From bb8333a73927145535cb58143913fd1f97fb6e07 Mon Sep 17 00:00:00 2001 From: David Hill Date: Sat, 27 Jun 2015 11:04:10 -0400 Subject: [PATCH] Use NewMsgInvSizeHint when we know the size. When trickling inv's to peers, allocate for the number of inv's in the queue instead of the default 1000. This should save on memory. --- peer.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/peer.go b/peer.go index 16047daa..eed6c552 100644 --- a/peer.go +++ b/peer.go @@ -1670,7 +1670,7 @@ out: // Create and send as many inv messages as needed to // drain the inventory send queue. - invMsg := wire.NewMsgInv() + invMsg := wire.NewMsgInvSizeHint(uint(invSendQueue.Len())) for e := invSendQueue.Front(); e != nil; e = invSendQueue.Front() { iv := invSendQueue.Remove(e).(*wire.InvVect) @@ -1685,7 +1685,7 @@ out: waiting = queuePacket( outMsg{msg: invMsg}, pendingMsgs, waiting) - invMsg = wire.NewMsgInv() + invMsg = wire.NewMsgInvSizeHint(uint(invSendQueue.Len())) } // Add the inventory that is being relayed to