fix: macOS block index corruption, dbcache auto-sizing, import key rescan height

- Shutdown: 3-phase stop (wait for RPC stop → SIGTERM → SIGKILL) prevents
  LevelDB flush interruption on macOS/APFS that caused full re-sync on restart
- dbcache: auto-detect RAM and set -dbcache to 12.5% (clamped 450-4096 MB)
  on macOS (sysctl), Linux (sysconf), and Windows (GlobalMemoryStatusEx)
- Import key: pass user-entered start height to z_importkey and trigger
  rescanblockchain from that height for t-key imports
- Bump version to 1.1.1
This commit is contained in:
2026-03-25 11:00:14 -05:00
parent f0b7b88ef2
commit f02c965929
6 changed files with 109 additions and 25 deletions

View File

@@ -307,8 +307,9 @@ void ImportKeyDialog::render(App* app)
// Import keys on worker thread to avoid freezing UI
bool rescan = s_rescan;
int rescanHeight = s_rescan_height;
if (app->worker()) {
app->worker()->post([rpc = app->rpc(), keys, rescan]() -> rpc::RPCWorker::MainCb {
app->worker()->post([rpc = app->rpc(), keys, rescan, rescanHeight]() -> rpc::RPCWorker::MainCb {
int imported = 0;
int failed = 0;
@@ -317,10 +318,22 @@ void ImportKeyDialog::render(App* app)
try {
if (keyType == "z-spending") {
rpc->call("z_importkey", {key, rescan ? "yes" : "no"});
// z_importkey "key" "yes"|"no" startheight
if (rescan && rescanHeight > 0) {
rpc->call("z_importkey", {key, "yes", rescanHeight});
} else {
rpc->call("z_importkey", {key, rescan ? "yes" : "no"});
}
imported++;
} else if (keyType == "t-privkey") {
rpc->call("importprivkey", {key, "", rescan});
// importprivkey does not accept a startheight;
// import without rescan, then rescanblockchain
// from the requested height afterward.
if (rescan && rescanHeight > 0) {
rpc->call("importprivkey", {key, "", false});
} else {
rpc->call("importprivkey", {key, "", rescan});
}
imported++;
} else {
failed++;
@@ -329,6 +342,17 @@ void ImportKeyDialog::render(App* app)
failed++;
}
}
// If t-keys were imported without rescan (because a
// specific start height was requested), trigger a
// single rescanblockchain from that height now.
if (rescan && rescanHeight > 0 && imported > 0) {
try {
rpc->call("rescanblockchain", {rescanHeight});
} catch (...) {
// rescan failure is non-fatal; user can retry
}
}
return [imported, failed]() {
s_imported_keys = imported;