Skip to content

Commit 68b9725

Browse files
committed
Add PR Suggestions:
- remove method instead of deprecating it. - Formatting - CHANGELOG entries
1 parent 1bd9369 commit 68b9725

File tree

3 files changed

+17
-26
lines changed

3 files changed

+17
-26
lines changed

zcash_client_backend/src/data_api.rs

+1-11
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ impl AccountBalance {
286286

287287
/// Returns the total value of unspent transparent transaction outputs belonging to the wallet.
288288
#[deprecated(
289-
note = "this function is deprecated. Please use AccountBalance::unshielded_balance instead."
289+
note = "this function is deprecated. Please use [`AccountBalance::unshielded_balance`] instead."
290290
)]
291291
pub fn unshielded(&self) -> NonNegativeAmount {
292292
self.unshielded_balance.total()
@@ -309,16 +309,6 @@ impl AccountBalance {
309309
Ok(result)
310310
}
311311

312-
/// Adds the specified value to the unshielded total, checking for overflow of
313-
/// the total account balance.
314-
#[deprecated(
315-
note = "this function is deprecated. Please use the `Balance::add_spendable_value` on the unshielded field instead instead."
316-
)]
317-
pub fn add_unshielded_value(&mut self, value: NonNegativeAmount) -> Result<(), BalanceError> {
318-
self.unshielded_balance.add_pending_spendable_value(value)?;
319-
Ok(())
320-
}
321-
322312
/// Returns the total value of funds belonging to the account.
323313
pub fn total(&self) -> NonNegativeAmount {
324314
(self.sapling_balance.total()

zcash_client_sqlite/src/wallet/transparent.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -423,10 +423,7 @@ pub(crate) fn add_transparent_account_balances(
423423
account_balances
424424
.entry(account)
425425
.or_insert(AccountBalance::ZERO)
426-
.with_unshielded_balance_mut::<_, SqliteClientError>(|bal| {
427-
bal.add_spendable_value(value)?;
428-
Ok(())
429-
})?;
426+
.with_unshielded_balance_mut(|bal| bal.add_spendable_value(value))?;
430427
}
431428

432429
let mut stmt_account_unconfirmed_balances = conn.prepare(
@@ -469,10 +466,7 @@ pub(crate) fn add_transparent_account_balances(
469466
account_balances
470467
.entry(account)
471468
.or_insert(AccountBalance::ZERO)
472-
.with_unshielded_balance_mut::<_, SqliteClientError>(|bal| {
473-
bal.add_pending_spendable_value(value)?;
474-
Ok(())
475-
})?;
469+
.with_unshielded_balance_mut(|bal| bal.add_pending_spendable_value(value))?;
476470
}
477471
Ok(())
478472
}

zcash_primitives/CHANGELOG.md

+14-7
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,24 @@ and this library adheres to Rust's notion of
1010
- `zcash_client_backend::AccountBalance::with_unshielded_balance_mut`
1111

1212
### Deprecated
13-
- `zcash_client_backend::AccountBalance::add_unshielded_value`
14-
- `zcash_client_backend::AccountBalance::unshielded`
13+
- `zcash_client_backend::AccountBalance::unshielded`. Instead use
14+
`account_balance.unshielded_balance().total()`.
15+
16+
### Removed
17+
- `zcash_client_backend::AccountBalance::add_unshielded_value`. Instead use
18+
`AccountBalance::with_unshielded_balance_mut` with a closure that calls
19+
the appropriate `add_*_value` method(s) of `Balance` on its argument.
20+
Note that the appropriate method(s) depend on whether the funds are
21+
spendable, pending change, or pending non-change (previously, only the
22+
total unshielded value was tracked).
1523
## [0.19.0] - 2024-10-02
1624

1725
### Changed
1826
- Migrated to `zcash_address 0.6`.
19-
- Implemented changes to refactor AccountBalance to use Balance for transparent funds
20-
(see issue #1411). `AccountBalance` now has an `unshielded` value that uses Balance.
21-
The current implementation maintains retrocompatibility with the `unshielded` value
22-
represeted with a `NonNegativeAmount`. There are values that are pending to be
23-
implemented such as change tracking.
27+
- Refactored `AccountBalance` to use `Balance` for transparent funds (issue #1411).
28+
`AccountBalance` now has an `unshielded_balance()` that uses `Balance`. This does
29+
not currently distinguish between pending change and non-change; the pending value
30+
is all counted as non-change.
2431

2532

2633
### Fixed

0 commit comments

Comments
 (0)