Versions in this module Expand all Collapse all v1 v1.2.2 Dec 22, 2021 v1.2.1 Dec 22, 2021 Changes in this version + var ErrNoValidPeer = errors.New("Can't find valid fast sync peer") + var ErrPeerMisbehave = errors.New("peer is misbehave") + type BasePeer interface + Addr func() net.Addr + ID func() string + IsLAN func() bool + Moniker func() string + RemoteAddrHost func() string + ServiceFlag func() consensus.ServiceFlag + TrafficStatus func() (*flowrate.Status, *flowrate.Status) + TrySend func(byte, interface{}) bool + type BasePeerSet interface + IsBanned func(ip string, level byte, reason string) bool + StopPeerGracefully func(string) + type BroadcastMsg interface + FilterTargetPeers func(ps *PeerSet) []string + GetChan func() byte + GetMsg func() interface{} + MarkSendRecord func(ps *PeerSet, peers []string) + MsgString func() string + type Peer struct + func (p *Peer) AddFilterAddress(address []byte) + func (p *Peer) AddFilterAddresses(addresses [][]byte) + func (p *Peer) FilterClear() + func (p *Peer) GetBlockByHeight(height uint64) bool + func (p *Peer) GetBlocks(locator []*bc.Hash, stopHash *bc.Hash) bool + func (p *Peer) GetHeaders(locator []*bc.Hash, stopHash *bc.Hash, skip uint64) bool + func (p *Peer) GetPeerInfo() *PeerInfo + func (p *Peer) Height() uint64 + func (p *Peer) JustifiedHeight() uint64 + func (p *Peer) MarkBlock(hash *bc.Hash) + func (p *Peer) SendBlock(block *types.Block) (bool, error) + func (p *Peer) SendBlocks(blocks []*types.Block) (bool, error) + func (p *Peer) SendHeaders(headers []*types.BlockHeader) (bool, error) + func (p *Peer) SendMerkleBlock(block *types.Block) (bool, error) + func (p *Peer) SendStatus(bestHeader, justifiedHeader *types.BlockHeader) error + func (p *Peer) SendTransactions(txs []*types.Tx) error + func (p *Peer) SetBestStatus(bestHeight uint64, bestHash *bc.Hash) + func (p *Peer) SetJustifiedStatus(justifiedHeight uint64, justifiedHash *bc.Hash) + type PeerInfo struct + AverageReceivedRate int64 + AverageSentRate int64 + CurrentReceivedRate int64 + CurrentSentRate int64 + Duration string + Height uint64 + ID string + Moniker string + Ping string + RemoteAddr string + TotalReceived int64 + TotalSent int64 + type PeerSet struct + func NewPeerSet(basePeerSet BasePeerSet) *PeerSet + func (ps *PeerSet) AddPeer(peer BasePeer) + func (ps *PeerSet) BestPeer(flag consensus.ServiceFlag) *Peer + func (ps *PeerSet) BroadcastMsg(bm BroadcastMsg) error + func (ps *PeerSet) BroadcastNewStatus(bestHeader, justifiedHeader *types.BlockHeader) error + func (ps *PeerSet) BroadcastTx(tx *types.Tx) error + func (ps *PeerSet) GetPeer(id string) *Peer + func (ps *PeerSet) GetPeerInfos() []*PeerInfo + func (ps *PeerSet) GetPeersByHeight(height uint64) []*Peer + func (ps *PeerSet) MarkBlock(peerID string, hash *bc.Hash) + func (ps *PeerSet) MarkBlockVerification(peerID string, signature []byte) + func (ps *PeerSet) MarkStatus(peerID string, height uint64) + func (ps *PeerSet) MarkTx(peerID string, txHash bc.Hash) + func (ps *PeerSet) PeersWithoutBlock(hash bc.Hash) []string + func (ps *PeerSet) PeersWithoutSignature(signature []byte) []string + func (ps *PeerSet) ProcessIllegal(peerID string, level byte, reason string) + func (ps *PeerSet) RemovePeer(peerID string) + func (ps *PeerSet) SendMsg(peerID string, msgChannel byte, msg interface{}) bool + func (ps *PeerSet) SetJustifiedStatus(peerID string, height uint64, hash *bc.Hash) + func (ps *PeerSet) SetStatus(peerID string, height uint64, hash *bc.Hash)