dcrd: trickle mempool response to peer.

QueueInventory also has the benefit of skipping known inventory.
This commit is contained in:
David Hill 2020-09-18 10:54:29 -04:00 committed by Dave Collins
parent e46e0d2165
commit 6fc441fb42

View File

@ -733,19 +733,11 @@ func (sp *serverPeer) OnMemPool(p *peer.Peer, msg *wire.MsgMemPool) {
// without double checking it here.
txMemPool := sp.server.txMemPool
txDescs := txMemPool.TxDescs()
invMsg := wire.NewMsgInvSizeHint(uint(len(txDescs)))
for i, txDesc := range txDescs {
iv := wire.NewInvVect(wire.InvTypeTx, txDesc.Tx.Hash())
invMsg.AddInvVect(iv)
if i+1 >= wire.MaxInvPerMsg {
break
}
}
// Send the inventory message if there is anything to send.
if len(invMsg.InvList) > 0 {
p.QueueMessage(invMsg, nil)
for _, txDesc := range txDescs {
iv := wire.NewInvVect(wire.InvTypeTx, txDesc.Tx.Hash())
sp.QueueInventory(iv)
}
}