Skip to content

Commit

Permalink
reverse TX_COUNT bits
Browse files Browse the repository at this point in the history
  • Loading branch information
steinerkelvin committed Oct 25, 2022
1 parent b4ee4bf commit c1346b9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion breaking_changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Serialization

- [ ] inversion of TX_COUNT bit order
- [X] reversion of TX_COUNT bit order
- [X] `fun` initial state is optional

## Chain state
Expand Down
7 changes: 4 additions & 3 deletions src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ impl Body {
}
tx_count += 1;
}
body_vec[0] = tx_count as u8;
body_vec[0] = (tx_count as u8).reverse_bits();
Body { data: body_vec }
}

Expand Down Expand Up @@ -186,7 +186,7 @@ impl Body {
data.extend_from_slice(&transaction.data);
}
// Finally stores resulting transaction count on the first byte
data[0] = tx_count as u8;
data[0] = (tx_count as u8).reverse_bits();
Ok(Body { data })
}
}
Expand Down Expand Up @@ -587,7 +587,7 @@ pub fn add_transaction_to_body_vec(
pub fn extract_transactions(body: &Body) -> Vec<Transaction> {
let mut transactions = Vec::new();
let mut index = 1;
let tx_count = body.data[0];
let tx_count = body.data[0].reverse_bits();
for _ in 0..tx_count {
if index >= body.data.len() {
break;
Expand Down Expand Up @@ -877,6 +877,7 @@ impl<C: ProtoComm> Node<C> {
self.target.insert(bhash, self.target[&phash]);
}
// Removes this block's transactions from mempool
// TODO: should actually only remove txs on tip update
for tx in extract_transactions(&block.body) {
self.pool.remove(&tx);
}
Expand Down

0 comments on commit c1346b9

Please sign in to comment.