Skip to content

Commit

Permalink
free known inventory from heap by setting to nil
Browse files Browse the repository at this point in the history
  • Loading branch information
lazynina committed Oct 30, 2024
1 parent d690018 commit 8f2c5d6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()

Expand Down

0 comments on commit 8f2c5d6

Please sign in to comment.