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

fix(screener): fix the cache #3412

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion contrib/screener-api/chainalysis/chainalysisapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
maxCacheSizeGB = 3
bytesInGB = 1024 * 1024 * 1024
chainalysisRequestTimeout = 30 * time.Second
defaultTTL = 24 * time.Hour
)

// NewClient creates a new Chainalysis API client.
Expand All @@ -53,7 +54,10 @@

// max cache size 3gb
// TODO: make this configurable.
registrationCache := gocache.NewCache().WithEvictionPolicy(gocache.LeastRecentlyUsed).WithMaxMemoryUsage(maxCacheSizeGB * bytesInGB)
registrationCache := gocache.NewCache().
WithEvictionPolicy(gocache.LeastRecentlyUsed).
WithMaxMemoryUsage(maxCacheSizeGB * bytesInGB).
WithDefaultTTL(defaultTTL)

Check warning on line 60 in contrib/screener-api/chainalysis/chainalysisapi.go

View check run for this annotation

Codecov / codecov/patch

contrib/screener-api/chainalysis/chainalysisapi.go#L57-L60

Added lines #L57 - L60 were not covered by tests

otelresty.TraceClient(client, otelresty.WithTracerProvider(metricHandler.GetTracerProvider()))

Expand Down Expand Up @@ -132,6 +136,8 @@
return true, nil
}

c.registrationCache.Delete(address)

Check warning on line 140 in contrib/screener-api/chainalysis/chainalysisapi.go

View check run for this annotation

Codecov / codecov/patch

contrib/screener-api/chainalysis/chainalysisapi.go#L139-L140

Added lines #L139 - L140 were not covered by tests
return false, nil
}

Expand Down
Loading