github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/p2p/scoring/internal/subscriptionRecord.go (about) 1 package internal 2 3 import ( 4 "github.com/libp2p/go-libp2p/core/peer" 5 6 "github.com/onflow/flow-go/model/flow" 7 ) 8 9 // SubscriptionRecordEntity is an entity that represents a the list of topics a peer is subscribed to. 10 // It is internally used by the SubscriptionRecordCache to store the subscription records in the cache. 11 type SubscriptionRecordEntity struct { 12 // entityId is the key of the entity in the cache. It is the hash of the peer id. 13 // It is intentionally encoded as part of the struct to avoid recomputing it. 14 entityId flow.Identifier 15 16 // PeerID is the peer id of the peer that is the owner of the subscription. 17 PeerID peer.ID 18 19 // Topics is the list of topics the peer is subscribed to. 20 Topics []string 21 22 // LastUpdatedCycle is the last cycle counter value that this record was updated. 23 // This is used to clean up old records' topics upon update. 24 LastUpdatedCycle uint64 25 } 26 27 var _ flow.Entity = (*SubscriptionRecordEntity)(nil) 28 29 // ID returns the entity id of the subscription record, which is the hash of the peer id. 30 func (s SubscriptionRecordEntity) ID() flow.Identifier { 31 return s.entityId 32 } 33 34 // Checksum returns the entity id of the subscription record, which is the hash of the peer id. 35 // It is of no use in the cache, but it is implemented to satisfy the flow.Entity interface. 36 func (s SubscriptionRecordEntity) Checksum() flow.Identifier { 37 return s.ID() 38 }