-
Notifications
You must be signed in to change notification settings - Fork 989
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
Override global one times. #3737
Conversation
… as an arg in the grin_api::Foreign::new.
…r modules for the rpc clients can be accessible in external projects.
…r the grin-gui so it can change the global contexts when it needs to switch from testnet to mainnet.
…nds in a start_index of 0 for new wallets.
core/src/core/pmmr/readonly_pmmr.rs
Outdated
@@ -73,7 +73,9 @@ where | |||
Some(p) => p, | |||
None => self.size, | |||
}; | |||
let mut pmmr_index = pmmr_index1 - 1; | |||
// default index to 0 if arg index1 is 0 | |||
let mut pmmr_index = if pmmr_index1 > 1 { pmmr_index1 - 1 } else { 0 }; |
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.
The endless saga of 1 vs 0 indexed pmmrs.
This is fine as a belt+suspenders check, though I think the idea was that this would always be called assuming a 1 index, as exposed by all of the APIs. A lot of work was done to use 0 indices internally, but this confusion still abounds.
In any case, all fine, but you can just use pmmr_index = pmmr_index1.saturating_sub(1);
instead of if statements
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.
Yeah, I traced this one from the grin-wallet/libwallet/src/api_impl/owners.rs - update_wallet_state function. Apparently, the start_index on line 1171 will always resolve to 0 for new wallets while the node is still syncing.
Okay, this seems all fine, just one small change noted above. This affects the core crate, but the new functions aren't called from anywhere else, just used by the grin-gui project. |
Yes, these functions are only really needed for the gui atm. I was thinking maybe a feature? |
Think we're fine as is, no need to complicate with features since there are no downsides to including this. |
The grin-gui needs to be able to start the embedded node either in Testnet or Mainnet. If the user selects a Testnet wallet while the embedded node is running on Mainnet the grin-gui shall shutdown the Mainnet node and restart a Testnet node. Unfortunately, since the init_global_... calls need to be called again with different parameters (i.e. change chain_type, fee, etc) the OneTime panics.
These functions shall permit the globals to be set again so the grin-gui can dynamically change its global context for Mainnet or Testnet.