From ab053d6002fdbc361507b53c72634d581d0bdaa1 Mon Sep 17 00:00:00 2001 From: Piotr Macek <4007944+piotrm50@users.noreply.github.com> Date: Thu, 18 Apr 2024 16:39:00 +0200 Subject: [PATCH] Call unhook for all evicted elements in SpendDAG. --- .../engine/mempool/spenddag/spenddagv1/spenddag.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/protocol/engine/mempool/spenddag/spenddagv1/spenddag.go b/pkg/protocol/engine/mempool/spenddag/spenddagv1/spenddag.go index ee42e7989..47e93973b 100644 --- a/pkg/protocol/engine/mempool/spenddag/spenddagv1/spenddag.go +++ b/pkg/protocol/engine/mempool/spenddag/spenddagv1/spenddag.go @@ -412,13 +412,12 @@ func (c *SpendDAG[SpenderID, ResourceID, VoteRank]) evictSpender(spenderID Spend // remove the spenders from the spenddag dictionary for _, evictedSpenderID := range evictedSpenderIDs { c.spendersByID.Delete(evictedSpenderID) - } - - // unhook the spend events and remove the unhook method from the storage - unhookFunc, unhookExists := c.spendUnhooks.Get(spenderID) - if unhookExists { - unhookFunc() - c.spendUnhooks.Delete(spenderID) + // unhook the spend events and remove the unhook method from the storage + unhookFunc, unhookExists := c.spendUnhooks.Get(spenderID) + if unhookExists { + unhookFunc() + c.spendUnhooks.Delete(spenderID) + } } return evictedSpenderIDs