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

     1  /*
     2   * @file
     3   * @copyright defined in aergo/LICENSE.txt
     4   */
     5  
     6  //go:generate mockgen -source=peermanager.go -package=p2pmock -destination=../p2pmock/mock_peermanager.go
     7  package p2pcommon
     8  
     9  import (
    10  	"github.com/aergoio/aergo/message"
    11  	"github.com/aergoio/aergo/types"
    12  )
    13  
    14  // PeerManager is internal service that provide peer management
    15  type PeerManager interface {
    16  	AddPeerEventListener(l PeerEventListener)
    17  
    18  	Start() error
    19  	Stop() error
    20  
    21  	//NetworkTransport
    22  	SelfMeta() PeerMeta
    23  	SelfNodeID() types.PeerID
    24  
    25  	// AddNewPeer connect to peer. It will reset reconnect schedule and try to connect immediately if this peer is in reconnect cooltime.
    26  	AddNewPeer(meta PeerMeta)
    27  	// Remove peer from peer list. Peer dispose relative resources and stop itself, and then call PeerManager.RemovePeer
    28  	RemovePeer(peer RemotePeer)
    29  	UpdatePeerRole(changes []AttrModifier)
    30  
    31  	NotifyPeerAddressReceived([]PeerMeta)
    32  
    33  	// GetPeer return registered(handshaked) remote peer object. It is thread safe
    34  	GetPeer(ID types.PeerID) (RemotePeer, bool)
    35  	// GetPeers return all registered(handshaked) remote peers. It is thread safe
    36  	GetPeers() []RemotePeer
    37  	GetPeerAddresses(noHidden bool, showSelf bool) []*message.PeerInfo
    38  
    39  	GetPeerBlockInfos() []types.PeerBlockInfo
    40  
    41  	AddDesignatedPeer(meta PeerMeta)
    42  	RemoveDesignatedPeer(peerID types.PeerID)
    43  	ListDesignatedPeers() []PeerMeta
    44  }