mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-18 13:17:55 +02:00
Write fee estimate and peers files only when initialized
Fixes #4669. Move the loading of addresses to StartNode() to make it more self-contained.
This commit is contained in:
parent
7fd8813675
commit
94064710b9
2 changed files with 29 additions and 18 deletions
20
src/net.cpp
20
src/net.cpp
|
|
@ -78,6 +78,7 @@ uint64_t nLocalHostNonce = 0;
|
|||
static std::vector<ListenSocket> vhListenSocket;
|
||||
CAddrMan addrman;
|
||||
int nMaxConnections = 125;
|
||||
bool fAddressesInitialized = false;
|
||||
|
||||
vector<CNode*> vNodes;
|
||||
CCriticalSection cs_vNodes;
|
||||
|
|
@ -1739,6 +1740,18 @@ void static Discover(boost::thread_group& threadGroup)
|
|||
|
||||
void StartNode(boost::thread_group& threadGroup)
|
||||
{
|
||||
uiInterface.InitMessage(_("Loading addresses..."));
|
||||
// Load addresses for peers.dat
|
||||
int64_t nStart = GetTimeMillis();
|
||||
{
|
||||
CAddrDB adb;
|
||||
if (!adb.Read(addrman))
|
||||
LogPrintf("Invalid or missing peers.dat; recreating\n");
|
||||
}
|
||||
LogPrintf("Loaded %i addresses from peers.dat %dms\n",
|
||||
addrman.size(), GetTimeMillis() - nStart);
|
||||
fAddressesInitialized = true;
|
||||
|
||||
if (semOutbound == NULL) {
|
||||
// initialize semaphore
|
||||
int nMaxOutbound = min(MAX_OUTBOUND_CONNECTIONS, nMaxConnections);
|
||||
|
|
@ -1785,7 +1798,12 @@ bool StopNode()
|
|||
if (semOutbound)
|
||||
for (int i=0; i<MAX_OUTBOUND_CONNECTIONS; i++)
|
||||
semOutbound->post();
|
||||
DumpAddresses();
|
||||
|
||||
if (fAddressesInitialized)
|
||||
{
|
||||
DumpAddresses();
|
||||
fAddressesInitialized = false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue