get the position for incoming mempool txids
This commit is contained in:
@@ -953,11 +953,11 @@ impl LightClient {
|
|||||||
wtxs.iter().flat_map(|wtx| {
|
wtxs.iter().flat_map(|wtx| {
|
||||||
wtx.incoming_metadata.iter()
|
wtx.incoming_metadata.iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
.map(move |(_i, om)|
|
.map(move |(i, om)|
|
||||||
object! {
|
object! {
|
||||||
"block_height" => wtx.block.clone(),
|
"block_height" => wtx.block.clone(),
|
||||||
"datetime" => wtx.datetime.clone(),
|
"datetime" => wtx.datetime.clone(),
|
||||||
"position" => om.position,
|
"position" => i,
|
||||||
"txid" => format!("{}", wtx.txid),
|
"txid" => format!("{}", wtx.txid),
|
||||||
"amount" => om.value as i64,
|
"amount" => om.value as i64,
|
||||||
"address" => om.address.clone(),
|
"address" => om.address.clone(),
|
||||||
|
|||||||
@@ -1562,20 +1562,20 @@ pub fn scan_full_mempool_tx(&self, tx: &Transaction, height: i32, _datetime: u64
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let position = if formatted_memo.as_ref().map_or(false, |m| m.starts_with('{')) {
|
/*let position = if formatted_memo.as_ref().map_or(false, |m| m.starts_with('{')) {
|
||||||
1
|
1
|
||||||
} else {
|
} else {
|
||||||
existing_txs.iter()
|
existing_txs.iter()
|
||||||
.filter(|tx| !LightWallet::memo_str(&Some(tx.incoming_metadata.iter().last().unwrap().memo.clone())).as_ref().map_or(false, |m| m.starts_with('{')))
|
.filter(|tx| !LightWallet::memo_str(&Some(tx.incoming_metadata.iter().last().unwrap().memo.clone())).as_ref().map_or(false, |m| m.starts_with('{')))
|
||||||
.count() as u64 + 2
|
.count() as u64 + 2
|
||||||
};
|
};*/
|
||||||
|
|
||||||
let incoming_metadata = IncomingTxMetadata {
|
let incoming_metadata = IncomingTxMetadata {
|
||||||
address: addr.clone(),
|
address: addr.clone(),
|
||||||
value: amt,
|
value: amt,
|
||||||
memo: memo.clone(),
|
memo: memo.clone(),
|
||||||
incoming_mempool: true,
|
incoming_mempool: true,
|
||||||
position: position,
|
// position: position,
|
||||||
};
|
};
|
||||||
|
|
||||||
wtx.incoming_metadata.push(incoming_metadata);
|
wtx.incoming_metadata.push(incoming_metadata);
|
||||||
@@ -1595,7 +1595,7 @@ pub fn scan_full_mempool_tx(&self, tx: &Transaction, height: i32, _datetime: u64
|
|||||||
value: amt,
|
value: amt,
|
||||||
memo: memo.clone(),
|
memo: memo.clone(),
|
||||||
incoming_mempool: true,
|
incoming_mempool: true,
|
||||||
position: position,
|
// position: position,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let mut new_wtx = WalletTx::new(height, now() as u64, &tx.txid());
|
let mut new_wtx = WalletTx::new(height, now() as u64, &tx.txid());
|
||||||
@@ -1604,14 +1604,14 @@ pub fn scan_full_mempool_tx(&self, tx: &Transaction, height: i32, _datetime: u64
|
|||||||
value: amt,
|
value: amt,
|
||||||
memo: memo.clone(),
|
memo: memo.clone(),
|
||||||
incoming_mempool: true,
|
incoming_mempool: true,
|
||||||
position: position,
|
// position: position,
|
||||||
});
|
});
|
||||||
txs.insert(tx.txid(), new_wtx);
|
txs.insert(tx.txid(), new_wtx);
|
||||||
}
|
}
|
||||||
|
|
||||||
info!("Successfully added txid with memo");
|
info!("Successfully added txid with memo");
|
||||||
} else {
|
} else {
|
||||||
let position = 0;
|
// let position = 0;
|
||||||
|
|
||||||
// Check if txid already exists in the hashmap
|
// Check if txid already exists in the hashmap
|
||||||
let txid_exists = match self.txs.read() {
|
let txid_exists = match self.txs.read() {
|
||||||
@@ -1633,7 +1633,7 @@ pub fn scan_full_mempool_tx(&self, tx: &Transaction, height: i32, _datetime: u64
|
|||||||
value: amt,
|
value: amt,
|
||||||
memo: memo.clone(),
|
memo: memo.clone(),
|
||||||
incoming_mempool: true,
|
incoming_mempool: true,
|
||||||
position: position,
|
// position: position,
|
||||||
};
|
};
|
||||||
|
|
||||||
wtx.incoming_metadata.push(incoming_metadata);
|
wtx.incoming_metadata.push(incoming_metadata);
|
||||||
@@ -1653,7 +1653,7 @@ pub fn scan_full_mempool_tx(&self, tx: &Transaction, height: i32, _datetime: u64
|
|||||||
value: amt,
|
value: amt,
|
||||||
memo: memo.clone(),
|
memo: memo.clone(),
|
||||||
incoming_mempool: true,
|
incoming_mempool: true,
|
||||||
position: position,
|
// position: position,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let mut new_wtx = WalletTx::new(height, now() as u64, &tx.txid());
|
let mut new_wtx = WalletTx::new(height, now() as u64, &tx.txid());
|
||||||
@@ -1662,7 +1662,7 @@ pub fn scan_full_mempool_tx(&self, tx: &Transaction, height: i32, _datetime: u64
|
|||||||
value: amt,
|
value: amt,
|
||||||
memo: memo.clone(),
|
memo: memo.clone(),
|
||||||
incoming_mempool: true,
|
incoming_mempool: true,
|
||||||
position: position,
|
// position: position,
|
||||||
});
|
});
|
||||||
txs.insert(tx.txid(), new_wtx);
|
txs.insert(tx.txid(), new_wtx);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ pub struct IncomingTxMetadata {
|
|||||||
pub value : u64,
|
pub value : u64,
|
||||||
pub memo : Memo,
|
pub memo : Memo,
|
||||||
pub incoming_mempool: bool,
|
pub incoming_mempool: bool,
|
||||||
pub position: u64,
|
// pub position: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IncomingTxMetadata {
|
impl IncomingTxMetadata {
|
||||||
@@ -378,7 +378,7 @@ impl IncomingTxMetadata {
|
|||||||
|
|
||||||
let value = reader.read_u64::<LittleEndian>()?;
|
let value = reader.read_u64::<LittleEndian>()?;
|
||||||
let incoming_mempool = true;
|
let incoming_mempool = true;
|
||||||
let position = 0;
|
// let position = 0;
|
||||||
|
|
||||||
let mut memo_bytes = [0u8; 512];
|
let mut memo_bytes = [0u8; 512];
|
||||||
reader.read_exact(&mut memo_bytes)?;
|
reader.read_exact(&mut memo_bytes)?;
|
||||||
@@ -389,7 +389,7 @@ impl IncomingTxMetadata {
|
|||||||
value,
|
value,
|
||||||
memo,
|
memo,
|
||||||
incoming_mempool,
|
incoming_mempool,
|
||||||
position,
|
// position,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user