github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/module/mempool/herocache/backdata/tracer.go (about) 1 package herocache 2 3 import "github.com/onflow/flow-go/model/flow" 4 5 type CacheOpt func(*Cache) 6 7 // Tracer is a generic interface that is used to report specific events that happen during 8 // lifetime of Cache and are potentially interesting for external consumer. 9 type Tracer interface { 10 // EntityEjectionDueToEmergency reports ejected entity whenever a bucket is found full and all of its keys are valid, i.e., 11 // each key belongs to an existing (key, entity) pair. 12 // Hence, adding a new key to that bucket will replace the oldest valid key inside that bucket. 13 // This ejection happens with very low, but still cryptographically non-negligible probability. 14 EntityEjectionDueToEmergency(ejectedEntity flow.Entity) 15 // EntityEjectionDueToFullCapacity reports ejected entity whenever adding a new (key, entity) to the cache results in ejection of another (key', entity') pair. 16 // This normally happens -- and is expected -- when the cache is full. 17 EntityEjectionDueToFullCapacity(ejectedEntity flow.Entity) 18 } 19 20 // WithTracer injects tracer into the cache 21 func WithTracer(t Tracer) CacheOpt { 22 return func(c *Cache) { 23 c.tracer = t 24 } 25 }