aboutsummaryrefslogtreecommitdiff
path: root/src/banman.h
diff options
context:
space:
mode:
authorAndrew Chow <github@achow101.com>2023-11-02 13:49:50 -0400
committerAndrew Chow <github@achow101.com>2023-11-02 14:09:27 -0400
commit0857f2935f90df9c3d303582e5b62a9c8dedd9d7 (patch)
tree2ea6c222b4224aa5c41fff3926f877bf4e396746 /src/banman.h
parent2e9454a633462604cfafdf685cc9b3ad7d0e56ef (diff)
parent37d150d8c5ffcb2bddcd99951a739e97571194c7 (diff)
downloadbitcoin-0857f2935f90df9c3d303582e5b62a9c8dedd9d7.tar.xz
Merge bitcoin/bitcoin#24097: Replace RecursiveMutex m_cs_banned with Mutex, and rename it
37d150d8c5ffcb2bddcd99951a739e97571194c7 refactor: Add more negative `!m_banned_mutex` thread safety annotations (Hennadii Stepanov) 0fb29087080a4e60d7c709ff5edf14e830ef3a69 refactor: replace RecursiveMutex m_banned_mutex with Mutex (w0xlt) 784c316f9cb664c9577cbfed1873bae573efd1b4 scripted-diff: rename m_cs_banned -> m_banned_mutex (w0xlt) 46709c5f27bf6cbc8eba1298b04bd079da2cdded refactor: Get rid of `BanMan::SetBannedSetDirty()` (Hennadii Stepanov) d88c0d8440cf640ef4f2c7a40b8b8b31bfd38f23 refactor: Get rid of `BanMan::BannedSetIsDirty()` (Hennadii Stepanov) Pull request description: This PR is an alternative to bitcoin/bitcoin#24092. Last two commit have been cherry-picked from the latter. ACKs for top commit: maflcko: ACK 37d150d8c5ffcb2bddcd99951a739e97571194c7 🎾 achow101: ACK 37d150d8c5ffcb2bddcd99951a739e97571194c7 theStack: Code-review ACK 37d150d8c5ffcb2bddcd99951a739e97571194c7 vasild: ACK 37d150d8c5ffcb2bddcd99951a739e97571194c7 Tree-SHA512: 5e9d40101a09af6e0645a6ede67432ea68631a1b960f9e6af0ad07415ca7718a30fcc1aad5182d1d5265dc54c26aba2008fc9973840255c09adbab8fedf10075
Diffstat (limited to 'src/banman.h')
-rw-r--r--src/banman.h37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/banman.h b/src/banman.h
index 5a5f5677b0..c6df7ec3c3 100644
--- a/src/banman.h
+++ b/src/banman.h
@@ -60,40 +60,37 @@ class BanMan
public:
~BanMan();
BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t default_ban_time);
- void Ban(const CNetAddr& net_addr, int64_t ban_time_offset = 0, bool since_unix_epoch = false);
- void Ban(const CSubNet& sub_net, int64_t ban_time_offset = 0, bool since_unix_epoch = false);
- void Discourage(const CNetAddr& net_addr);
- void ClearBanned();
+ void Ban(const CNetAddr& net_addr, int64_t ban_time_offset = 0, bool since_unix_epoch = false) EXCLUSIVE_LOCKS_REQUIRED(!m_banned_mutex);
+ void Ban(const CSubNet& sub_net, int64_t ban_time_offset = 0, bool since_unix_epoch = false) EXCLUSIVE_LOCKS_REQUIRED(!m_banned_mutex);
+ void Discourage(const CNetAddr& net_addr) EXCLUSIVE_LOCKS_REQUIRED(!m_banned_mutex);
+ void ClearBanned() EXCLUSIVE_LOCKS_REQUIRED(!m_banned_mutex);
//! Return whether net_addr is banned
- bool IsBanned(const CNetAddr& net_addr);
+ bool IsBanned(const CNetAddr& net_addr) EXCLUSIVE_LOCKS_REQUIRED(!m_banned_mutex);
//! Return whether sub_net is exactly banned
- bool IsBanned(const CSubNet& sub_net);
+ bool IsBanned(const CSubNet& sub_net) EXCLUSIVE_LOCKS_REQUIRED(!m_banned_mutex);
//! Return whether net_addr is discouraged.
- bool IsDiscouraged(const CNetAddr& net_addr);
+ bool IsDiscouraged(const CNetAddr& net_addr) EXCLUSIVE_LOCKS_REQUIRED(!m_banned_mutex);
- bool Unban(const CNetAddr& net_addr);
- bool Unban(const CSubNet& sub_net);
- void GetBanned(banmap_t& banmap);
- void DumpBanlist();
+ bool Unban(const CNetAddr& net_addr) EXCLUSIVE_LOCKS_REQUIRED(!m_banned_mutex);
+ bool Unban(const CSubNet& sub_net) EXCLUSIVE_LOCKS_REQUIRED(!m_banned_mutex);
+ void GetBanned(banmap_t& banmap) EXCLUSIVE_LOCKS_REQUIRED(!m_banned_mutex);
+ void DumpBanlist() EXCLUSIVE_LOCKS_REQUIRED(!m_banned_mutex);
private:
- void LoadBanlist() EXCLUSIVE_LOCKS_REQUIRED(!m_cs_banned);
- bool BannedSetIsDirty();
- //!set the "dirty" flag for the banlist
- void SetBannedSetDirty(bool dirty = true);
+ void LoadBanlist() EXCLUSIVE_LOCKS_REQUIRED(!m_banned_mutex);
//!clean unused entries (if bantime has expired)
- void SweepBanned() EXCLUSIVE_LOCKS_REQUIRED(m_cs_banned);
+ void SweepBanned() EXCLUSIVE_LOCKS_REQUIRED(m_banned_mutex);
- RecursiveMutex m_cs_banned;
- banmap_t m_banned GUARDED_BY(m_cs_banned);
- bool m_is_dirty GUARDED_BY(m_cs_banned){false};
+ Mutex m_banned_mutex;
+ banmap_t m_banned GUARDED_BY(m_banned_mutex);
+ bool m_is_dirty GUARDED_BY(m_banned_mutex){false};
CClientUIInterface* m_client_interface = nullptr;
CBanDB m_ban_db;
const int64_t m_default_ban_time;
- CRollingBloomFilter m_discouraged GUARDED_BY(m_cs_banned) {50000, 0.000001};
+ CRollingBloomFilter m_discouraged GUARDED_BY(m_banned_mutex) {50000, 0.000001};
};
#endif // BITCOIN_BANMAN_H