Documentation ¶
Index ¶
- type Communicator
- func (c *Communicator) BroadcastBlock(blk *block.Block)
- func (c *Communicator) PeerCount() int
- func (c *Communicator) PeersStats() []*PeerStats
- func (c *Communicator) Protocols() []*p2psrv.Protocol
- func (c *Communicator) Start()
- func (c *Communicator) Stop()
- func (c *Communicator) SubscribeBlock(ch chan *NewBlockEvent) event.Subscription
- func (c *Communicator) Sync(handler HandleBlockStream)
- func (c *Communicator) Synced() <-chan struct{}
- type HandleBlockStream
- type NewBlockEvent
- type Peer
- func (p *Peer) Duration() mclock.AbsTime
- func (p *Peer) Head() (id thor.Bytes32, totalScore uint64)
- func (p *Peer) IsBlockKnown(id thor.Bytes32) bool
- func (p *Peer) IsTransactionKnown(hash thor.Bytes32) bool
- func (p *Peer) MarkBlock(id thor.Bytes32)
- func (p *Peer) MarkTransaction(hash thor.Bytes32)
- func (p *Peer) UpdateHead(id thor.Bytes32, totalScore uint64)
- type PeerSet
- type PeerStats
- type Peers
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Communicator ¶
type Communicator struct {
// contains filtered or unexported fields
}
Communicator communicates with remote p2p peers to exchange blocks and txs, etc.
func New ¶
func New(chain *chain.Chain, txPool *txpool.TxPool) *Communicator
New create a new Communicator instance.
func (*Communicator) BroadcastBlock ¶
func (c *Communicator) BroadcastBlock(blk *block.Block)
BroadcastBlock broadcast a block to remote peers.
func (*Communicator) PeerCount ¶
func (c *Communicator) PeerCount() int
PeerCount returns count of peers.
func (*Communicator) PeersStats ¶
func (c *Communicator) PeersStats() []*PeerStats
PeersStats returns all peers' stats
func (*Communicator) Protocols ¶
func (c *Communicator) Protocols() []*p2psrv.Protocol
Protocols returns all supported protocols.
func (*Communicator) SubscribeBlock ¶
func (c *Communicator) SubscribeBlock(ch chan *NewBlockEvent) event.Subscription
SubscribeBlock subscribe the event that new block received.
func (*Communicator) Sync ¶
func (c *Communicator) Sync(handler HandleBlockStream)
Sync start synchronization process.
func (*Communicator) Synced ¶
func (c *Communicator) Synced() <-chan struct{}
Synced returns a channel indicates if synchronization process passed.
type HandleBlockStream ¶
HandleBlockStream to handle the stream of downloaded blocks in sync process.
type NewBlockEvent ¶
NewBlockEvent event emitted when received block announcement.
type Peer ¶
Peer extends p2p.Peer with RPC integrated.
func (*Peer) IsBlockKnown ¶
IsBlockKnown returns if the block is known.
func (*Peer) IsTransactionKnown ¶
IsTransactionKnown returns if the transaction is known.
func (*Peer) MarkTransaction ¶
MarkTransaction marks a transaction to known.
type PeerSet ¶
type PeerSet struct {
// contains filtered or unexported fields
}
PeerSet manages a set of peers, which mapped by NodeID.
type PeerStats ¶
type PeerStats struct { Name string BestBlockID thor.Bytes32 TotalScore uint64 PeerID string NetAddr string Inbound bool Duration uint64 // in seconds }
PeerStats records stats of a peer.