From 567008d2a0c95bd972f4031f31647c493d1bc2e8 Mon Sep 17 00:00:00 2001 From: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Date: Sat, 12 Sep 2020 17:59:09 +0300 Subject: [PATCH] p2p: Add DumpAnchors() --- src/addrdb.cpp | 7 +++++++ src/addrdb.h | 12 ++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/addrdb.cpp b/src/addrdb.cpp index f3e8a19de2..ca2d66570b 100644 --- a/src/addrdb.cpp +++ b/src/addrdb.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -156,3 +157,9 @@ bool CAddrDB::Read(CAddrMan& addr, CDataStream& ssPeers) } return ret; } + +void DumpAnchors(const fs::path& anchors_db_path, const std::vector& anchors) +{ + LOG_TIME_SECONDS(strprintf("Flush %d outbound block-relay-only peer addresses to anchors.dat", anchors.size())); + SerializeFileDB("anchors", anchors_db_path, anchors); +} diff --git a/src/addrdb.h b/src/addrdb.h index 8410c3776c..614a0c20e3 100644 --- a/src/addrdb.h +++ b/src/addrdb.h @@ -11,9 +11,9 @@ #include #include -#include +#include -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& anchors); + #endif // BITCOIN_ADDRDB_H