ref(tx_graph)!: Rename list_chain_txs
to list_canonical_txs
This commit is contained in:
parent
2ce4bb4dfc
commit
b34790c6b6
@ -981,10 +981,10 @@ impl<A: Anchor> TxGraph<A> {
|
|||||||
/// If the [`ChainOracle`] implementation (`chain`) fails, an error will be returned with the
|
/// If the [`ChainOracle`] implementation (`chain`) fails, an error will be returned with the
|
||||||
/// returned item.
|
/// returned item.
|
||||||
///
|
///
|
||||||
/// If the [`ChainOracle`] is infallible, [`list_chain_txs`] can be used instead.
|
/// If the [`ChainOracle`] is infallible, [`list_canonical_txs`] can be used instead.
|
||||||
///
|
///
|
||||||
/// [`list_chain_txs`]: Self::list_chain_txs
|
/// [`list_canonical_txs`]: Self::list_canonical_txs
|
||||||
pub fn try_list_chain_txs<'a, C: ChainOracle + 'a>(
|
pub fn try_list_canonical_txs<'a, C: ChainOracle + 'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
chain: &'a C,
|
chain: &'a C,
|
||||||
chain_tip: BlockId,
|
chain_tip: BlockId,
|
||||||
@ -1003,15 +1003,15 @@ impl<A: Anchor> TxGraph<A> {
|
|||||||
|
|
||||||
/// List graph transactions that are in `chain` with `chain_tip`.
|
/// List graph transactions that are in `chain` with `chain_tip`.
|
||||||
///
|
///
|
||||||
/// This is the infallible version of [`try_list_chain_txs`].
|
/// This is the infallible version of [`try_list_canonical_txs`].
|
||||||
///
|
///
|
||||||
/// [`try_list_chain_txs`]: Self::try_list_chain_txs
|
/// [`try_list_canonical_txs`]: Self::try_list_canonical_txs
|
||||||
pub fn list_chain_txs<'a, C: ChainOracle + 'a>(
|
pub fn list_canonical_txs<'a, C: ChainOracle + 'a>(
|
||||||
&'a self,
|
&'a self,
|
||||||
chain: &'a C,
|
chain: &'a C,
|
||||||
chain_tip: BlockId,
|
chain_tip: BlockId,
|
||||||
) -> impl Iterator<Item = CanonicalTx<'a, Arc<Transaction>, A>> {
|
) -> impl Iterator<Item = CanonicalTx<'a, Arc<Transaction>, A>> {
|
||||||
self.try_list_chain_txs(chain, chain_tip)
|
self.try_list_canonical_txs(chain, chain_tip)
|
||||||
.map(|r| r.expect("oracle is infallible"))
|
.map(|r| r.expect("oracle is infallible"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ struct Scenario<'a> {
|
|||||||
name: &'a str,
|
name: &'a str,
|
||||||
/// Transaction templates
|
/// Transaction templates
|
||||||
tx_templates: &'a [TxTemplate<'a, BlockId>],
|
tx_templates: &'a [TxTemplate<'a, BlockId>],
|
||||||
/// Names of txs that must exist in the output of `list_chain_txs`
|
/// Names of txs that must exist in the output of `list_canonical_txs`
|
||||||
exp_chain_txs: HashSet<&'a str>,
|
exp_chain_txs: HashSet<&'a str>,
|
||||||
/// Outpoints that must exist in the output of `filter_chain_txouts`
|
/// Outpoints that must exist in the output of `filter_chain_txouts`
|
||||||
exp_chain_txouts: HashSet<(&'a str, u32)>,
|
exp_chain_txouts: HashSet<(&'a str, u32)>,
|
||||||
@ -27,7 +27,7 @@ struct Scenario<'a> {
|
|||||||
|
|
||||||
/// This test ensures that [`TxGraph`] will reliably filter out irrelevant transactions when
|
/// This test ensures that [`TxGraph`] will reliably filter out irrelevant transactions when
|
||||||
/// presented with multiple conflicting transaction scenarios using the [`TxTemplate`] structure.
|
/// presented with multiple conflicting transaction scenarios using the [`TxTemplate`] structure.
|
||||||
/// This test also checks that [`TxGraph::list_chain_txs`], [`TxGraph::filter_chain_txouts`],
|
/// This test also checks that [`TxGraph::list_canonical_txs`], [`TxGraph::filter_chain_txouts`],
|
||||||
/// [`TxGraph::filter_chain_unspents`], and [`TxGraph::balance`] return correct data.
|
/// [`TxGraph::filter_chain_unspents`], and [`TxGraph::balance`] return correct data.
|
||||||
#[test]
|
#[test]
|
||||||
fn test_tx_conflict_handling() {
|
fn test_tx_conflict_handling() {
|
||||||
@ -597,7 +597,7 @@ fn test_tx_conflict_handling() {
|
|||||||
let (tx_graph, spk_index, exp_tx_ids) = init_graph(scenario.tx_templates.iter());
|
let (tx_graph, spk_index, exp_tx_ids) = init_graph(scenario.tx_templates.iter());
|
||||||
|
|
||||||
let txs = tx_graph
|
let txs = tx_graph
|
||||||
.list_chain_txs(&local_chain, chain_tip)
|
.list_canonical_txs(&local_chain, chain_tip)
|
||||||
.map(|tx| tx.tx_node.txid)
|
.map(|tx| tx.tx_node.txid)
|
||||||
.collect::<BTreeSet<_>>();
|
.collect::<BTreeSet<_>>();
|
||||||
let exp_txs = scenario
|
let exp_txs = scenario
|
||||||
@ -607,7 +607,7 @@ fn test_tx_conflict_handling() {
|
|||||||
.collect::<BTreeSet<_>>();
|
.collect::<BTreeSet<_>>();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
txs, exp_txs,
|
txs, exp_txs,
|
||||||
"\n[{}] 'list_chain_txs' failed",
|
"\n[{}] 'list_canonical_txs' failed",
|
||||||
scenario.name
|
scenario.name
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1091,7 +1091,7 @@ impl Wallet {
|
|||||||
{
|
{
|
||||||
self.indexed_graph
|
self.indexed_graph
|
||||||
.graph()
|
.graph()
|
||||||
.list_chain_txs(&self.chain, self.chain.tip().block_id())
|
.list_canonical_txs(&self.chain, self.chain.tip().block_id())
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Return the balance, separated into available, trusted-pending, untrusted-pending and immature
|
/// Return the balance, separated into available, trusted-pending, untrusted-pending and immature
|
||||||
|
@ -277,7 +277,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
if unconfirmed {
|
if unconfirmed {
|
||||||
let unconfirmed_txids = graph
|
let unconfirmed_txids = graph
|
||||||
.graph()
|
.graph()
|
||||||
.list_chain_txs(&*chain, chain_tip.block_id())
|
.list_canonical_txs(&*chain, chain_tip.block_id())
|
||||||
.filter(|canonical_tx| !canonical_tx.chain_position.is_confirmed())
|
.filter(|canonical_tx| !canonical_tx.chain_position.is_confirmed())
|
||||||
.map(|canonical_tx| canonical_tx.tx_node.txid)
|
.map(|canonical_tx| canonical_tx.tx_node.txid)
|
||||||
.collect::<Vec<Txid>>();
|
.collect::<Vec<Txid>>();
|
||||||
|
@ -307,7 +307,7 @@ fn main() -> anyhow::Result<()> {
|
|||||||
// `EsploraExt::update_tx_graph_without_keychain`.
|
// `EsploraExt::update_tx_graph_without_keychain`.
|
||||||
let unconfirmed_txids = graph
|
let unconfirmed_txids = graph
|
||||||
.graph()
|
.graph()
|
||||||
.list_chain_txs(&*chain, local_tip.block_id())
|
.list_canonical_txs(&*chain, local_tip.block_id())
|
||||||
.filter(|canonical_tx| !canonical_tx.chain_position.is_confirmed())
|
.filter(|canonical_tx| !canonical_tx.chain_position.is_confirmed())
|
||||||
.map(|canonical_tx| canonical_tx.tx_node.txid)
|
.map(|canonical_tx| canonical_tx.tx_node.txid)
|
||||||
.collect::<Vec<Txid>>();
|
.collect::<Vec<Txid>>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user