aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Dong <[email protected]>2018-10-30 21:13:13 -0700
committerCarl Dong <[email protected]>2019-01-16 13:54:18 -0500
commit1ffa4ce27d4ea6c1067d8984455df97994c7713e (patch)
tree803808d1bc193d25b7955b40a8e989b5c32455d9 /src
parentbanman: add thread annotations and mark members const where possible (diff)
downloaddiscoin-1ffa4ce27d4ea6c1067d8984455df97994c7713e.tar.xz
discoin-1ffa4ce27d4ea6c1067d8984455df97994c7713e.zip
banman: reformulate nBanUtil calculation
Avoid reassigning parameters.
Diffstat (limited to 'src')
-rw-r--r--src/banman.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/banman.cpp b/src/banman.cpp
index dc16aab28..19c8e3752 100644
--- a/src/banman.cpp
+++ b/src/banman.cpp
@@ -104,11 +104,14 @@ void BanMan::Ban(const CSubNet& subNet, const BanReason& banReason, int64_t bant
{
CBanEntry banEntry(GetTime());
banEntry.banReason = banReason;
+
+ int64_t normalized_bantimeoffset = bantimeoffset;
+ bool normalized_sinceUnixEpoch = sinceUnixEpoch;
if (bantimeoffset <= 0) {
- bantimeoffset = m_default_ban_time;
- sinceUnixEpoch = false;
+ normalized_bantimeoffset = m_default_ban_time;
+ normalized_sinceUnixEpoch = false;
}
- banEntry.nBanUntil = (sinceUnixEpoch ? 0 : GetTime()) + bantimeoffset;
+ banEntry.nBanUntil = (normalized_sinceUnixEpoch ? 0 : GetTime()) + normalized_bantimeoffset;
{
LOCK(m_cs_banned);