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 udpatil committed Apr 16, 2024
1 parent ae3db8f commit b455dda
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 @@ -149,7 +149,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 @@ -161,7 +160,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 b455dda

Please sign in to comment.