Skip to content

Commit

Permalink
p2p: Add DumpAnchors()
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Oct 9, 2020
1 parent 12a1c3a commit 567008d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions src/addrdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);
}
12 changes: 10 additions & 2 deletions src/addrdb.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
#include <serialize.h>

#include <string>
#include <map>
#include <vector>

class CSubNet;
class CAddress;
class CAddrMan;
class CDataStream;

Expand Down Expand Up @@ -73,4 +73,12 @@ class CBanDB
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

0 comments on commit 567008d

Please sign in to comment.