Prevent address generation on startup#82
Conversation
Avoid generating and writing a new wallet address to LMDB every time the GUI application starts up, which could lead to performance degradation. Instead, reuse the last generated address on initialization, and only generate a new address on user demand (via explicit 'generate' button).
| } | ||
|
|
||
| pub fn get_new_main_address( | ||
| pub async fn get_new_main_address_async( |
There was a problem hiding this comment.
Nit: I'd prefer to explicitly name get_new_main_address as blocking - I think names like
pub async fn get_new_main_address(..)
pub fn get_new_main_address_blocking(..)would be better
| } | ||
|
|
||
| pub fn deposit( | ||
| pub async fn deposit_async( |
There was a problem hiding this comment.
Nit: I'd prefer to explicitly name deposit as blocking - I think names like
pub async fn deposit(..)
pub fn deposit_blocking(..)would be better
| }); | ||
|
|
||
| if !config.headless { | ||
| let fallback_rt; |
There was a problem hiding this comment.
I'd prefer not to do deferred initialization if possible - something like
let rt_handle = match &app {
Ok(app) => Some(app.runtime.handle().clone()),
Err(_) =>
// fallback runtime
tokio::runtime::Builder::new_multi_thread()
.enable_all()
.build()
.ok(),
};
let _rt_guard = rt_handle.as_ref().map(|rt| rt.enter());would be cleaner
| Ok(address) | ||
| } | ||
|
|
||
| pub fn get_last_address(&self) -> Result<Option<Address>, Error> { |
There was a problem hiding this comment.
I think a better naming convention here would be
/// Gets the latest generated address
pub fn try_get_last_address(&self) -> Result<Option<Address>, Error> {...}
/// Gets the latest generated address, or generates a new one if no addresses have already been generated
pub fn get_or_generate_last_address -> Result<Address, Error> {...}| use super::*; | ||
|
|
||
| #[test] | ||
| fn test_get_address_or_new() -> Result<(), Error> { |
There was a problem hiding this comment.
I'd prefer not to return a Result<(), Error> here, because the error will not be formatted with sources if encountered during the test. Use anyhow::Result<()> here instead
| .unwrap() | ||
| .as_nanos() | ||
| )); | ||
|
|
There was a problem hiding this comment.
Nit: a lot of useless line breaks here, this test could be a lot more compact without compromising readablility
Description
This PR resolves the issue where the Thunder GUI window size was too small on startup and caused layout squishing (vertical letters) in the Mempool Explorer and Transaction Builder tabs.
Changes Made
eframe::NativeOptionsinapp/main.rsto set the default viewport inner size to1280x720pixels.SidePanelcontainers insideScrollAreawithui.horizontalandui.verticalcolumns using fixed widths. This resolves layout breaking and enables correct horizontal scrolling behavior. Also updated the spent UTXOs grid ID to"spent_utxos"to prevent ID collisions.ScrollAreaand replaced nestedSidePanels withui.horizontalandui.verticalcolumns. Renamed the outputs grid from"inputs"to"outputs"to fix a duplicate ID warning.cargo fmt.Verification
cargo check.cargo test.This pull request was made by Antigravity Gemini 3.5 Flash High.