@@ -16,7 +16,7 @@ BanMan::BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t
16
16
{
17
17
if (m_client_interface) m_client_interface->InitMessage (_ (" Loading banlist..." ));
18
18
19
- int64_t nStart = GetTimeMillis ();
19
+ int64_t n_start = GetTimeMillis ();
20
20
m_is_dirty = false ;
21
21
banmap_t banmap;
22
22
if (m_ban_db.Read (banmap)) {
@@ -25,7 +25,7 @@ BanMan::BanMan(fs::path ban_file, CClientUIInterface* client_interface, int64_t
25
25
SweepBanned (); // sweep out unused entries
26
26
27
27
LogPrint (BCLog::NET, " Loaded %d banned node ips/subnets from banlist.dat %dms\n " ,
28
- banmap.size (), GetTimeMillis () - nStart );
28
+ banmap.size (), GetTimeMillis () - n_start );
29
29
} else {
30
30
LogPrintf (" Invalid or missing banlist.dat; recreating\n " );
31
31
SetBannedSetDirty (true ); // force write
@@ -44,7 +44,7 @@ void BanMan::DumpBanlist()
44
44
45
45
if (!BannedSetIsDirty ()) return ;
46
46
47
- int64_t nStart = GetTimeMillis ();
47
+ int64_t n_start = GetTimeMillis ();
48
48
49
49
banmap_t banmap;
50
50
GetBanned (banmap);
@@ -53,7 +53,7 @@ void BanMan::DumpBanlist()
53
53
}
54
54
55
55
LogPrint (BCLog::NET, " Flushed %d banned node ips/subnets to banlist.dat %dms\n " ,
56
- banmap.size (), GetTimeMillis () - nStart );
56
+ banmap.size (), GetTimeMillis () - n_start );
57
57
}
58
58
59
59
void BanMan::ClearBanned ()
@@ -67,119 +67,119 @@ void BanMan::ClearBanned()
67
67
if (m_client_interface) m_client_interface->BannedListChanged ();
68
68
}
69
69
70
- bool BanMan::IsBanned (CNetAddr netAddr )
70
+ bool BanMan::IsBanned (CNetAddr net_addr )
71
71
{
72
72
LOCK (m_cs_banned);
73
73
for (const auto & it : m_banned) {
74
- CSubNet subNet = it.first ;
75
- CBanEntry banEntry = it.second ;
74
+ CSubNet sub_net = it.first ;
75
+ CBanEntry ban_entry = it.second ;
76
76
77
- if (subNet .Match (netAddr ) && GetTime () < banEntry .nBanUntil ) {
77
+ if (sub_net .Match (net_addr ) && GetTime () < ban_entry .nBanUntil ) {
78
78
return true ;
79
79
}
80
80
}
81
81
return false ;
82
82
}
83
83
84
- bool BanMan::IsBanned (CSubNet subNet )
84
+ bool BanMan::IsBanned (CSubNet sub_net )
85
85
{
86
86
LOCK (m_cs_banned);
87
- banmap_t ::iterator i = m_banned.find (subNet );
87
+ banmap_t ::iterator i = m_banned.find (sub_net );
88
88
if (i != m_banned.end ()) {
89
- CBanEntry banEntry = (*i).second ;
90
- if (GetTime () < banEntry .nBanUntil ) {
89
+ CBanEntry ban_entry = (*i).second ;
90
+ if (GetTime () < ban_entry .nBanUntil ) {
91
91
return true ;
92
92
}
93
93
}
94
94
return false ;
95
95
}
96
96
97
- void BanMan::Ban (const CNetAddr& netAddr , const BanReason& banReason , int64_t bantimeoffset , bool sinceUnixEpoch )
97
+ void BanMan::Ban (const CNetAddr& net_addr , const BanReason& ban_reason , int64_t ban_time_offset , bool since_unix_epoch )
98
98
{
99
- CSubNet subNet (netAddr );
100
- Ban (subNet, banReason, bantimeoffset, sinceUnixEpoch );
99
+ CSubNet sub_net (net_addr );
100
+ Ban (sub_net, ban_reason, ban_time_offset, since_unix_epoch );
101
101
}
102
102
103
- void BanMan::Ban (const CSubNet& subNet , const BanReason& banReason , int64_t bantimeoffset , bool sinceUnixEpoch )
103
+ void BanMan::Ban (const CSubNet& sub_net , const BanReason& ban_reason , int64_t ban_time_offset , bool since_unix_epoch )
104
104
{
105
- CBanEntry banEntry (GetTime (), banReason );
105
+ CBanEntry ban_entry (GetTime (), ban_reason );
106
106
107
- int64_t normalized_bantimeoffset = bantimeoffset ;
108
- bool normalized_sinceUnixEpoch = sinceUnixEpoch ;
109
- if (bantimeoffset <= 0 ) {
110
- normalized_bantimeoffset = m_default_ban_time;
111
- normalized_sinceUnixEpoch = false ;
107
+ int64_t normalized_ban_time_offset = ban_time_offset ;
108
+ bool normalized_since_unix_epoch = since_unix_epoch ;
109
+ if (ban_time_offset <= 0 ) {
110
+ normalized_ban_time_offset = m_default_ban_time;
111
+ normalized_since_unix_epoch = false ;
112
112
}
113
- banEntry .nBanUntil = (normalized_sinceUnixEpoch ? 0 : GetTime ()) + normalized_bantimeoffset ;
113
+ ban_entry .nBanUntil = (normalized_since_unix_epoch ? 0 : GetTime ()) + normalized_ban_time_offset ;
114
114
115
115
{
116
116
LOCK (m_cs_banned);
117
- if (m_banned[subNet ].nBanUntil < banEntry .nBanUntil ) {
118
- m_banned[subNet ] = banEntry ;
117
+ if (m_banned[sub_net ].nBanUntil < ban_entry .nBanUntil ) {
118
+ m_banned[sub_net ] = ban_entry ;
119
119
m_is_dirty = true ;
120
120
} else
121
121
return ;
122
122
}
123
123
if (m_client_interface) m_client_interface->BannedListChanged ();
124
124
125
125
// store banlist to disk immediately if user requested ban
126
- if (banReason == BanReasonManuallyAdded) DumpBanlist ();
126
+ if (ban_reason == BanReasonManuallyAdded) DumpBanlist ();
127
127
}
128
128
129
- bool BanMan::Unban (const CNetAddr& netAddr )
129
+ bool BanMan::Unban (const CNetAddr& net_addr )
130
130
{
131
- CSubNet subNet (netAddr );
132
- return Unban (subNet );
131
+ CSubNet sub_net (net_addr );
132
+ return Unban (sub_net );
133
133
}
134
134
135
- bool BanMan::Unban (const CSubNet& subNet )
135
+ bool BanMan::Unban (const CSubNet& sub_net )
136
136
{
137
137
{
138
138
LOCK (m_cs_banned);
139
- if (m_banned.erase (subNet ) == 0 ) return false ;
139
+ if (m_banned.erase (sub_net ) == 0 ) return false ;
140
140
m_is_dirty = true ;
141
141
}
142
142
if (m_client_interface) m_client_interface->BannedListChanged ();
143
143
DumpBanlist (); // store banlist to disk immediately
144
144
return true ;
145
145
}
146
146
147
- void BanMan::GetBanned (banmap_t & banMap )
147
+ void BanMan::GetBanned (banmap_t & banmap )
148
148
{
149
149
LOCK (m_cs_banned);
150
150
// Sweep the banlist so expired bans are not returned
151
151
SweepBanned ();
152
- banMap = m_banned; // create a thread safe copy
152
+ banmap = m_banned; // create a thread safe copy
153
153
}
154
154
155
- void BanMan::SetBanned (const banmap_t & banMap )
155
+ void BanMan::SetBanned (const banmap_t & banmap )
156
156
{
157
157
LOCK (m_cs_banned);
158
- m_banned = banMap ;
158
+ m_banned = banmap ;
159
159
m_is_dirty = true ;
160
160
}
161
161
162
162
void BanMan::SweepBanned ()
163
163
{
164
164
int64_t now = GetTime ();
165
- bool notifyUI = false ;
165
+ bool notify_ui = false ;
166
166
{
167
167
LOCK (m_cs_banned);
168
168
banmap_t ::iterator it = m_banned.begin ();
169
169
while (it != m_banned.end ()) {
170
- CSubNet subNet = (*it).first ;
171
- CBanEntry banEntry = (*it).second ;
172
- if (now > banEntry .nBanUntil ) {
170
+ CSubNet sub_net = (*it).first ;
171
+ CBanEntry ban_entry = (*it).second ;
172
+ if (now > ban_entry .nBanUntil ) {
173
173
m_banned.erase (it++);
174
174
m_is_dirty = true ;
175
- notifyUI = true ;
176
- LogPrint (BCLog::NET, " %s: Removed banned node ip/subnet from banlist.dat: %s\n " , __func__, subNet .ToString ());
175
+ notify_ui = true ;
176
+ LogPrint (BCLog::NET, " %s: Removed banned node ip/subnet from banlist.dat: %s\n " , __func__, sub_net .ToString ());
177
177
} else
178
178
++it;
179
179
}
180
180
}
181
181
// update UI
182
- if (notifyUI && m_client_interface) {
182
+ if (notify_ui && m_client_interface) {
183
183
m_client_interface->BannedListChanged ();
184
184
}
185
185
}
0 commit comments