Documentation ¶
Index ¶
- type Downloader
- type Fetcher
- func (f *Fetcher) Enqueue(peer string, block *types.Block, fetchBlock blockRequesterFn) error
- func (f *Fetcher) FilterBlocks(id string, blocks types.Blocks, fetchBlock blockRequesterFn) types.Blocks
- func (f *Fetcher) Notify(peer string, hash common.Hash, height uint32, fetchBlock blockRequesterFn) error
- func (f *Fetcher) Start()
- func (f *Fetcher) Stop()
- type ProtocolManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Downloader ¶
type Downloader struct {
// contains filtered or unexported fields
}
Downloader 区块同步工人
func NewDownloader ¶
func NewDownloader(peers *peerSet, chain blockchain.BlockChain, dropPeer peerDropFn) *Downloader
New create Downloader object
func (*Downloader) DeliverBlocks ¶
func (d *Downloader) DeliverBlocks(id string, blocks types.Blocks) error
DeliverBlocks 将收到的区块分发给loop
func (*Downloader) IsSynchronising ¶
func (d *Downloader) IsSynchronising() bool
IsSynchronising 是否已经在同步了
func (*Downloader) Synchronise ¶
func (d *Downloader) Synchronise(id string) error
Synchronise 同步启动函数,供外部调用
type Fetcher ¶
type Fetcher struct {
// contains filtered or unexported fields
}
Fetcher 获取区块结构体
func NewFetcher ¶
func NewFetcher(getLocalBlock blockExistFn, broadcastBlock blockBroadcasterFn, currentChainHeight chainHeightFn, consensusChainHeight chainHeightFn, insertChain chainInsertFn, dropPeer peerDropFn) *Fetcher
NewFetcher 实例化fetcher
func (*Fetcher) FilterBlocks ¶
func (f *Fetcher) FilterBlocks(id string, blocks types.Blocks, fetchBlock blockRequesterFn) types.Blocks
FilterBlock 过滤blocks是否为fetcher请求的,处理掉是fetcher请求的,将不是fetcher请求的返回
type ProtocolManager ¶
type ProtocolManager struct {
// contains filtered or unexported fields
}
func NewProtocolManager ¶
func NewProtocolManager(chainID uint64, nodeID []byte, blockchain *chain.BlockChain, txpool *chain.TxPool, discover *p2p.DiscoverManager) *ProtocolManager
func (*ProtocolManager) BroadcastTxs ¶
func (pm *ProtocolManager) BroadcastTxs(txs types.Transactions)
BroadcastTx 广播交易
Click to show internal directories.
Click to hide internal directories.