diff --git a/src/addrdb.h b/src/addrdb.h --- a/src/addrdb.h +++ b/src/addrdb.h @@ -10,10 +10,10 @@ #include // For banmap_t #include -#include #include +#include -class CSubNet; +class CAddress; class CAddrMan; class CDataStream; class CChainParams; @@ -70,4 +70,14 @@ 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 CChainParams &chainParams, + const fs::path &anchors_db_path, + const std::vector &anchors); + #endif // BITCOIN_ADDRDB_H diff --git a/src/addrdb.cpp b/src/addrdb.cpp --- a/src/addrdb.cpp +++ b/src/addrdb.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -153,3 +154,12 @@ } return ret; } + +void DumpAnchors(const CChainParams &chainParams, + 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(chainParams, "anchors", anchors_db_path, anchors); +}