mirror of
https://github.com/grassrootseconomics/eth-tracker.git
synced 2026-05-19 19:10:56 +02:00
feat: change transfer event lookup to enforce both token AND address existence before emitting event
* Add ExistsNetwork cache lookup * Exists now only accepts a single param
This commit is contained in:
19
internal/cache/xmap.go
vendored
19
internal/cache/xmap.go
vendored
@@ -26,8 +26,23 @@ func (c *mapCache) Remove(_ context.Context, key string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *mapCache) Exists(_ context.Context, key ...string) (bool, error) {
|
||||
for _, v := range key {
|
||||
func (c *mapCache) Exists(_ context.Context, key string) (bool, error) {
|
||||
_, ok := c.xmap.Load(key)
|
||||
if ok {
|
||||
return true, nil
|
||||
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
func (c *mapCache) ExistsNetwork(_ context.Context, token string, addresses ...string) (bool, error) {
|
||||
_, ok := c.xmap.Load(token)
|
||||
if !ok {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
for _, v := range addresses {
|
||||
_, ok := c.xmap.Load(v)
|
||||
if ok {
|
||||
return true, nil
|
||||
|
||||
Reference in New Issue
Block a user