mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 13:41:37 +00:00
Merge pull request #2746 from nspcc-dev/optimize-tx-callbacks
network: only call tx callback if we're waiting for transactions
This commit is contained in:
commit
73079745ab
1 changed files with 4 additions and 1 deletions
|
@ -108,6 +108,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{}
|
||||
|
@ -1044,7 +1045,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 {
|
||||
|
@ -1344,6 +1345,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