github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/network/p2p/scoring/utils.go (about) 1 package scoring 2 3 import ( 4 "github.com/libp2p/go-libp2p/core/peer" 5 6 "github.com/onflow/flow-go/model/flow" 7 "github.com/onflow/flow-go/module" 8 ) 9 10 // HasValidFlowIdentity checks if the peer has a valid Flow identity. 11 func HasValidFlowIdentity(idProvider module.IdentityProvider, pid peer.ID) (*flow.Identity, error) { 12 flowId, ok := idProvider.ByPeerID(pid) 13 if !ok { 14 return nil, NewInvalidPeerIDError(pid, PeerIdStatusUnknown) 15 } 16 17 if flowId.IsEjected() { 18 return nil, NewInvalidPeerIDError(pid, PeerIdStatusEjected) 19 } 20 21 return flowId, nil 22 }