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:
2024-11-20 09:53:54 +03:00
parent faa428c583
commit cf263c7d15
4 changed files with 45 additions and 31 deletions

View File

@@ -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