Documentation ¶
Index ¶
- Variables
- type BasePeer
- type BasePeerSet
- type BroadcastMsg
- type Peer
- 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
- type 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)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrPeerMisbehave = errors.New("peer is misbehave") ErrNoValidPeer = errors.New("Can't find valid fast sync peer") )
Functions ¶
This section is empty.
Types ¶
type BasePeer ¶
type BasePeer interface { Moniker() string Addr() net.Addr ID() string RemoteAddrHost() string ServiceFlag() consensus.ServiceFlag TrafficStatus() (*flowrate.Status, *flowrate.Status) TrySend(byte, interface{}) bool IsLAN() bool }
BasePeer is the interface for connection level peer
type BasePeerSet ¶
type BasePeerSet interface { StopPeerGracefully(string) IsBanned(ip string, level byte, reason string) bool }
BasePeerSet is the intergace for connection level peer manager
type BroadcastMsg ¶
type Peer ¶
type Peer struct { BasePeer // contains filtered or unexported fields }
func (*Peer) AddFilterAddress ¶
func (*Peer) AddFilterAddresses ¶
func (*Peer) FilterClear ¶
func (p *Peer) FilterClear()
func (*Peer) GetBlockByHeight ¶
func (*Peer) GetHeaders ¶
func (*Peer) GetPeerInfo ¶
func (*Peer) JustifiedHeight ¶
func (*Peer) SendHeaders ¶
func (p *Peer) SendHeaders(headers []*types.BlockHeader) (bool, error)
func (*Peer) SendStatus ¶
func (p *Peer) SendStatus(bestHeader, justifiedHeader *types.BlockHeader) error
type PeerInfo ¶
type PeerInfo struct { ID string `json:"peer_id"` Moniker string `json:"moniker"` RemoteAddr string `json:"remote_addr"` Height uint64 `json:"height"` Ping string `json:"ping"` Duration string `json:"duration"` TotalSent int64 `json:"total_sent"` TotalReceived int64 `json:"total_received"` AverageSentRate int64 `json:"average_sent_rate"` AverageReceivedRate int64 `json:"average_received_rate"` CurrentSentRate int64 `json:"current_sent_rate"` CurrentReceivedRate int64 `json:"current_received_rate"` }
PeerInfo indicate peer status snap
type PeerSet ¶
type PeerSet struct { BasePeerSet // contains filtered or unexported fields }
func NewPeerSet ¶
func NewPeerSet(basePeerSet BasePeerSet) *PeerSet
newPeerSet creates a new peer set to track the active participants.
func (*PeerSet) BroadcastMsg ¶
func (ps *PeerSet) BroadcastMsg(bm BroadcastMsg) error
BroadcastMsg Broadcast message to the target peers and mark the message send record
func (*PeerSet) BroadcastNewStatus ¶
func (ps *PeerSet) BroadcastNewStatus(bestHeader, justifiedHeader *types.BlockHeader) error
func (*PeerSet) GetPeerInfos ¶
func (*PeerSet) GetPeersByHeight ¶
func (*PeerSet) MarkBlockVerification ¶
func (*PeerSet) MarkStatus ¶
func (*PeerSet) PeersWithoutSignature ¶
func (*PeerSet) ProcessIllegal ¶
func (*PeerSet) RemovePeer ¶
func (*PeerSet) SetJustifiedStatus ¶
Click to show internal directories.
Click to hide internal directories.