synchro

package
v0.0.0-...-376a440 Latest Latest
Warning

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

Go to latest
Published: May 10, 2020 License: LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockHashLeastNeighborNumber = 1
	BlockHashExpiredSeconds      = 60
)

Constant of blockhash sync

Variables

This section is empty.

Functions

This section is empty.

Types

type BlockHash

type BlockHash struct {
	Hash   []byte
	Number int64
	PeerID []p2p.PeerID
}

BlockHash return the block hash with the Peers that have it.

type Sync

type Sync struct {
	// contains filtered or unexported fields
}

Sync is the synchronizer of blockchain. It includes requestHandler, heightSync, blockhashSync, blockSync.

func New

func New(cBase *chainbase.ChainBase, p p2p.Service) *Sync

New will return a new synchronizer of blockchain.

func (*Sync) BroadcastBlock

func (s *Sync) BroadcastBlock(block *block.Block)

BroadcastBlock will broadcast new block to neighbor nodes.

func (*Sync) BroadcastBlockInfo

func (s *Sync) BroadcastBlockInfo(block *block.Block)

BroadcastBlockInfo will broadcast new block information to neighbor nodes.

func (*Sync) Close

func (s *Sync) Close()

Close will close the synchronizer of blockchain.

func (*Sync) IsCatchingUp

func (s *Sync) IsCatchingUp() bool

IsCatchingUp will return whether it is catching up with other nodes.

func (*Sync) ValidBlock

func (s *Sync) ValidBlock() <-chan *block.Block

ValidBlock will return the valid blocks from other nodes. Including passive request and active broadcast.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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