chain_tip: BlockId,
txid: Txid,
) -> Result<Option<ObservedAs<&A>>, C::Error> {
- let (tx_node, anchors, &last_seen) = match self.txs.get(&txid) {
- Some((tx, anchors, last_seen)) if !(anchors.is_empty() && *last_seen == 0) => {
- (tx, anchors, last_seen)
- }
- _ => return Ok(None),
+ let (tx_node, anchors, last_seen) = match self.txs.get(&txid) {
+ Some(v) => v,
+ None => return Ok(None),
};
for anchor in anchors {
return Ok(None);
}
}
- if conflicting_tx.last_seen_unconfirmed > last_seen {
+ if conflicting_tx.last_seen_unconfirmed > *last_seen {
return Ok(None);
}
}
- Ok(Some(ObservedAs::Unconfirmed(last_seen)))
+ Ok(Some(ObservedAs::Unconfirmed(*last_seen)))
}
/// Get the position of the transaction in `chain` with tip `chain_tip`.
ObservedAs::Confirmed(&local_chain.get_block(95).expect("block expected"))
);
- // As long the unconfirmed tx isn't marked as seen, chain_spend will return None.
- assert!(graph
- .get_chain_spend(&local_chain, tip, OutPoint::new(tx_0.txid(), 1))
- .is_none());
+ // Even if unconfirmed tx has a last_seen of 0, it can still be part of a chain spend.
+ assert_eq!(
+ graph.get_chain_spend(&local_chain, tip, OutPoint::new(tx_0.txid(), 1)),
+ Some((ObservedAs::Unconfirmed(0), tx_2.txid())),
+ );
// Mark the unconfirmed as seen and check correct ObservedAs status is returned.
let _ = graph.insert_seen_at(tx_2.txid(), 1234567);