Skip to content

Commit

Permalink
fix pending pop (#173)
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen authored and stevenlanders committed Jan 30, 2024
1 parent a42a7ca commit 8177f98
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 3 additions & 1 deletion internal/mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion internal/mempool/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 0 additions & 2 deletions internal/rpc/core/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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,
Expand Down

0 comments on commit 8177f98

Please sign in to comment.