Skip to content

Commit

Permalink
Add PR Suggestions:
Browse files Browse the repository at this point in the history
- remove method instead of deprecating it.
- Formatting
- CHANGELOG entries
  • Loading branch information
pacu committed Oct 20, 2024
1 parent 5f928c3 commit 3734cda
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 26 deletions.
12 changes: 1 addition & 11 deletions zcash_client_backend/src/data_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl AccountBalance {

/// Returns the total value of unspent transparent transaction outputs belonging to the wallet.
#[deprecated(
note = "this function is deprecated. Please use AccountBalance::unshielded_balance instead."
note = "this function is deprecated. Please use [`AccountBalance::unshielded_balance`] instead."
)]
pub fn unshielded(&self) -> NonNegativeAmount {
self.unshielded_balance.total()
Expand All @@ -310,16 +310,6 @@ impl AccountBalance {
Ok(result)
}

/// Adds the specified value to the unshielded total, checking for overflow of
/// the total account balance.
#[deprecated(
note = "this function is deprecated. Please use the `Balance::add_spendable_value` on the unshielded field instead instead."
)]
pub fn add_unshielded_value(&mut self, value: NonNegativeAmount) -> Result<(), BalanceError> {
self.unshielded_balance.add_pending_spendable_value(value)?;
Ok(())
}

/// Returns the total value of funds belonging to the account.
pub fn total(&self) -> NonNegativeAmount {
(self.sapling_balance.total()
Expand Down
10 changes: 2 additions & 8 deletions zcash_client_sqlite/src/wallet/transparent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,7 @@ pub(crate) fn add_transparent_account_balances(
account_balances
.entry(account)
.or_insert(AccountBalance::ZERO)
.with_unshielded_balance_mut::<_, SqliteClientError>(|bal| {
bal.add_spendable_value(value)?;
Ok(())
})?;
.with_unshielded_balance_mut(|bal| bal.add_spendable_value(value))?;
}

let mut stmt_account_unconfirmed_balances = conn.prepare(
Expand Down Expand Up @@ -469,10 +466,7 @@ pub(crate) fn add_transparent_account_balances(
account_balances
.entry(account)
.or_insert(AccountBalance::ZERO)
.with_unshielded_balance_mut::<_, SqliteClientError>(|bal| {
bal.add_pending_spendable_value(value)?;
Ok(())
})?;
.with_unshielded_balance_mut(|bal| bal.add_pending_spendable_value(value))?;
}
Ok(())
}
Expand Down
21 changes: 14 additions & 7 deletions zcash_primitives/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,24 @@ and this library adheres to Rust's notion of
- `zcash_client_backend::AccountBalance::with_unshielded_balance_mut`

### Deprecated
- `zcash_client_backend::AccountBalance::add_unshielded_value`
- `zcash_client_backend::AccountBalance::unshielded`
- `zcash_client_backend::AccountBalance::unshielded`. Instead use
`account_balance.unshielded_balance().total()`.

### Removed
- `zcash_client_backend::AccountBalance::add_unshielded_value`. Instead use
`AccountBalance::with_unshielded_balance_mut` with a closure that calls
the appropriate `add_*_value` method(s) of `Balance` on its argument.
Note that the appropriate method(s) depend on whether the funds are
spendable, pending change, or pending non-change (previously, only the
total unshielded value was tracked).
## [0.19.0] - 2024-10-02

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


### Fixed
Expand Down

0 comments on commit 3734cda

Please sign in to comment.