synchronise

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 30, 2018 License: LGPL-3.0 Imports: 23 Imported by: 0

Documentation

Index

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 同步启动函数,供外部调用

func (*Downloader) Terminate

func (d *Downloader) Terminate()

Terminate 强行终止同步

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) Enqueue

func (f *Fetcher) Enqueue(peer string, block *types.Block, fetchBlock blockRequesterFn) error

Enqueue 收到完整块时调用

func (*Fetcher) FilterBlocks

func (f *Fetcher) FilterBlocks(id string, blocks types.Blocks, fetchBlock blockRequesterFn) types.Blocks

FilterBlock 过滤blocks是否为fetcher请求的,处理掉是fetcher请求的,将不是fetcher请求的返回

func (*Fetcher) Notify

func (f *Fetcher) Notify(peer string, hash common.Hash, height uint32, fetchBlock blockRequesterFn) error

Notify 供外界调用 收到新块(hash height等)通知

func (*Fetcher) Start

func (f *Fetcher) Start()

Start start fetcher

func (*Fetcher) Stop

func (f *Fetcher) Stop()

Stop stop 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 广播交易

func (*ProtocolManager) Start

func (pm *ProtocolManager) Start()

Start 启动pm

func (*ProtocolManager) Stop

func (pm *ProtocolManager) Stop()

Stop 停止pm

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL