Versions in this module Expand all Collapse all v1 v1.1.2 Sep 16, 2021 Changes in this version + const BlockRequestByte + const BlockResponseByte + const BlockchainChannel + const BlocksRequestByte + const BlocksResponseByte + const FilterAddByte + const FilterClearByte + const FilterLoadByte + const HeadersRequestByte + const HeadersResponseByte + const MerkleRequestByte + const MerkleResponseByte + const NewMineBlockByte + const NewTransactionByte + const StatusRequestByte + const StatusResponseByte + var ErrPeerMisbehave = errors.New("peer is misbehave") + type BasePeer interface + Addr func() net.Addr + ID func() string + IsLAN func() bool + 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 BlockMessage struct + RawBlock []byte + func NewBlockMessage(block *types.Block) (*BlockMessage, error) + func (m *BlockMessage) GetBlock() (*types.Block, error) + func (m *BlockMessage) String() string + type BlockchainMessage interface + String func() string + func DecodeMessage(bz []byte) (msgType byte, msg BlockchainMessage, err error) + type BlocksMessage struct + RawBlocks [][]byte + func NewBlocksMessage(blocks []*types.Block) (*BlocksMessage, error) + func (m *BlocksMessage) GetBlocks() ([]*types.Block, error) + func (m *BlocksMessage) String() string + type Chain interface + BestBlockHeader func() *types.BlockHeader + BestBlockHeight func() uint64 + CalcNextSeed func(*bc.Hash) (*bc.Hash, error) + GetBlockByHash func(*bc.Hash) (*types.Block, error) + GetBlockByHeight func(uint64) (*types.Block, error) + GetHeaderByHash func(*bc.Hash) (*types.BlockHeader, error) + GetHeaderByHeight func(uint64) (*types.BlockHeader, error) + GetTransactionStatus func(*bc.Hash) (*bc.TransactionStatus, error) + InMainChain func(bc.Hash) bool + ProcessBlock func(*types.Block) (bool, error) + ValidateTx func(*types.Tx) (bool, error) + type FilterAddMessage struct + Address []byte + func (m *FilterAddMessage) String() string + type FilterClearMessage struct + func (m *FilterClearMessage) String() string + type FilterLoadMessage struct + Addresses [][]byte + func (m *FilterLoadMessage) String() string + type GetBlockMessage struct + Height uint64 + RawHash [32]byte + func (m *GetBlockMessage) GetHash() *bc.Hash + func (m *GetBlockMessage) String() string + type GetBlocksMessage struct + RawBlockLocator [][32]byte + RawStopHash [32]byte + func NewGetBlocksMessage(blockLocator []*bc.Hash, stopHash *bc.Hash) *GetBlocksMessage + func (m *GetBlocksMessage) GetBlockLocator() []*bc.Hash + func (m *GetBlocksMessage) GetStopHash() *bc.Hash + func (m *GetBlocksMessage) String() string + type GetHeadersMessage struct + RawBlockLocator [][32]byte + RawStopHash [32]byte + func NewGetHeadersMessage(blockLocator []*bc.Hash, stopHash *bc.Hash) *GetHeadersMessage + func (m *GetHeadersMessage) GetBlockLocator() []*bc.Hash + func (m *GetHeadersMessage) GetStopHash() *bc.Hash + func (m *GetHeadersMessage) String() string + type GetMerkleBlockMessage struct + Height uint64 + RawHash [32]byte + func (m *GetMerkleBlockMessage) GetHash() *bc.Hash + func (m *GetMerkleBlockMessage) String() string + type HeadersMessage struct + RawHeaders [][]byte + func NewHeadersMessage(headers []*types.BlockHeader) (*HeadersMessage, error) + func (m *HeadersMessage) GetHeaders() ([]*types.BlockHeader, error) + func (m *HeadersMessage) String() string + type MerkleBlockMessage struct + Flags []byte + RawBlockHeader []byte + RawTxDatas [][]byte + RawTxStatuses [][]byte + StatusHashes [][32]byte + TxHashes [][32]byte + func NewMerkleBlockMessage() *MerkleBlockMessage + func (m *MerkleBlockMessage) String() string + type MineBlockMessage struct + RawBlock []byte + func NewMinedBlockMessage(block *types.Block) (*MineBlockMessage, error) + func (m *MineBlockMessage) GetMineBlock() (*types.Block, error) + func (m *MineBlockMessage) String() string + type PeerInfo struct + AverageReceivedRate int64 + AverageSentRate int64 + CurrentReceivedRate int64 + CurrentSentRate int64 + Duration string + Height uint64 + ID string + Ping string + RemoteAddr string + TotalReceived int64 + TotalSent int64 + type ProtocolReactor struct + func NewProtocolReactor(sm *SyncManager, peers *peerSet) *ProtocolReactor + func (pr *ProtocolReactor) AddPeer(peer *p2p.Peer) error + func (pr *ProtocolReactor) GetChannels() []*connection.ChannelDescriptor + func (pr *ProtocolReactor) OnStart() error + func (pr *ProtocolReactor) OnStop() + func (pr *ProtocolReactor) Receive(chID byte, src *p2p.Peer, msgBytes []byte) + func (pr *ProtocolReactor) RemovePeer(peer *p2p.Peer, reason interface{}) + type StatusRequestMessage struct + func (m *StatusRequestMessage) String() string + type StatusResponseMessage struct + GenesisHash [32]byte + Height uint64 + RawHash [32]byte + func NewStatusResponseMessage(blockHeader *types.BlockHeader, hash *bc.Hash) *StatusResponseMessage + func (m *StatusResponseMessage) GetGenesisHash() *bc.Hash + func (m *StatusResponseMessage) GetHash() *bc.Hash + func (m *StatusResponseMessage) String() string + type Switch interface + AddReactor func(name string, reactor p2p.Reactor) p2p.Reactor + DialPeerWithAddress func(addr *p2p.NetAddress) error + IsBanned func(peerID string, level byte, reason string) bool + IsListening func() bool + NodeInfo func() *p2p.NodeInfo + Peers func() *p2p.PeerSet + Start func() (bool, error) + Stop func() bool + StopPeerGracefully func(string) + type SyncManager struct + func NewSyncManager(config *cfg.Config, chain Chain, txPool *core.TxPool, ...) (*SyncManager, error) + func (sm *SyncManager) BestPeer() *PeerInfo + func (sm *SyncManager) DialPeerWithAddress(addr *p2p.NetAddress) error + func (sm *SyncManager) GetNetwork() string + func (sm *SyncManager) GetPeerInfos() []*PeerInfo + func (sm *SyncManager) IsCaughtUp() bool + func (sm *SyncManager) IsListening() bool + func (sm *SyncManager) NodeInfo() *p2p.NodeInfo + func (sm *SyncManager) PeerCount() int + func (sm *SyncManager) Start() error + func (sm *SyncManager) Stop() + func (sm *SyncManager) StopPeer(peerID string) error + type TransactionMessage struct + RawTx []byte + func NewTransactionMessage(tx *types.Tx) (*TransactionMessage, error) + func (m *TransactionMessage) GetTransaction() (*types.Tx, error) + func (m *TransactionMessage) String() string