-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
change(rpc): Update getaddressbalance
RPC to return received
field
#9295
base: db-format-upgrade-trait
Are you sure you want to change the base?
Conversation
Merge ProtectionsYour pull request matches the following merge protections and will not be merged until they are valid. 🔴 ⛓️ Depends-On RequirementsThis rule is failing.Requirement based on the presence of
|
|
||
let mut address_balance_location = AddressBalanceLocation::new(address_location); | ||
*address_balance_location.balance_mut() = balance; | ||
*address_balance_location.received_mut() = received; | ||
|
||
address_balance_location | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't fully reviewed this yet, but one thing I'm not sure about: don't we need to jump through hoops to make sure everything works during a database upgrade? Won't this code break trying to read values in the old format, or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Won't this code break trying to read values in the old format, or am I missing something?
The FromDisk
impl for AddressBalanceLocation
uses received_bytes.try_into().unwrap_or_default()
to read the received bytes or default to 0 if it's in the old format.
(Unfortunately I don't think there's a good way to make the old code work with the new data format)
55b3602
to
deff106
Compare
…n argument to getaddressbalance RPC (and others that accept the `AddressStrings` type)
944f8be
to
65fcd68
Compare
- Adds received balances to non-finalized state, and - Applies the partial chain received balance change to the finalized received balance when reading address balances.
// Return early if there are no blocks in the state and the database is empty. | ||
// Note: The caller should (and as of this writing, does) return early if the database is empty anyway. | ||
if initial_tip_height.is_min() { | ||
return Ok(()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This condition is checking if the state contains only the genesis block, not if it's entirely empty.
// Return early if there are no blocks in the state and the database is empty. | |
// Note: The caller should (and as of this writing, does) return early if the database is empty anyway. | |
if initial_tip_height.is_min() { | |
return Ok(()); | |
} |
Motivation
Updates the
getaddressbalance
RPC to accept either a single address string or a list of them to match zcashd, and adds thereceived
field on the method's response.This PR is still a draft as it will need an acceptance test.
Depends-On: #9263
Will close #8452.
Solution
received
field, and adds an in-place format upgrade,AddressStrings
as aVec
with one item, andreceived
field to thegetaddressbalance
RPC output.Tests
This PR still needs an acceptance test for the db format upgrade.
The changes to the RPC should be covered by existing snapshot tests.
PR Checklist
C-exclude-from-changelog
label.