Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/cache endpoint #18

Open
wants to merge 3 commits into
base: mainnet
from
Open

Feat/cache endpoint #18

wants to merge 3 commits into from

Conversation

mxmar
Copy link

@mxmar mxmar commented May 20, 2024

This PR adds cache flow for totalSupply regarding gobitfly#2529 (comment) core developer comment.

@mxmar mxmar added the enhancement New feature or request label May 20, 2024
@mxmar mxmar requested a review from Wolmin May 20, 2024 15:01
@mxmar mxmar self-assigned this May 20, 2024
Copy link

@Wolmin Wolmin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments, mostly formatting

services/services.go Outdated Show resolved Hide resolved
services/services.go Show resolved Hide resolved
services/services.go Outdated Show resolved Hide resolved
func LatestTotalSupply() (string, error) {
cacheKey := fmt.Sprintf("%d:frontend:latestTotalSupply", utils.Config.Chain.Config.DepositChainID)

if totalSupply, err := cache.TieredCache.GetStringWithLocalTimeout(cacheKey, time.Second*5); err == nil {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this protected in case we get the totalSupply from cache before we set it in place? Or generally if the cache key is missing?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I follow Beaconcha.in implementation rules:

func poolsUpdater(wg *sync.WaitGroup) {
+
if wanted, err := cache.TieredCache.GetWithLocalTimeout(cacheKey, time.Second*5, wanted); err == nil {
so I've assumed that it's preferred design :) But I'm open to discuss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request