chain: add batch-insert methods for IndexedTxGraph

This commit is contained in:
志宇
2023-10-04 17:10:46 +08:00
parent 43bc813c64
commit 240657b167
2 changed files with 149 additions and 32 deletions

View File

@@ -74,7 +74,7 @@ fn insert_relevant_txs() {
};
assert_eq!(
graph.insert_relevant_txs(txs.iter().map(|tx| (tx, None)), None),
graph.batch_insert_relevant(txs.iter().map(|tx| (tx, None, None))),
changeset,
);
@@ -211,8 +211,8 @@ fn test_list_owned_txouts() {
// Insert transactions into graph with respective anchors
// For unconfirmed txs we pass in `None`.
let _ = graph.insert_relevant_txs(
[&tx1, &tx2, &tx3, &tx6].iter().enumerate().map(|(i, tx)| {
let _ =
graph.batch_insert_relevant([&tx1, &tx2, &tx3, &tx6].iter().enumerate().map(|(i, tx)| {
let height = i as u32;
(
*tx,
@@ -225,12 +225,11 @@ fn test_list_owned_txouts() {
anchor_block,
confirmation_height: anchor_block.height,
}),
None,
)
}),
None,
);
}));
let _ = graph.insert_relevant_txs([&tx4, &tx5].iter().map(|tx| (*tx, None)), Some(100));
let _ = graph.batch_insert_relevant([&tx4, &tx5].iter().map(|tx| (*tx, None, Some(100))));
// A helper lambda to extract and filter data from the graph.
let fetch =