Documentation ¶
Index ¶
- Constants
- type Dispatcher
- func (d *Dispatcher) Concurrent() int64
- func (d *Dispatcher) IncomingBlocks(ctx context.Context) (<-chan *types2.BlockHeader, error)
- func (d *Dispatcher) RegisterCallback(cb func(*types.Target, error))
- func (d *Dispatcher) SendGossipBlock(ci *types2.ChainInfo) error
- func (d *Dispatcher) SendHello(ci *types2.ChainInfo) error
- func (d *Dispatcher) SendOwnBlock(ci *types2.ChainInfo) error
- func (d *Dispatcher) SetConcurrent(number int64)
- func (d *Dispatcher) Start(syncingCtx context.Context)
- func (d *Dispatcher) SyncTracker() *types.TargetTracker
Constants ¶
const DefaultInQueueSize = 5
DefaultInQueueSize is the bucketSize of the channel used for receiving targets from producers.
const DefaultWorkQueueSize = 15
DefaultWorkQueueSize is the bucketSize of the work queue
const LocalIncoming = "incoming"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher struct {
// contains filtered or unexported fields
}
Dispatcher receives, sorts and dispatches targets to the catchupSyncer to control chain syncing.
New targets arrive over the incoming channel. The dispatcher then puts them into the workTracker which sorts them by their claimed chain height. The dispatcher pops the highest priority target from the queue and then attempts to sync the target using its internal catchupSyncer.
The dispatcher has a simple control channel. It reads this for external controls. Currently there is only one kind of control message. It registers a callback that the dispatcher will call after every non-erroring sync.
func NewDispatcher ¶
func NewDispatcher(catchupSyncer dispatchSyncer, chainStore *chain.Store) *Dispatcher
NewDispatcher creates a new syncing dispatcher with default queue sizes.
func NewDispatcherWithSizes ¶
func NewDispatcherWithSizes(syncer dispatchSyncer, chainStore *chain.Store, workQueueSize, inQueueSize int) *Dispatcher
NewDispatcherWithSizes creates a new syncing dispatcher.
func (*Dispatcher) Concurrent ¶ added in v0.9.4
func (d *Dispatcher) Concurrent() int64
Concurrent get current max syncing goroutine
func (*Dispatcher) IncomingBlocks ¶ added in v1.14.0
func (d *Dispatcher) IncomingBlocks(ctx context.Context) (<-chan *types2.BlockHeader, error)
func (*Dispatcher) RegisterCallback ¶
func (d *Dispatcher) RegisterCallback(cb func(*types.Target, error))
RegisterCallback registers a callback on the dispatcher that will fire after every successful target sync.
func (*Dispatcher) SendGossipBlock ¶
func (d *Dispatcher) SendGossipBlock(ci *types2.ChainInfo) error
SendGossipBlock handles chain info from new blocks sent on pubsub
func (*Dispatcher) SendHello ¶
func (d *Dispatcher) SendHello(ci *types2.ChainInfo) error
SendHello handles chain information from bootstrap peers.
func (*Dispatcher) SendOwnBlock ¶
func (d *Dispatcher) SendOwnBlock(ci *types2.ChainInfo) error
SendOwnBlock handles chain info from a node's own mining system
func (*Dispatcher) SetConcurrent ¶ added in v0.9.1
func (d *Dispatcher) SetConcurrent(number int64)
SetConcurrent set the max goroutine to syncing target
func (*Dispatcher) Start ¶
func (d *Dispatcher) Start(syncingCtx context.Context)
Start launches the business logic for the syncing subsystem.
func (*Dispatcher) SyncTracker ¶
func (d *Dispatcher) SyncTracker() *types.TargetTracker
SyncTracker returnss the target tracker of syncing