Documentation ¶
Index ¶
- func DisableLog()
- func UseLogger(logger elalog.Logger)
- type Config
- type SyncManager
- func (sm *SyncManager) DonePeer(peer *peer.Peer)
- func (sm *SyncManager) IsCurrent() bool
- func (sm *SyncManager) NewPeer(peer *peer.Peer)
- func (sm *SyncManager) Pause() chan<- struct{}
- func (sm *SyncManager) QueueBlock(block *util.Block, peer *peer.Peer, done chan struct{})
- func (sm *SyncManager) QueueInv(inv *msg.Inv, peer *peer.Peer)
- func (sm *SyncManager) QueueTx(tx util.Transaction, peer *peer.Peer, done chan struct{})
- func (sm *SyncManager) Start()
- func (sm *SyncManager) Stop() error
- func (sm *SyncManager) SyncPeerID() uint64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DisableLog ¶
func DisableLog()
DisableLog disables all library log output. Logging output is disabled by default until either UseLogger or SetLogWriter are called.
Types ¶
type Config ¶
type Config struct { Chain *blockchain.BlockChain MaxPeers int CandidateFlags []uint64 GetTxFilter func() *msg.TxFilterLoad TransactionAnnounce func(tx util.Transaction) }
Config is a configuration struct used to initialize a new SyncManager.
func NewDefaultConfig ¶
func NewDefaultConfig(chain *blockchain.BlockChain, candidateFlags []uint64, getTxFilter func() *msg.TxFilterLoad) *Config
type SyncManager ¶
type SyncManager struct {
// contains filtered or unexported fields
}
SyncManager is used to communicate block related messages with peers. The SyncManager is started as by executing Start() in a goroutine. Once started, it selects peers to sync from and starts the initial block download. Once the chain is in sync, the SyncManager handles incoming block and header notifications and relays announcements of new blocks to peers.
func New ¶
func New(cfg *Config) (*SyncManager, error)
New constructs a new SyncManager. Use Start to begin processing asynchronous block, tx, and inv updates.
func (*SyncManager) DonePeer ¶
func (sm *SyncManager) DonePeer(peer *peer.Peer)
DonePeer informs the blockmanager that a peer has disconnected.
func (*SyncManager) IsCurrent ¶
func (sm *SyncManager) IsCurrent() bool
IsCurrent returns whether or not the sync manager believes it is synced with the connected peers.
func (*SyncManager) NewPeer ¶
func (sm *SyncManager) NewPeer(peer *peer.Peer)
NewPeer informs the sync manager of a newly active peer.
func (*SyncManager) Pause ¶
func (sm *SyncManager) Pause() chan<- struct{}
Pause pauses the sync manager until the returned channel is closed.
Note that while paused, all peer and block processing is halted. The message sender should avoid pausing the sync manager for long durations.
func (*SyncManager) QueueBlock ¶
func (sm *SyncManager) QueueBlock(block *util.Block, peer *peer.Peer, done chan struct{})
QueueBlock adds the passed block message and peer to the block handling queue. Responds to the done channel argument after the block message is processed.
func (*SyncManager) QueueInv ¶
func (sm *SyncManager) QueueInv(inv *msg.Inv, peer *peer.Peer)
QueueInv adds the passed inv message and peer to the block handling queue.
func (*SyncManager) QueueTx ¶
func (sm *SyncManager) QueueTx(tx util.Transaction, peer *peer.Peer, done chan struct{})
QueueTx adds the passed transaction message and peer to the block handling queue. Responds to the done channel argument after the tx message is processed.
func (*SyncManager) Start ¶
func (sm *SyncManager) Start()
Start begins the core block handler which processes block and inv messages.
func (*SyncManager) Stop ¶
func (sm *SyncManager) Stop() error
Stop gracefully shuts down the sync manager by stopping all asynchronous handlers and waiting for them to finish.
func (*SyncManager) SyncPeerID ¶
func (sm *SyncManager) SyncPeerID() uint64
SyncPeerID returns the ID of the current sync peer, or 0 if there is none.