Skip to content

Commit

Permalink
Fix transaction counting bug in simple mempool
Browse files Browse the repository at this point in the history
Signed-off-by: Matej Pavlovic <matopavlovic@gmail.com>
  • Loading branch information
matejpavlovic committed Aug 10, 2022
1 parent d6f5672 commit 1d89188
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,22 @@ func IncludeBatchCreation(
var txs []*requestpb.Request
batchSize := 0

var i int
var txID t.TxID

for i, txID = range state.NewTxIDs {
txCount := 0
for _, txID := range state.NewTxIDs {
tx := state.TxByID[txID]

// TODO: add other limitations (if any) here.
if i == params.MaxTransactionsInBatch {
if txCount == params.MaxTransactionsInBatch {
break
}

txIDs = append(txIDs, txID)
txs = append(txs, tx)
batchSize += len(tx.Data)
txCount++
}

state.NewTxIDs = state.NewTxIDs[i:]
state.NewTxIDs = state.NewTxIDs[txCount:]

// Note that a batch may be empty.
mpdsl.NewBatch(m, t.ModuleID(origin.Module), txIDs, txs, origin)
Expand Down

0 comments on commit 1d89188

Please sign in to comment.