Skip to content

Commit 1d61fde

Browse files
evanlinjinValuedMammal
authored andcommitted
feat(wallet)!: make seen_at mandatory for Wallet::apply_update_at
Not including a `seen_at` alongside the update means the unconfirmed txs of the update will not be considered to be part of the canonical history. Therefore, transactions created with this wallet may replace the update's unconfirmed txs (which is unintuitive behavior). Also updated the docs.
1 parent 5cf9ba9 commit 1d61fde

File tree

1 file changed

+4
-7
lines changed
  • crates/wallet/src/wallet

1 file changed

+4
-7
lines changed

crates/wallet/src/wallet/mod.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2256,26 +2256,23 @@ impl Wallet {
22562256
let now = SystemTime::now()
22572257
.duration_since(UNIX_EPOCH)
22582258
.expect("time now must surpass epoch anchor");
2259-
self.apply_update_at(update, Some(now.as_secs()))
2259+
self.apply_update_at(update, now.as_secs())
22602260
}
22612261

2262-
/// Applies an `update` alongside an optional `seen_at` timestamp and stages the changes.
2262+
/// Applies an `update` alongside a `seen_at` timestamp and stages the changes.
22632263
///
22642264
/// `seen_at` represents when the update is seen (in unix seconds). It is used to determine the
22652265
/// `last_seen`s for all transactions in the update which have no corresponding anchor(s). The
22662266
/// `last_seen` value is used internally to determine precedence of conflicting unconfirmed
22672267
/// transactions (where the transaction with the lower `last_seen` value is omitted from the
22682268
/// canonical history).
22692269
///
2270-
/// Not setting a `seen_at` value means unconfirmed transactions introduced by this update will
2271-
/// not be part of the canonical history of transactions.
2272-
///
22732270
/// Use [`apply_update`](Wallet::apply_update) to have the `seen_at` value automatically set to
22742271
/// the current time.
22752272
pub fn apply_update_at(
22762273
&mut self,
22772274
update: impl Into<Update>,
2278-
seen_at: Option<u64>,
2275+
seen_at: u64,
22792276
) -> Result<(), CannotConnectError> {
22802277
let update = update.into();
22812278
let mut changeset = match update.chain {
@@ -2290,7 +2287,7 @@ impl Wallet {
22902287
changeset.merge(index_changeset.into());
22912288
changeset.merge(
22922289
self.indexed_graph
2293-
.apply_update_at(update.tx_update, seen_at)
2290+
.apply_update_at(update.tx_update, Some(seen_at))
22942291
.into(),
22952292
);
22962293
self.stage.merge(changeset);

0 commit comments

Comments
 (0)