github.com/koko1123/flow-go-1@v0.29.6/network/p2p/scoring/utils.go (about) 1 package scoring 2 3 import ( 4 "github.com/libp2p/go-libp2p/core/peer" 5 6 "github.com/koko1123/flow-go-1/model/flow" 7 "github.com/koko1123/flow-go-1/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.Ejected { 18 return nil, NewInvalidPeerIDError(pid, PeerIdStatusEjected) 19 } 20 21 return flowId, nil 22 }