diff --git a/pkg/consensus/consensus.go b/pkg/consensus/consensus.go index a2833ac64..a4229e536 100644 --- a/pkg/consensus/consensus.go +++ b/pkg/consensus/consensus.go @@ -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 diff --git a/pkg/services/notary/notary.go b/pkg/services/notary/notary.go index dc3d93a85..e3b6bea96 100644 --- a/pkg/services/notary/notary.go +++ b/pkg/services/notary/notary.go @@ -64,7 +64,12 @@ type ( mp *mempool.Pool // requests channel - reqCh chan mempoolevent.Event + 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{} diff --git a/pkg/services/stateroot/service.go b/pkg/services/stateroot/service.go index 4dd21e42b..32de50124 100644 --- a/pkg/services/stateroot/service.go +++ b/pkg/services/stateroot/service.go @@ -63,9 +63,12 @@ type ( timePerBlock time.Duration maxRetries int relayExtensible RelayCallback - blockCh chan *block.Block - stopCh chan struct{} - done chan struct{} + // 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,