Skip to content

Commit 3780647

Browse files
authored
TxPool: Remove the expiry map which is no longer used (#6513)
1 parent 5031060 commit 3780647

File tree

2 files changed

+3
-34
lines changed

2 files changed

+3
-34
lines changed

data/pools/transactionPool.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ type TransactionPool struct {
6161

6262
mu deadlock.Mutex
6363
cond sync.Cond
64-
expiredTxCount map[basics.Round]int
6564
pendingBlockEvaluator BlockEvaluator
6665
evalTracer logic.EvalTracer
6766
numPendingWholeBlocks basics.Round
@@ -131,7 +130,6 @@ func MakeTransactionPool(ledger *ledger.Ledger, cfg config.Local, log logging.Lo
131130
pool := TransactionPool{
132131
pendingTxids: make(map[transactions.Txid]transactions.SignedTxn),
133132
rememberedTxids: make(map[transactions.Txid]transactions.SignedTxn),
134-
expiredTxCount: make(map[basics.Round]int),
135133
ledger: ledger,
136134
statusCache: makeStatusCache(cfg.TxPoolSize),
137135
logProcessBlockStats: cfg.EnableProcessBlockStats,
@@ -195,7 +193,6 @@ func (pool *TransactionPool) Reset() {
195193
pool.pendingTxGroups = nil
196194
pool.rememberedTxids = make(map[transactions.Txid]transactions.SignedTxn)
197195
pool.rememberedTxGroups = nil
198-
pool.expiredTxCount = make(map[basics.Round]int)
199196
pool.numPendingWholeBlocks = 0
200197
pool.pendingBlockEvaluator = nil
201198
pool.statusCache.reset()
@@ -209,15 +206,6 @@ func (pool *TransactionPool) getVotingAccountsForRound(rnd basics.Round) []basic
209206
return pool.vac.VotingAccountsForRound(rnd)
210207
}
211208

212-
// NumExpired returns the number of transactions that expired at the
213-
// end of a round (only meaningful if cleanup has been called for that
214-
// round).
215-
func (pool *TransactionPool) NumExpired(round basics.Round) int {
216-
pool.mu.Lock()
217-
defer pool.mu.Unlock()
218-
return pool.expiredTxCount[round]
219-
}
220-
221209
// PendingTxIDs return the IDs of all pending transactions.
222210
func (pool *TransactionPool) PendingTxIDs() []transactions.Txid {
223211
pool.pendingMu.RLock()
@@ -586,10 +574,6 @@ func (pool *TransactionPool) OnNewBlock(block bookkeeping.Block, delta ledgercor
586574
stats.KnownCommittedCount = knownCommitted
587575
stats.UnknownCommittedCount = unknownCommitted
588576

589-
proto := config.Consensus[block.CurrentProtocol]
590-
pool.expiredTxCount[block.Round()] = int(stats.ExpiredCount)
591-
delete(pool.expiredTxCount, block.Round()-expiredHistory*basics.Round(proto.MaxTxnLife))
592-
593577
if pool.logProcessBlockStats {
594578
var details struct {
595579
Round uint64

data/pools/transactionPool_test.go

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,8 @@ func TestCleanUp(t *testing.T) {
637637
}
638638
}
639639

640+
require.Len(t, transactionPool.PendingTxGroups(), issuedTransactions)
641+
640642
for mockLedger.Latest() < 6 {
641643
eval := newBlockEvaluator(t, mockLedger)
642644
ufblk, err := eval.GenerateBlock(nil)
@@ -649,24 +651,7 @@ func TestCleanUp(t *testing.T) {
649651
transactionPool.OnNewBlock(blk.Block(), ledgercore.StateDelta{})
650652
}
651653

652-
pending := transactionPool.PendingTxGroups()
653-
require.Zero(t, len(pending))
654-
require.Zero(t, transactionPool.NumExpired(4))
655-
require.Equal(t, issuedTransactions, transactionPool.NumExpired(5))
656-
657-
for mockLedger.Latest() < 6+basics.Round(expiredHistory*proto.MaxTxnLife) {
658-
eval := newBlockEvaluator(t, mockLedger)
659-
ufblk, err := eval.GenerateBlock(nil)
660-
require.NoError(t, err)
661-
662-
blk := ledgercore.MakeValidatedBlock(ufblk.UnfinishedBlock(), ufblk.UnfinishedDeltas())
663-
err = mockLedger.AddValidatedBlock(blk, agreement.Certificate{})
664-
require.NoError(t, err)
665-
666-
transactionPool.OnNewBlock(blk.Block(), ledgercore.StateDelta{})
667-
require.Zero(t, transactionPool.NumExpired(blk.Block().Round()))
668-
}
669-
require.Len(t, transactionPool.expiredTxCount, int(expiredHistory*proto.MaxTxnLife))
654+
require.Empty(t, transactionPool.PendingTxGroups())
670655
}
671656

672657
func TestFixOverflowOnNewBlock(t *testing.T) {

0 commit comments

Comments
 (0)