From 571d72e958da9a460f2927a6ef7e50a127a239aa Mon Sep 17 00:00:00 2001 From: lukechampine Date: Wed, 11 Dec 2024 09:10:45 -0500 Subject: [PATCH] chain: Return deep copies of v2 pool transactions --- chain/manager.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/chain/manager.go b/chain/manager.go index 53e47da..dabdae3 100644 --- a/chain/manager.go +++ b/chain/manager.go @@ -826,7 +826,7 @@ func (m *Manager) V2PoolTransaction(id types.TransactionID) (types.V2Transaction if !ok { return types.V2Transaction{}, false } - return m.txpool.v2txns[i], ok + return m.txpool.v2txns[i].DeepCopy(), ok } // V2PoolTransactions returns the v2 transactions currently in the txpool. Any @@ -835,7 +835,11 @@ func (m *Manager) V2PoolTransactions() []types.V2Transaction { m.mu.Lock() defer m.mu.Unlock() m.revalidatePool() - return append([]types.V2Transaction(nil), m.txpool.v2txns...) + v2txns := make([]types.V2Transaction, len(m.txpool.v2txns)) + for i, txn := range m.txpool.v2txns { + v2txns[i] = txn.DeepCopy() + } + return v2txns } // TransactionsForPartialBlock returns the transactions in the txpool with the