Skip to content

Commit

Permalink
applayer/template: fix tx_id handling
Browse files Browse the repository at this point in the history
When we create a new transaction, we increment the State's tx_id and
pass that to the tx.tx_id. so, when calling get_tx and free_tx, we
shouldn't need to adjust the tx_id again.

Related to
Bug OISF#7000
  • Loading branch information
jufajardini committed Apr 30, 2024
1 parent 872da3c commit b9863d3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions rust/src/applayertemplate/template.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ impl TemplateState {
let mut index = 0;
for i in 0..len {
let tx = &self.transactions[i];
if tx.tx_id == tx_id + 1 {
if tx.tx_id == tx_id {
found = true;
index = i;
break;
Expand All @@ -108,7 +108,7 @@ impl TemplateState {
}

pub fn get_tx(&mut self, tx_id: u64) -> Option<&TemplateTransaction> {
self.transactions.iter().find(|tx| tx.tx_id == tx_id + 1)
self.transactions.iter().find(|tx| tx.tx_id == tx_id)
}

fn new_tx(&mut self) -> TemplateTransaction {
Expand Down

0 comments on commit b9863d3

Please sign in to comment.