LCOV - code coverage report
Current view: top level - src - addrdb.h (source / functions) Hit Total Coverage
Test: fuzz_coverage.info Lines: 0 1 0.0 %
Date: 2023-11-10 23:46:46 Functions: 0 1 0.0 %
Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : // Copyright (c) 2009-2010 Satoshi Nakamoto
       2                 :            : // Copyright (c) 2009-2021 The Bitcoin Core developers
       3                 :            : // Distributed under the MIT software license, see the accompanying
       4                 :            : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       5                 :            : 
       6                 :            : #ifndef BITCOIN_ADDRDB_H
       7                 :            : #define BITCOIN_ADDRDB_H
       8                 :            : 
       9                 :            : #include <net_types.h>
      10                 :            : #include <util/fs.h>
      11                 :            : #include <util/result.h>
      12                 :            : 
      13                 :            : #include <memory>
      14                 :            : #include <vector>
      15                 :            : 
      16                 :            : class ArgsManager;
      17                 :            : class AddrMan;
      18                 :            : class CAddress;
      19                 :            : class DataStream;
      20                 :            : class NetGroupManager;
      21                 :            : 
      22                 :            : /** Only used by tests. */
      23                 :            : void ReadFromStream(AddrMan& addr, DataStream& ssPeers);
      24                 :            : 
      25                 :            : bool DumpPeerAddresses(const ArgsManager& args, const AddrMan& addr);
      26                 :            : 
      27                 :            : /** Access to the banlist database (banlist.json) */
      28                 :          0 : class CBanDB
      29                 :            : {
      30                 :            : private:
      31                 :            :     /**
      32                 :            :      * JSON key under which the data is stored in the json database.
      33                 :            :      */
      34                 :            :     static constexpr const char* JSON_KEY = "banned_nets";
      35                 :            : 
      36                 :            :     const fs::path m_banlist_dat;
      37                 :            :     const fs::path m_banlist_json;
      38                 :            : public:
      39                 :            :     explicit CBanDB(fs::path ban_list_path);
      40                 :            :     bool Write(const banmap_t& banSet);
      41                 :            : 
      42                 :            :     /**
      43                 :            :      * Read the banlist from disk.
      44                 :            :      * @param[out] banSet The loaded list. Set if `true` is returned, otherwise it is left
      45                 :            :      * in an undefined state.
      46                 :            :      * @return true on success
      47                 :            :      */
      48                 :            :     bool Read(banmap_t& banSet);
      49                 :            : };
      50                 :            : 
      51                 :            : /** Returns an error string on failure */
      52                 :            : util::Result<std::unique_ptr<AddrMan>> LoadAddrman(const NetGroupManager& netgroupman, const ArgsManager& args);
      53                 :            : 
      54                 :            : /**
      55                 :            :  * Dump the anchor IP address database (anchors.dat)
      56                 :            :  *
      57                 :            :  * Anchors are last known outgoing block-relay-only peers that are
      58                 :            :  * tried to re-connect to on startup.
      59                 :            :  */
      60                 :            : void DumpAnchors(const fs::path& anchors_db_path, const std::vector<CAddress>& anchors);
      61                 :            : 
      62                 :            : /**
      63                 :            :  * Read the anchor IP address database (anchors.dat)
      64                 :            :  *
      65                 :            :  * Deleting anchors.dat is intentional as it avoids renewed peering to anchors after
      66                 :            :  * an unclean shutdown and thus potential exploitation of the anchor peer policy.
      67                 :            :  */
      68                 :            : std::vector<CAddress> ReadAnchors(const fs::path& anchors_db_path);
      69                 :            : 
      70                 :            : #endif // BITCOIN_ADDRDB_H

Generated by: LCOV version 1.14