From 8177f9854d6c2e61f9658dad79be920955e84aa5 Mon Sep 17 00:00:00 2001 From: codchen Date: Wed, 20 Dec 2023 22:25:47 +0800 Subject: [PATCH] fix pending pop (#173) --- internal/mempool/mempool.go | 4 +++- internal/mempool/tx.go | 2 +- internal/rpc/core/mempool.go | 2 -- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/mempool/mempool.go b/internal/mempool/mempool.go index d38fe9e5c..41f5b587c 100644 --- a/internal/mempool/mempool.go +++ b/internal/mempool/mempool.go @@ -177,7 +177,9 @@ func (txmp *TxMempool) Unlock() { // Size returns the number of valid transactions in the mempool. It is // thread-safe. func (txmp *TxMempool) Size() int { - return txmp.txStore.Size() + txmp.pendingTxs.Size() + txSize := txmp.txStore.Size() + pendingSize := txmp.pendingTxs.Size() + return txSize + pendingSize } // SizeBytes return the total sum in bytes of all the valid transactions in the diff --git a/internal/mempool/tx.go b/internal/mempool/tx.go index e5fd7b16f..c74872054 100644 --- a/internal/mempool/tx.go +++ b/internal/mempool/tx.go @@ -343,7 +343,7 @@ func (p *PendingTxs) popTxsAtIndices(indices []int) { newTxs = append(newTxs, p.txs[start:idx]...) start = idx } - newTxs = append(newTxs, p.txs[indices[len(indices)-1]:]...) + newTxs = append(newTxs, p.txs[start+1:]...) p.txs = newTxs } diff --git a/internal/rpc/core/mempool.go b/internal/rpc/core/mempool.go index b5a1592d9..1e8628641 100644 --- a/internal/rpc/core/mempool.go +++ b/internal/rpc/core/mempool.go @@ -148,7 +148,6 @@ func (env *Environment) BroadcastTxCommit(ctx context.Context, req *coretypes.Re // More: https://docs.tendermint.com/master/rpc/#/Info/unconfirmed_txs func (env *Environment) UnconfirmedTxs(ctx context.Context, req *coretypes.RequestUnconfirmedTxs) (*coretypes.ResultUnconfirmedTxs, error) { totalCount := env.Mempool.Size() - fmt.Printf("EVMTEST mempool size: %d\n", totalCount) perPage := env.validatePerPage(req.PerPage.IntPtr()) page, err := validatePage(req.Page.IntPtr(), perPage, totalCount) if err != nil { @@ -160,7 +159,6 @@ func (env *Environment) UnconfirmedTxs(ctx context.Context, req *coretypes.Reque txs := env.Mempool.ReapMaxTxs(skipCount + tmmath.MinInt(perPage, totalCount-skipCount)) result := txs[skipCount:] - fmt.Printf("EVMTEST unconfirmed tx result count: %d, skipping %d\n", len(result), skipCount) return &coretypes.ResultUnconfirmedTxs{ Count: len(result), Total: totalCount,