github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/p2p/scoring/internal/appSpecificScoreRecord.go (about) 1 package internal 2 3 import ( 4 "time" 5 6 "github.com/libp2p/go-libp2p/core/peer" 7 8 "github.com/onflow/flow-go/model/flow" 9 ) 10 11 // appSpecificScoreRecordEntity is an entity that represents the application specific score of a peer. 12 type appSpecificScoreRecordEntity struct { 13 // entityId is the key of the entity in the cache. It is the hash of the peer id. 14 // It is intentionally encoded as part of the struct to avoid recomputing it. 15 entityId flow.Identifier 16 17 // PeerID is the peer id of the peer that is the owner of the subscription. 18 PeerID peer.ID 19 20 // Score is the application specific score of the peer. 21 Score float64 22 23 // LastUpdated is the last time the score was updated. 24 LastUpdated time.Time 25 } 26 27 var _ flow.Entity = (*appSpecificScoreRecordEntity)(nil) 28 29 // ID returns the entity id of the subscription record, which is the hash of the peer id. 30 // The AppSpecificScoreCache uses the entity id as the key in the cache. 31 func (a appSpecificScoreRecordEntity) ID() flow.Identifier { 32 return a.entityId 33 } 34 35 // Checksum returns the entity id of the subscription record, which is the hash of the peer id. 36 // It is of no use in the cache, but it is implemented to satisfy the flow.Entity interface. 37 func (a appSpecificScoreRecordEntity) Checksum() flow.Identifier { 38 return a.entityId 39 }