github.com/onflow/flow-go@v0.35.7-crescendo-preview.23-atree-inlining/model/libp2p/peer.go (about)

     1  package libp2p
     2  
     3  import (
     4  	"github.com/onflow/flow-go/model/flow"
     5  )
     6  
     7  // Peer holds the information we know about a peer on the network, such as his
     8  // ID and what events he has seen.
     9  type Peer struct {
    10  	ID   flow.Identifier
    11  	Seen map[string]struct{}
    12  }
    13  
    14  // PeerList represents a list of peers.
    15  type PeerList []*Peer
    16  
    17  // IDs returns the list of IDs for the peers in the list.
    18  func (pl PeerList) NodeIDs() []flow.Identifier {
    19  	nodeIDs := make([]flow.Identifier, 0, len(pl))
    20  	for _, p := range pl {
    21  		nodeIDs = append(nodeIDs, p.ID)
    22  	}
    23  	return nodeIDs
    24  }
    25  
    26  // PeerFilter is a function to filter peers by the information they hold.
    27  type PeerFilter func(*Peer) bool