From 8f2c5d6ef36cc5ce78cabcd146355ffeb639f57c Mon Sep 17 00:00:00 2001 From: Lazy Nina Date: Wed, 30 Oct 2024 01:12:52 -0400 Subject: [PATCH] free known inventory from heap by setting to nil --- lib/peer.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/peer.go b/lib/peer.go index a3d6805b5..32390065a 100644 --- a/lib/peer.go +++ b/lib/peer.go @@ -111,7 +111,7 @@ type Peer struct { // Inventory stuff. // The inventory that we know the peer already has. - knownInventory lru.Set[InvVect] + knownInventory *lru.Set[InvVect] // Whether the peer is ready to receive INV messages. For a peer that // still needs a mempool download, this is false. @@ -652,7 +652,7 @@ func NewPeer(_id uint64, _conn net.Conn, _isOutbound bool, _netAddr *wire.NetAdd outputQueueChan: make(chan DeSoMessage), peerDisconnectedChan: peerDisconnectedChan, quit: make(chan interface{}), - knownInventory: *lru.NewSet[InvVect](maxKnownInventory), + knownInventory: lru.NewSet[InvVect](maxKnownInventory), blocksToSend: make(map[BlockHash]bool), stallTimeoutSeconds: _stallTimeoutSeconds, minTxFeeRateNanosPerKB: _minFeeRateNanosPerKB, @@ -1362,6 +1362,8 @@ func (pp *Peer) Disconnect(reason string) { // Free the cache of known inventory. pp.knownInventory.Clear() + pp.knownInventory = nil + // Close the connection object. pp.Conn.Close()