Skip to content

Commit

Permalink
chain: Return deep copies of v2 pool transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
lukechampine authored and ChrisSchinnerl committed Dec 11, 2024
1 parent 6881993 commit 571d72e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions chain/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit 571d72e

Please sign in to comment.