services: use buffered channels for block subscription
Add a tiny buffer where possible to avoid Blockchain's blocking on new block addition.
This commit is contained in:
parent
97c7023020
commit
ea46943815
3 changed files with 15 additions and 6 deletions
|
@ -89,7 +89,8 @@ type service struct {
|
|||
messages chan Payload
|
||||
transactions chan *transaction.Transaction
|
||||
// blockEvents is used to pass a new block event to the consensus
|
||||
// process.
|
||||
// process. It has a tiny buffer in order to avoid Blockchain blocking
|
||||
// on block addition under the high load.
|
||||
blockEvents chan *coreb.Block
|
||||
lastProposal []util.Uint256
|
||||
wallet *wallet.Wallet
|
||||
|
|
|
@ -65,6 +65,11 @@ type (
|
|||
mp *mempool.Pool
|
||||
// requests channel
|
||||
reqCh chan mempoolevent.Event
|
||||
// blocksCh is a channel used to receive block notifications from the
|
||||
// Blockchain. It is not buffered intentionally, as it's important to keep
|
||||
// the notary request pool in sync with the current blockchain heigh, thus,
|
||||
// it's not recommended to use a large size of notary requests pool as it may
|
||||
// slow down the block processing.
|
||||
blocksCh chan *block.Block
|
||||
stopCh chan struct{}
|
||||
done chan struct{}
|
||||
|
|
|
@ -63,6 +63,9 @@ type (
|
|||
timePerBlock time.Duration
|
||||
maxRetries int
|
||||
relayExtensible RelayCallback
|
||||
// blockCh is a channel used to receive block notifications from the
|
||||
// Blockchain. It has a tiny buffer in order to avoid Blockchain blocking
|
||||
// on block addition under the high load.
|
||||
blockCh chan *block.Block
|
||||
stopCh chan struct{}
|
||||
done chan struct{}
|
||||
|
@ -84,7 +87,7 @@ func New(cfg config.StateRoot, sm *stateroot.Module, log *zap.Logger, bc Ledger,
|
|||
chain: bc,
|
||||
log: log,
|
||||
incompleteRoots: make(map[uint32]*incompleteRoot),
|
||||
blockCh: make(chan *block.Block),
|
||||
blockCh: make(chan *block.Block, 1),
|
||||
stopCh: make(chan struct{}),
|
||||
done: make(chan struct{}),
|
||||
timePerBlock: bcConf.TimePerBlock,
|
||||
|
|
Loading…
Reference in a new issue