Changeset View
Changeset View
Standalone View
Standalone View
src/net.cpp
| Show First 20 Lines • Show All 409 Lines • ▼ Show 20 Lines | void CConnman::DumpBanlist() { | ||||
| SweepBanned(); | SweepBanned(); | ||||
| if (!BannedSetIsDirty()) { | if (!BannedSetIsDirty()) { | ||||
| return; | return; | ||||
| } | } | ||||
| int64_t nStart = GetTimeMillis(); | int64_t nStart = GetTimeMillis(); | ||||
| CBanDB bandb; | CBanDB bandb(config->GetChainParams()); | ||||
| banmap_t banmap; | banmap_t banmap; | ||||
| GetBanned(banmap); | GetBanned(banmap); | ||||
| if (bandb.Write(banmap)) { | if (bandb.Write(banmap)) { | ||||
| SetBannedSetDirty(false); | SetBannedSetDirty(false); | ||||
| } | } | ||||
| LogPrint(BCLog::NET, | LogPrint(BCLog::NET, | ||||
| "Flushed %d banned node ips/subnets to banlist.dat %dms\n", | "Flushed %d banned node ips/subnets to banlist.dat %dms\n", | ||||
| ▲ Show 20 Lines • Show All 1,283 Lines • ▼ Show 20 Lines | void CConnman::ThreadDNSAddressSeed() { | ||||
| } | } | ||||
| LogPrintf("%d addresses found from DNS seeds\n", found); | LogPrintf("%d addresses found from DNS seeds\n", found); | ||||
| } | } | ||||
| void CConnman::DumpAddresses() { | void CConnman::DumpAddresses() { | ||||
| int64_t nStart = GetTimeMillis(); | int64_t nStart = GetTimeMillis(); | ||||
| CAddrDB adb; | CAddrDB adb(config->GetChainParams()); | ||||
| adb.Write(addrman); | adb.Write(addrman); | ||||
| LogPrint(BCLog::NET, "Flushed %d addresses to peers.dat %dms\n", | LogPrint(BCLog::NET, "Flushed %d addresses to peers.dat %dms\n", | ||||
| addrman.size(), GetTimeMillis() - nStart); | addrman.size(), GetTimeMillis() - nStart); | ||||
| } | } | ||||
| void CConnman::DumpData() { | void CConnman::DumpData() { | ||||
| DumpAddresses(); | DumpAddresses(); | ||||
| ▲ Show 20 Lines • Show All 638 Lines • ▼ Show 20 Lines | bool CConnman::Start(CScheduler &scheduler, std::string &strNodeError, | ||||
| clientInterface = connOptions.uiInterface; | clientInterface = connOptions.uiInterface; | ||||
| if (clientInterface) { | if (clientInterface) { | ||||
| clientInterface->InitMessage(_("Loading addresses...")); | clientInterface->InitMessage(_("Loading addresses...")); | ||||
| } | } | ||||
| // Load addresses from peers.dat | // Load addresses from peers.dat | ||||
| int64_t nStart = GetTimeMillis(); | int64_t nStart = GetTimeMillis(); | ||||
| { | { | ||||
| CAddrDB adb; | CAddrDB adb(config->GetChainParams()); | ||||
| if (adb.Read(addrman)) { | if (adb.Read(addrman)) { | ||||
| LogPrintf("Loaded %i addresses from peers.dat %dms\n", | LogPrintf("Loaded %i addresses from peers.dat %dms\n", | ||||
| addrman.size(), GetTimeMillis() - nStart); | addrman.size(), GetTimeMillis() - nStart); | ||||
| } else { | } else { | ||||
| // Addrman can be in an inconsistent state after failure, reset it | // Addrman can be in an inconsistent state after failure, reset it | ||||
| addrman.Clear(); | addrman.Clear(); | ||||
| LogPrintf("Invalid or missing peers.dat; recreating\n"); | LogPrintf("Invalid or missing peers.dat; recreating\n"); | ||||
| DumpAddresses(); | DumpAddresses(); | ||||
| } | } | ||||
| } | } | ||||
| if (clientInterface) { | if (clientInterface) { | ||||
| clientInterface->InitMessage(_("Loading banlist...")); | clientInterface->InitMessage(_("Loading banlist...")); | ||||
| } | } | ||||
| // Load addresses from banlist.dat | // Load addresses from banlist.dat | ||||
| nStart = GetTimeMillis(); | nStart = GetTimeMillis(); | ||||
| CBanDB bandb; | CBanDB bandb(config->GetChainParams()); | ||||
| banmap_t banmap; | banmap_t banmap; | ||||
| if (bandb.Read(banmap)) { | if (bandb.Read(banmap)) { | ||||
| // thread save setter | // thread save setter | ||||
| SetBanned(banmap); | SetBanned(banmap); | ||||
| // no need to write down, just read data | // no need to write down, just read data | ||||
| SetBannedSetDirty(false); | SetBannedSetDirty(false); | ||||
| // sweep out unused entries | // sweep out unused entries | ||||
| SweepBanned(); | SweepBanned(); | ||||
| ▲ Show 20 Lines • Show All 656 Lines • Show Last 20 Lines | |||||