Documentation ¶
Index ¶
- Constants
- Variables
- type BlockRequestMessage
- type BlockResponseMessage
- type BlockchainMessage
- type Fetcher
- type MineBlockMessage
- type ProtocolReactor
- func (pr *ProtocolReactor) AddPeer(peer *p2p.Peer) error
- func (pr *ProtocolReactor) GetChannels() []*p2p.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 Response
- type StatusRequestMessage
- type StatusResponseMessage
- type SyncManager
- type TransactionNotifyMessage
Constants ¶
const ( BlockRequestByte = byte(0x10) BlockResponseByte = byte(0x11) StatusRequestByte = byte(0x20) StatusResponseByte = byte(0x21) NewTransactionByte = byte(0x30) NewMineBlockByte = byte(0x40) )
protocol msg
const ( // BlockchainChannel is a channel for blocks and status updates BlockchainChannel = byte(0x40) )
Variables ¶
Functions ¶
This section is empty.
Types ¶
type BlockRequestMessage ¶
BlockRequestMessage request blocks from remote peers by height/hash
func (*BlockRequestMessage) GetHash ¶
func (m *BlockRequestMessage) GetHash() *bc.Hash
GetHash get hash
func (*BlockRequestMessage) String ¶
func (m *BlockRequestMessage) String() string
String convert msg to string
type BlockResponseMessage ¶
type BlockResponseMessage struct {
RawBlock []byte
}
BlockResponseMessage response get block msg
func NewBlockResponseMessage ¶
func NewBlockResponseMessage(block *types.Block) (*BlockResponseMessage, error)
NewBlockResponseMessage construct bock response msg
func (*BlockResponseMessage) GetBlock ¶
func (m *BlockResponseMessage) GetBlock() *types.Block
GetBlock get block from msg
func (*BlockResponseMessage) String ¶
func (m *BlockResponseMessage) String() string
String convert msg to string
type BlockchainMessage ¶
type BlockchainMessage interface{}
BlockchainMessage is a generic message for this reactor.
func DecodeMessage ¶
func DecodeMessage(bz []byte) (msgType byte, msg BlockchainMessage, err error)
DecodeMessage decode msg
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher is responsible for accumulating block announcements from various peers and scheduling them for retrieval.
func NewFetcher ¶
NewFetcher New creates a block fetcher to retrieve blocks of the new mined.
type MineBlockMessage ¶
type MineBlockMessage struct {
RawBlock []byte
}
MineBlockMessage new mined block msg
func NewMinedBlockMessage ¶
func NewMinedBlockMessage(block *types.Block) (*MineBlockMessage, error)
NewMinedBlockMessage construct new mined block msg
func (*MineBlockMessage) GetMineBlock ¶
func (m *MineBlockMessage) GetMineBlock() (*types.Block, error)
GetMineBlock get mine block from msg
func (*MineBlockMessage) String ¶
func (m *MineBlockMessage) String() string
String convert msg to string
type ProtocolReactor ¶
type ProtocolReactor struct { p2p.BaseReactor // contains filtered or unexported fields }
ProtocolReactor handles new coming protocol message.
func NewProtocolReactor ¶
func NewProtocolReactor(chain *protocol.Chain, txPool *protocol.TxPool, sw *p2p.Switch, blockPeer *blockKeeper, fetcher *Fetcher, peers *peerSet, newPeerCh chan struct{}, txSyncCh chan *txsync, quitReqBlockCh chan *string) *ProtocolReactor
NewProtocolReactor returns the reactor of whole blockchain.
func (*ProtocolReactor) AddPeer ¶
func (pr *ProtocolReactor) AddPeer(peer *p2p.Peer) error
AddPeer implements Reactor by sending our state to peer.
func (*ProtocolReactor) GetChannels ¶
func (pr *ProtocolReactor) GetChannels() []*p2p.ChannelDescriptor
GetChannels implements Reactor
func (*ProtocolReactor) OnStart ¶
func (pr *ProtocolReactor) OnStart() error
OnStart implements BaseService
func (*ProtocolReactor) Receive ¶
func (pr *ProtocolReactor) Receive(chID byte, src *p2p.Peer, msgBytes []byte)
Receive implements Reactor by handling 4 types of messages (look below).
func (*ProtocolReactor) RemovePeer ¶
func (pr *ProtocolReactor) RemovePeer(peer *p2p.Peer, reason interface{})
RemovePeer implements Reactor by removing peer from the pool.
type Response ¶
type Response struct { Status string `json:"status,omitempty"` Msg string `json:"msg,omitempty"` Data interface{} `json:"data,omitempty"` }
Response describes the response standard.
type StatusRequestMessage ¶
type StatusRequestMessage struct{}
StatusRequestMessage status request msg
type StatusResponseMessage ¶
StatusResponseMessage get status response msg
func NewStatusResponseMessage ¶
func NewStatusResponseMessage(blockHeader *types.BlockHeader, hash *bc.Hash) *StatusResponseMessage
NewStatusResponseMessage construct get status response msg
func (*StatusResponseMessage) GetGenesisHash ¶ added in v0.5.1
func (m *StatusResponseMessage) GetGenesisHash() *bc.Hash
GetGenesisHash get hash from msg
func (*StatusResponseMessage) GetHash ¶
func (m *StatusResponseMessage) GetHash() *bc.Hash
GetHash get hash from msg
func (*StatusResponseMessage) String ¶
func (m *StatusResponseMessage) String() string
String convert msg to string
type SyncManager ¶
type SyncManager struct {
// contains filtered or unexported fields
}
SyncManager Sync Manager is responsible for the business layer information synchronization
func NewSyncManager ¶
func NewSyncManager(config *cfg.Config, chain *core.Chain, txPool *core.TxPool, newBlockCh chan *bc.Hash) (*SyncManager, error)
NewSyncManager create a sync manager
func (*SyncManager) BlockKeeper ¶
func (sm *SyncManager) BlockKeeper() *blockKeeper
BlockKeeper get block keeper
func (*SyncManager) DialSeeds ¶
func (sm *SyncManager) DialSeeds(seeds []string) error
DialSeeds dial seed peers
func (*SyncManager) NodeInfo ¶
func (sm *SyncManager) NodeInfo() *p2p.NodeInfo
NodeInfo get P2P peer node info
func (*SyncManager) Switch ¶
func (sm *SyncManager) Switch() *p2p.Switch
Switch get sync manager switch
type TransactionNotifyMessage ¶
type TransactionNotifyMessage struct {
RawTx []byte
}
TransactionNotifyMessage notify new tx msg
func NewTransactionNotifyMessage ¶
func NewTransactionNotifyMessage(tx *types.Tx) (*TransactionNotifyMessage, error)
NewTransactionNotifyMessage construct notify new tx msg
func (*TransactionNotifyMessage) GetTransaction ¶
func (m *TransactionNotifyMessage) GetTransaction() (*types.Tx, error)
GetTransaction get tx from msg