Fixes #4669 (see discussion there).
Also move the loading of addresses to StartNode() to make it more self-contained.
Fixes #4669.
Move the loading of addresses to StartNode() to make it more
self-contained.
1739 | @@ -1739,6 +1740,18 @@ void static Discover(boost::thread_group& threadGroup) 1740 | 1741 | void StartNode(boost::thread_group& threadGroup) 1742 | { 1743 | + uiInterface.InitMessage(_("Loading addresses..."));
Feels weird to have an init message in net.cpp, just saying.
Not strange at all - StartNode is part of the initialization process. This is bound to happen as we modularize. In time I expect all init messages to be in modules.
StartNode is not called in the case that there is a lock file, as AppInit2 stops partway!
1062 | @@ -1056,6 +1063,7 @@ bool AppInit2(boost::thread_group& threadGroup) 1063 | // Allowed to fail as this file IS missing on first startup. 1064 | if (est_filein) 1065 | mempool.ReadFeeEstimates(est_filein); 1066 | + fFeeEstimatesInitialized = true;
That fee file isn't created here, so that can't be the place where we should set init to true?
It doesn't need to be created here. We just need the flag to know whether we reached this stage in the initialization process. If we did, it is valid to write the file on shutdown.
Alright, but at least the variable name is missleading? At this stage we could have a missing file, an up-version file or some serialisation error, which would make me think fFeeEstimatesInitialized shouldn't be true. Perhaps fWriteFeeEstimates is better.
The point is that it doesn't matter which of those are the case. We choose to ignore read errors. If the file is invalid or missing, it's fine to write an empty file. It's just not fine to write an empty file when initialization failed.
142 | @@ -137,6 +143,7 @@ void Shutdown()
143 | mempool.WriteFeeEstimates(est_fileout);
IMHO that call creates the file.
Which is inside if (fFeeEstimatesInitialized) now right? So if the fee estimates were never read (or deemed missing and initialized to empty), they won't be written either.
Correct!
IF StartNode() was called, it is valid for the shutdown (or the DumpAddresses thread) to write the addresses file, no matter how many addresses are in it.
This is an initialization sequence fix: It makes sure that if the lock file is missing, or AppInit2() exits in some other way before addresses list is initialized, it won't write an empty file on shutdown (and StopNode),
Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/p4942_94064710b9123dfb3df8cfd6c32efae349aec281/ for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.
utACK. I guess at some point we want the fee data to move from globals into an encapsulated state, which only exists when it was correctly loaded. But this is already an improvement.
ut ACK