fix(daemon): let DRAGONX.conf dbcache override the pinned value
The wallet pins a -dbcache value on the daemon command line. A command-line flag overrides the same key in DRAGONX.conf, so a user who set their own dbcache in the conf never got it: the wallet's pin always won. - Before spawning, a normal start now reads DRAGONX.conf once and, if it sets dbcache, drops the wallet's own -dbcache pin from the arguments so the user's value takes effect. An isolated start keeps its own datadir and conf and is left alone. - The conf is now read a single time for both this check and the existing rpcthreads check instead of twice. Tests cover dropping the pin when the conf sets dbcache (in various forms), and leaving the default arguments untouched when it is commented out, empty, or sets something else. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -6859,6 +6859,25 @@ void testConfSetsKey()
|
||||
EXPECT_FALSE(EmbeddedDaemon::confSetsKey("rpcworkqueue=64 # rpcthreads=4\n", "rpcthreads"));
|
||||
}
|
||||
|
||||
// C97: a user dbcache= in DRAGONX.conf wins over the wallet's -dbcache pin; default argv is unchanged.
|
||||
void testDropPinnedDbcache()
|
||||
{
|
||||
using dragonx::daemon::EmbeddedDaemon;
|
||||
const std::vector<std::string> base{"-a", "-dbcache=450", "-b"};
|
||||
auto run = [&](const std::string& conf) {
|
||||
std::vector<std::string> v = base;
|
||||
EmbeddedDaemon::dropPinnedDbcacheIfConfSets(v, conf);
|
||||
return v;
|
||||
};
|
||||
const std::vector<std::string> dropped{"-a", "-b"};
|
||||
EXPECT_TRUE(run("dbcache=1000") == dropped);
|
||||
EXPECT_TRUE(run(" dbcache = 8\r\n") == dropped);
|
||||
EXPECT_TRUE(run("rpcuser=x\ndbcache=2000\n") == dropped);
|
||||
EXPECT_TRUE(run("#dbcache=1") == base);
|
||||
EXPECT_TRUE(run("") == base);
|
||||
EXPECT_TRUE(run("rpcuser=x") == base);
|
||||
}
|
||||
|
||||
// S12: the ownership record names the node we launched, by pid AND start time, so a later session can
|
||||
// recognise it after "Leave running" — and a reused pid, or a record from before a reboot, never matches.
|
||||
void testOwnershipRecord()
|
||||
@@ -18655,6 +18674,7 @@ int main()
|
||||
testDatadirLockGate();
|
||||
testDaemonProcessIdentity();
|
||||
testConfSetsKey();
|
||||
testDropPinnedDbcache();
|
||||
testOwnershipRecord();
|
||||
testDebugLogTailRules();
|
||||
testNoteConsolidation();
|
||||
|
||||
Reference in New Issue
Block a user