Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChainSynchronizer ¶
type ChainSynchronizer struct { *Counter // contains filtered or unexported fields }
ChainSynchronizer is the component responsible for keeping the node in sync with the rest of the network. It sits between the peer and the chain, as a sort of gateway for incoming blocks. It keeps track of the local chain tip and compares it with each incoming block to make sure we stay in sync with our peers.
func NewChainSynchronizer ¶
func NewChainSynchronizer(publisher wire.EventPublisher, rpcBus *wire.RPCBus, responseChan chan<- *bytes.Buffer, counter *Counter) *ChainSynchronizer
NewChainSynchronizer returns an initialized ChainSynchronizer. The passed responseChan should point to an individual peer's outgoing message queue, and the passed Counter should be shared between all instances of the ChainSynchronizer.
func (*ChainSynchronizer) Synchronize ¶
func (s *ChainSynchronizer) Synchronize(blkBuf *bytes.Buffer, peerInfo string) error
Synchronize our blockchain with our peers.
type Counter ¶
type Counter struct {
// contains filtered or unexported fields
}
Counter is a simple guarded counter, which can be used to figure out if we are currently syncing with another peer. It is used to orchestrate requests for blocks.
func NewCounter ¶
func NewCounter(subscriber wire.EventSubscriber) *Counter
NewCounter returns an initialized counter. It will decrement each time we accept a new block.