Documentation ¶
Index ¶
Constants ¶
View Source
const ( BlockHashLeastNeighborNumber = 2 BlockHashExpiredSeconds = 60 BlockHashMaxRequestRange = 100 )
Constant of blockhash sync
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockMessage ¶
type BlockMessage struct { Blk *block.Block P2PType p2p.MessageType From string }
BlockMessage define a block from a neighbor node.
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(p p2p.Service, bCache blockcache.BlockCache, bChain block.Chain) *Sync
New will return a new synchronizer of blockchain.
func (*Sync) IncomingBlock ¶
func (s *Sync) IncomingBlock() <-chan *BlockMessage
IncomingBlock will return the blocks from other nodes. Including passive request and active broadcast.
func (*Sync) NeighborHeight ¶
NeighborHeight will return the median of the head height of the neighbor nodes. If the number of neighbor nodes is less than leastNeighborNumber, return -1.
Source Files ¶
Click to show internal directories.
Click to hide internal directories.