Skip to content

Commit b0dc3dd

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 00c568d commit b0dc3dd

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

+4-7
Original file line numberDiff line numberDiff line change
@@ -2254,26 +2254,23 @@ impl Wallet {
22542254
let now = SystemTime::now()
22552255
.duration_since(UNIX_EPOCH)
22562256
.expect("time now must surpass epoch anchor");
2257-
self.apply_update_at(update, Some(now.as_secs()))
2257+
self.apply_update_at(update, now.as_secs())
22582258
}
22592259

2260-
/// Applies an `update` alongside an optional `seen_at` timestamp and stages the changes.
2260+
/// Applies an `update` alongside a `seen_at` timestamp and stages the changes.
22612261
///
22622262
/// `seen_at` represents when the update is seen (in unix seconds). It is used to determine the
22632263
/// `last_seen`s for all transactions in the update which have no corresponding anchor(s). The
22642264
/// `last_seen` value is used internally to determine precedence of conflicting unconfirmed
22652265
/// transactions (where the transaction with the lower `last_seen` value is omitted from the
22662266
/// canonical history).
22672267
///
2268-
/// Not setting a `seen_at` value means unconfirmed transactions introduced by this update will
2269-
/// not be part of the canonical history of transactions.
2270-
///
22712268
/// Use [`apply_update`](Wallet::apply_update) to have the `seen_at` value automatically set to
22722269
/// the current time.
22732270
pub fn apply_update_at(
22742271
&mut self,
22752272
update: impl Into<Update>,
2276-
seen_at: Option<u64>,
2273+
seen_at: u64,
22772274
) -> Result<(), CannotConnectError> {
22782275
let update = update.into();
22792276
let mut changeset = match update.chain {
@@ -2288,7 +2285,7 @@ impl Wallet {
22882285
changeset.merge(index_changeset.into());
22892286
changeset.merge(
22902287
self.indexed_graph
2291-
.apply_update_at(update.tx_update, seen_at)
2288+
.apply_update_at(update.tx_update, Some(seen_at))
22922289
.into(),
22932290
);
22942291
self.stage.merge(changeset);

0 commit comments

Comments
 (0)