p2p: Add DumpAnchors()

This commit is contained in:
Hennadii Stepanov 2020-09-12 17:59:09 +03:00
parent 12a1c3ad1a
commit 567008d2a0
No known key found for this signature in database
GPG key ID: 410108112E7EA81F
2 changed files with 17 additions and 2 deletions

View file

@ -10,6 +10,7 @@
#include <clientversion.h>
#include <cstdint>
#include <hash.h>
#include <logging/timer.h>
#include <random.h>
#include <streams.h>
#include <tinyformat.h>
@ -156,3 +157,9 @@ bool CAddrDB::Read(CAddrMan& addr, CDataStream& ssPeers)
}
return ret;
}
void DumpAnchors(const fs::path& anchors_db_path, const std::vector<CAddress>& anchors)
{
LOG_TIME_SECONDS(strprintf("Flush %d outbound block-relay-only peer addresses to anchors.dat", anchors.size()));
SerializeFileDB("anchors", anchors_db_path, anchors);
}

View file

@ -11,9 +11,9 @@
#include <serialize.h>
#include <string>
#include <map>
#include <vector>
class CSubNet;
class CAddress;
class CAddrMan;
class CDataStream;
@ -73,4 +73,12 @@ public:
bool Read(banmap_t& banSet);
};
/**
* Dump the anchor IP address database (anchors.dat)
*
* Anchors are last known outgoing block-relay-only peers that are
* tried to re-connect to on startup.
*/
void DumpAnchors(const fs::path& anchors_db_path, const std::vector<CAddress>& anchors);
#endif // BITCOIN_ADDRDB_H