github.com/aergoio/aergo@v1.3.1/p2p/p2pcommon/peerrole.go (about)

     1  /*
     2   * @file
     3   * @copyright defined in aergo/LICENSE.txt
     4   */
     5  
     6  package p2pcommon
     7  
     8  import "github.com/aergoio/aergo/types"
     9  
    10  type PeerRole uint8
    11  
    12  const (
    13  	UnknownRole PeerRole = iota
    14  	BlockProducer
    15  	Watcher
    16  	_
    17  )
    18  //go:generate stringer -type=PeerRole
    19  
    20  type PeerRoleManager interface {
    21  	UpdateBP(toAdd []types.PeerID, toRemove []types.PeerID)
    22  
    23  	// SelfRole returns role of this peer itself
    24  	SelfRole() PeerRole
    25  	// GetRole returns role of remote peer
    26  	GetRole(pid types.PeerID) PeerRole
    27  	// NotifyNewBlockMsg selects target peers with the appropriate role and sends them a NewBlockNotice
    28  	NotifyNewBlockMsg(mo MsgOrder, peers []RemotePeer) (skipped, sent int)
    29  }
    30  //go:generate mockgen -source=peerrole.go -package=p2pmock -destination=../p2pmock/mock_peerrole.go
    31  
    32  type AttrModifier struct {
    33  	ID   types.PeerID
    34  	Role PeerRole
    35  }