[chain_redesign] Change behavior of try_get_chain_position
`TxGraph::try_get_chain_position` used to always exclude unconfirmed transactions with last_seen value of 0. However, what is the point of including a transaction in the graph if it cannot be part of the chain history? Additionally, maybe sometimes we don't wish to use the last_seen field at all. The new behavior will consider unconfirmed transactions with last_seen of 0.
This commit is contained in:
@@ -624,11 +624,9 @@ impl<A: Anchor> TxGraph<A> {
|
||||
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 {
|
||||
@@ -657,12 +655,12 @@ impl<A: Anchor> TxGraph<A> {
|
||||
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`.
|
||||
|
||||
Reference in New Issue
Block a user