mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-28 11:36:17 +00:00
network: only call tx callback if we're waiting for transactions
Until the consensus process starts for a new block and until it really needs some transactions we can spare some cycles by not delivering transactions to it. In tests this doesn't affect TPS, but makes block delays a bit more stable. Related to #2744, I think it also may cause timeouts during transaction processing (waiting on the consensus process channel while it does something dBFT-related).
This commit is contained in:
parent
c3001bc5bd
commit
4dd3fd4ac0
1 changed files with 4 additions and 1 deletions
|
@ -107,6 +107,7 @@ type (
|
|||
services map[string]Service
|
||||
extensHandlers map[string]func(*payload.Extensible) error
|
||||
txCallback func(*transaction.Transaction)
|
||||
txCbHeight atomic.Uint32
|
||||
|
||||
txInLock sync.Mutex
|
||||
txInMap map[util.Uint256]struct{}
|
||||
|
@ -1021,7 +1022,7 @@ func (s *Server) handleTxCmd(tx *transaction.Transaction) error {
|
|||
s.serviceLock.RLock()
|
||||
txCallback := s.txCallback
|
||||
s.serviceLock.RUnlock()
|
||||
if txCallback != nil {
|
||||
if txCallback != nil && s.chain.BlockHeight() <= s.txCbHeight.Load() {
|
||||
txCallback(tx)
|
||||
}
|
||||
if s.verifyAndPoolTX(tx) == nil {
|
||||
|
@ -1321,6 +1322,8 @@ func (s *Server) RequestTx(hashes ...util.Uint256) {
|
|||
return
|
||||
}
|
||||
|
||||
s.txCbHeight.Store(s.chain.BlockHeight())
|
||||
|
||||
for i := 0; i <= len(hashes)/payload.MaxHashesCount; i++ {
|
||||
start := i * payload.MaxHashesCount
|
||||
stop := (i + 1) * payload.MaxHashesCount
|
||||
|
|
Loading…
Reference in a new issue