Documentation ¶
Index ¶
- func BootstrapPeers() []multiaddr.Multiaddr
- func ConnectToBootstraps(ctx context.Context, _host host.Host) (int, int)
- func CreateHost(ctx context.Context) (host.Host, error)
- func HandleStream(stream network.Stream)
- func InitMemPool(pool *data.MemPool) error
- func InitPubSub(client *pubsub.PubSub) error
- func Listen(_host host.Host)
- func LookForPeers(ctx context.Context, _host host.Host, _dht *dht.IpfsDHT, ...)
- func ReadFrom(ctx context.Context, cancel context.CancelFunc, rw *bufio.ReadWriter, ...)
- func SetUpPeerDiscovery(ctx context.Context, _host host.Host, comm chan struct{})
- func Setup(ctx context.Context, comm chan struct{}) error
- func ShowHost(_host host.Host)
- func WriteTo(ctx context.Context, cancel context.CancelFunc, rw *bufio.ReadWriter, ...)
- type ConnectionManager
- type IsConnected
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BootstrapPeers ¶
func BootstrapPeers() []multiaddr.Multiaddr
BootstrapPeers - Returns addresses of bootstrap nodes, if none are given using default ones
func ConnectToBootstraps ¶
ConnectToBootstraps - Attempting to connect to bootstrap nodes concurrently Waiting for all of them to complete, after that returning back how many attempts went successful among total attempts, respectively
func CreateHost ¶
CreateHost - Creates a libp2p host, to be used for communicating with other `harmony` peers
func HandleStream ¶
HandleStream - Attepts new stream & handles it through out its life time
func InitMemPool ¶
InitMemPool - Initializing mempool handle, in this module so that it can be used updating local mempool state, when new deserialisable tx chunk is received from any peer, over p2p network
func InitPubSub ¶ added in v0.9.3
InitPubSub - Initializing pubsub handle, so that all subscriptions can be managed using it
func Listen ¶
Listen - Handle incoming connection of other harmony peer for certain supported protocol(s)
func LookForPeers ¶
func LookForPeers(ctx context.Context, _host host.Host, _dht *dht.IpfsDHT, routing *discovery.RoutingDiscovery, comm chan struct{})
LookForPeers - Asks this node to start looking for peers, does for some time & attempts to connect to them, while setting up stream for further chit-chat
func ReadFrom ¶
func ReadFrom(ctx context.Context, cancel context.CancelFunc, rw *bufio.ReadWriter, peerId string, remote multiaddr.Multiaddr)
ReadFrom - Read from stream & attempt to deserialize length prefixed tx data received from peer, which will be acted upon
func SetUpPeerDiscovery ¶
SetUpPeerDiscovery - Setting up peer discovery mechanism, by connecting to bootstrap nodes first, then advertises self with rendezvous & attempts to discover peers with same rendezvous, which are to be eventually connected with
func WriteTo ¶
func WriteTo(ctx context.Context, cancel context.CancelFunc, rw *bufio.ReadWriter, peerId string, remote multiaddr.Multiaddr)
WriteTo - Write to mempool changes into stream i.e. connection with some remote peer
Types ¶
type ConnectionManager ¶
type ConnectionManager struct { Peers map[peer.ID]bool NewPeerChan chan peer.ID DroppedPeerChan chan peer.ID IsConnectedChan chan IsConnected }
ConnectionManager - All connected peers to be kept track of, so that we don't attempt to reconnect to same peer again
func NewConnectionManager ¶
func NewConnectionManager() *ConnectionManager
func (*ConnectionManager) Added ¶
func (c *ConnectionManager) Added(peerId peer.ID)
Added - When new connection is established
func (*ConnectionManager) Dropped ¶
func (c *ConnectionManager) Dropped(peerId peer.ID)
Dropped - When connection with some peer is dropped
func (*ConnectionManager) IsConnected ¶
func (c *ConnectionManager) IsConnected(peerId peer.ID) bool
IsConnected - Before attempting to (re-)establish connection with peer, check whether already connected or not
func (*ConnectionManager) Start ¶
func (c *ConnectionManager) Start(ctx context.Context)
Start - Listen for new peer we're getting connected to/ dropped
Also clean up list of dropped peers after every `n` time unit, to avoid lock contention as much as possible
type IsConnected ¶
IsConnected - Queries can be sent to connection manager by worker go routines over channel & response to be sent back to them over `response` channel