Skip to content

Commit 567008d

Browse files
committed
p2p: Add DumpAnchors()
1 parent 12a1c3a commit 567008d

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/addrdb.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <clientversion.h>
1111
#include <cstdint>
1212
#include <hash.h>
13+
#include <logging/timer.h>
1314
#include <random.h>
1415
#include <streams.h>
1516
#include <tinyformat.h>
@@ -156,3 +157,9 @@ bool CAddrDB::Read(CAddrMan& addr, CDataStream& ssPeers)
156157
}
157158
return ret;
158159
}
160+
161+
void DumpAnchors(const fs::path& anchors_db_path, const std::vector<CAddress>& anchors)
162+
{
163+
LOG_TIME_SECONDS(strprintf("Flush %d outbound block-relay-only peer addresses to anchors.dat", anchors.size()));
164+
SerializeFileDB("anchors", anchors_db_path, anchors);
165+
}

src/addrdb.h

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111
#include <serialize.h>
1212

1313
#include <string>
14-
#include <map>
14+
#include <vector>
1515

16-
class CSubNet;
16+
class CAddress;
1717
class CAddrMan;
1818
class CDataStream;
1919

@@ -73,4 +73,12 @@ class CBanDB
7373
bool Read(banmap_t& banSet);
7474
};
7575

76+
/**
77+
* Dump the anchor IP address database (anchors.dat)
78+
*
79+
* Anchors are last known outgoing block-relay-only peers that are
80+
* tried to re-connect to on startup.
81+
*/
82+
void DumpAnchors(const fs::path& anchors_db_path, const std::vector<CAddress>& anchors);
83+
7684
#endif // BITCOIN_ADDRDB_H

0 commit comments

Comments
 (0)