12
12
13
13
14
14
BanMan::BanMan (fs::path ban_file, CClientUIInterface* client_interface, int64_t default_ban_time)
15
- : clientInterface (client_interface), m_ban_db(std::move(ban_file)), m_default_ban_time(default_ban_time)
15
+ : m_client_interface (client_interface), m_ban_db(std::move(ban_file)), m_default_ban_time(default_ban_time)
16
16
{
17
- if (clientInterface) clientInterface ->InitMessage (_ (" Loading banlist..." ));
17
+ if (m_client_interface) m_client_interface ->InitMessage (_ (" Loading banlist..." ));
18
18
19
19
int64_t nStart = GetTimeMillis ();
20
- setBannedIsDirty = false ;
20
+ m_is_dirty = false ;
21
21
banmap_t banmap;
22
22
if (m_ban_db.Read (banmap)) {
23
23
SetBanned (banmap); // thread save setter
@@ -59,18 +59,18 @@ void BanMan::DumpBanlist()
59
59
void BanMan::ClearBanned ()
60
60
{
61
61
{
62
- LOCK (cs_setBanned );
63
- setBanned .clear ();
64
- setBannedIsDirty = true ;
62
+ LOCK (m_cs_banned );
63
+ m_banned .clear ();
64
+ m_is_dirty = true ;
65
65
}
66
66
DumpBanlist (); // store banlist to disk
67
- if (clientInterface) clientInterface ->BannedListChanged ();
67
+ if (m_client_interface) m_client_interface ->BannedListChanged ();
68
68
}
69
69
70
70
bool BanMan::IsBanned (CNetAddr netAddr)
71
71
{
72
- LOCK (cs_setBanned );
73
- for (const auto & it : setBanned ) {
72
+ LOCK (m_cs_banned );
73
+ for (const auto & it : m_banned ) {
74
74
CSubNet subNet = it.first ;
75
75
CBanEntry banEntry = it.second ;
76
76
@@ -83,9 +83,9 @@ bool BanMan::IsBanned(CNetAddr netAddr)
83
83
84
84
bool BanMan::IsBanned (CSubNet subNet)
85
85
{
86
- LOCK (cs_setBanned );
87
- banmap_t ::iterator i = setBanned .find (subNet);
88
- if (i != setBanned .end ()) {
86
+ LOCK (m_cs_banned );
87
+ banmap_t ::iterator i = m_banned .find (subNet);
88
+ if (i != m_banned .end ()) {
89
89
CBanEntry banEntry = (*i).second ;
90
90
if (GetTime () < banEntry.nBanUntil ) {
91
91
return true ;
@@ -111,14 +111,14 @@ void BanMan::Ban(const CSubNet& subNet, const BanReason& banReason, int64_t bant
111
111
banEntry.nBanUntil = (sinceUnixEpoch ? 0 : GetTime ()) + bantimeoffset;
112
112
113
113
{
114
- LOCK (cs_setBanned );
115
- if (setBanned [subNet].nBanUntil < banEntry.nBanUntil ) {
116
- setBanned [subNet] = banEntry;
117
- setBannedIsDirty = true ;
114
+ LOCK (m_cs_banned );
115
+ if (m_banned [subNet].nBanUntil < banEntry.nBanUntil ) {
116
+ m_banned [subNet] = banEntry;
117
+ m_is_dirty = true ;
118
118
} else
119
119
return ;
120
120
}
121
- if (clientInterface) clientInterface ->BannedListChanged ();
121
+ if (m_client_interface) m_client_interface ->BannedListChanged ();
122
122
123
123
// store banlist to disk immediately if user requested ban
124
124
if (banReason == BanReasonManuallyAdded) DumpBanlist ();
@@ -133,63 +133,63 @@ bool BanMan::Unban(const CNetAddr& netAddr)
133
133
bool BanMan::Unban (const CSubNet& subNet)
134
134
{
135
135
{
136
- LOCK (cs_setBanned );
137
- if (setBanned .erase (subNet) == 0 ) return false ;
138
- setBannedIsDirty = true ;
136
+ LOCK (m_cs_banned );
137
+ if (m_banned .erase (subNet) == 0 ) return false ;
138
+ m_is_dirty = true ;
139
139
}
140
- if (clientInterface) clientInterface ->BannedListChanged ();
140
+ if (m_client_interface) m_client_interface ->BannedListChanged ();
141
141
DumpBanlist (); // store banlist to disk immediately
142
142
return true ;
143
143
}
144
144
145
145
void BanMan::GetBanned (banmap_t & banMap)
146
146
{
147
- LOCK (cs_setBanned );
147
+ LOCK (m_cs_banned );
148
148
// Sweep the banlist so expired bans are not returned
149
149
SweepBanned ();
150
- banMap = setBanned ; // create a thread safe copy
150
+ banMap = m_banned ; // create a thread safe copy
151
151
}
152
152
153
153
void BanMan::SetBanned (const banmap_t & banMap)
154
154
{
155
- LOCK (cs_setBanned );
156
- setBanned = banMap;
157
- setBannedIsDirty = true ;
155
+ LOCK (m_cs_banned );
156
+ m_banned = banMap;
157
+ m_is_dirty = true ;
158
158
}
159
159
160
160
void BanMan::SweepBanned ()
161
161
{
162
162
int64_t now = GetTime ();
163
163
bool notifyUI = false ;
164
164
{
165
- LOCK (cs_setBanned );
166
- banmap_t ::iterator it = setBanned .begin ();
167
- while (it != setBanned .end ()) {
165
+ LOCK (m_cs_banned );
166
+ banmap_t ::iterator it = m_banned .begin ();
167
+ while (it != m_banned .end ()) {
168
168
CSubNet subNet = (*it).first ;
169
169
CBanEntry banEntry = (*it).second ;
170
170
if (now > banEntry.nBanUntil ) {
171
- setBanned .erase (it++);
172
- setBannedIsDirty = true ;
171
+ m_banned .erase (it++);
172
+ m_is_dirty = true ;
173
173
notifyUI = true ;
174
174
LogPrint (BCLog::NET, " %s: Removed banned node ip/subnet from banlist.dat: %s\n " , __func__, subNet.ToString ());
175
175
} else
176
176
++it;
177
177
}
178
178
}
179
179
// update UI
180
- if (notifyUI && clientInterface ) {
181
- clientInterface ->BannedListChanged ();
180
+ if (notifyUI && m_client_interface ) {
181
+ m_client_interface ->BannedListChanged ();
182
182
}
183
183
}
184
184
185
185
bool BanMan::BannedSetIsDirty ()
186
186
{
187
- LOCK (cs_setBanned );
188
- return setBannedIsDirty ;
187
+ LOCK (m_cs_banned );
188
+ return m_is_dirty ;
189
189
}
190
190
191
191
void BanMan::SetBannedSetDirty (bool dirty)
192
192
{
193
- LOCK (cs_setBanned ); // reuse setBanned lock for the setBannedIsDirty flag
194
- setBannedIsDirty = dirty;
193
+ LOCK (m_cs_banned ); // reuse m_banned lock for the m_is_dirty flag
194
+ m_is_dirty = dirty;
195
195
}
0 commit comments