Skip to content
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

Merged
merged 8 commits into from
Oct 7, 2022
Merged

Override global one times. #3737

merged 8 commits into from
Oct 7, 2022

Conversation

flomang
Copy link
Contributor

@flomang flomang commented Oct 3, 2022

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.

flomang and others added 7 commits August 18, 2022 11:37
…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.
@@ -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 };
Copy link
Member

@yeastplume yeastplume Oct 6, 2022

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

Copy link
Contributor Author

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.

@yeastplume
Copy link
Member

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.

@flomang
Copy link
Contributor Author

flomang commented Oct 6, 2022

Yes, these functions are only really needed for the gui atm. I was thinking maybe a feature?

@yeastplume
Copy link
Member

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.

@yeastplume yeastplume merged commit 529ce44 into mimblewimble:master Oct 7, 2022
bayk added a commit to mwcproject/mwc-node that referenced this pull request Jun 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants