Skip to content

[chain] last_seen_unconfirmed should have a default of None not 0 #1396

@LLFourn

Description

@LLFourn

Current implementation of TxGraph insert_tx is:

    /// Inserts the given transaction into [`TxGraph`].
    ///
    /// The [`ChangeSet`] returned will be empty if `tx` already exists.
    pub fn insert_tx(&mut self, tx: Transaction) -> ChangeSet<A> {
        let mut update = Self::default();
        update.txs.insert(
            tx.txid(),
            (TxNodeInternal::Whole(tx.into()), BTreeSet::new(), 0),
        );
        self.apply_update(update)
    }

The 0 in the tuple represents the last time the transaction has been seen unconfirmed. I think it is wrong to set 0 here because you should be able to insert transactions into the graph (or wallet) that have never been broadcast and have never been seen. When you list canonical transactions1 you don't want to list transactions that have been inserted but never actually seen. In other words the field should be an Option which is still monotonically increasing with None being the smallest value.

I don't think this change affects the changeset struct, it just changes how you interpret a missing last_seen.

Footnotes

  1. Incidentally we should rename try_list_chain_txs to canonincal_transactions

Metadata

Metadata

Assignees

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions