mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 22:42:04 +01:00
p2p: Add ReadAnchors()
This commit is contained in:
parent
567008d2a0
commit
c29272a157
2 changed files with 21 additions and 0 deletions
|
@ -163,3 +163,16 @@ void DumpAnchors(const fs::path& anchors_db_path, const std::vector<CAddress>& a
|
|||
LOG_TIME_SECONDS(strprintf("Flush %d outbound block-relay-only peer addresses to anchors.dat", anchors.size()));
|
||||
SerializeFileDB("anchors", anchors_db_path, anchors);
|
||||
}
|
||||
|
||||
std::vector<CAddress> ReadAnchors(const fs::path& anchors_db_path)
|
||||
{
|
||||
std::vector<CAddress> anchors;
|
||||
if (DeserializeFileDB(anchors_db_path, anchors)) {
|
||||
LogPrintf("Loaded %i addresses from %s\n", anchors.size(), anchors_db_path.filename());
|
||||
} else {
|
||||
anchors.clear();
|
||||
}
|
||||
|
||||
fs::remove(anchors_db_path);
|
||||
return anchors;
|
||||
}
|
||||
|
|
|
@ -81,4 +81,12 @@ public:
|
|||
*/
|
||||
void DumpAnchors(const fs::path& anchors_db_path, const std::vector<CAddress>& anchors);
|
||||
|
||||
/**
|
||||
* Read the anchor IP address database (anchors.dat)
|
||||
*
|
||||
* Deleting anchors.dat is intentional as it avoids renewed peering to anchors after
|
||||
* an unclean shutdown and thus potential exploitation of the anchor peer policy.
|
||||
*/
|
||||
std::vector<CAddress> ReadAnchors(const fs::path& anchors_db_path);
|
||||
|
||||
#endif // BITCOIN_ADDRDB_H
|
||||
|
|
Loading…
Add table
Reference in a new issue