Unverified Commit cf2e79e7 authored by Roman Zeyde's avatar Roman Zeyde
Browse files

Use u32::max_value() for mempool transactions' height at mempool.rs

So mempool transactions will appear at the end of the scripthash status:
https://electrumx.readthedocs.io/en/latest/protocol-basics.html#status
parent 3f2e3ed1
......@@ -15,6 +15,7 @@ use util::Bytes;
use errors::*;
const VSIZE_BIN_WIDTH: u32 = 100_000; // in vbytes
pub const MEMPOOL_HEIGHT: u32 = u32::max_value(); // special "marker" for mempool transactions
struct MempoolStore {
map: BTreeMap<Bytes, Vec<Bytes>>,
......@@ -29,7 +30,7 @@ impl MempoolStore {
fn add(&mut self, tx: &Transaction) {
let mut rows = vec![];
index_transaction(tx, 0, &Sha256dHash::default(), &mut rows);
index_transaction(tx, MEMPOOL_HEIGHT, &Sha256dHash::default(), &mut rows);
for row in rows {
let (key, value) = row.into_pair();
self.map.entry(key).or_insert(vec![]).push(value);
......@@ -38,7 +39,7 @@ impl MempoolStore {
fn remove(&mut self, tx: &Transaction) {
let mut rows = vec![];
index_transaction(tx, 0, &Sha256dHash::default(), &mut rows);
index_transaction(tx, MEMPOOL_HEIGHT, &Sha256dHash::default(), &mut rows);
for row in rows {
let (key, value) = row.into_pair();
let no_values_left = {
......@@ -49,7 +50,7 @@ impl MempoolStore {
let last_value = values
.pop()
.expect(&format!("no values found for key {}", hex::encode(&key)));
// TxInRow and TxOutRow have an empty value, TxRow has height=0 as value.
// TxInRow and TxOutRow have an empty value, TxRow has MEMPOOL_HEIGHT as value.
assert_eq!(
value,
last_value,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment