forked from TrueCloudLab/neoneo-go
network: check inv against currently processed transactions
Sometimes we already have it, but it's not yet processed, so we can save on getdata request. It only affects very high-speed networks like 4-1 scenario and it doesn't affect it a lot, but still we can do it.
This commit is contained in:
parent
bf4636f70a
commit
e26055190e
1 changed files with 7 additions and 2 deletions
|
@ -111,7 +111,7 @@ type (
|
|||
txCallback func(*transaction.Transaction)
|
||||
txCbEnabled atomic.Bool
|
||||
|
||||
txInLock sync.Mutex
|
||||
txInLock sync.RWMutex
|
||||
txin chan *transaction.Transaction
|
||||
txInMap map[util.Uint256]struct{}
|
||||
|
||||
|
@ -760,7 +760,12 @@ func (s *Server) handlePong(p Peer, pong *payload.Ping) error {
|
|||
func (s *Server) handleInvCmd(p Peer, inv *payload.Inventory) error {
|
||||
var reqHashes = inv.Hashes[:0]
|
||||
var typExists = map[payload.InventoryType]func(util.Uint256) bool{
|
||||
payload.TXType: s.mempool.ContainsKey,
|
||||
payload.TXType: func(h util.Uint256) bool {
|
||||
s.txInLock.RLock()
|
||||
_, ok := s.txInMap[h]
|
||||
s.txInLock.RUnlock()
|
||||
return ok || s.mempool.ContainsKey(h)
|
||||
},
|
||||
payload.BlockType: s.chain.HasBlock,
|
||||
payload.ExtensibleType: func(h util.Uint256) bool {
|
||||
cp := s.extensiblePool.Get(h)
|
||||
|
|
Loading…
Reference in a new issue