Skip to content

Commit 1ffa4ce

Browse files
committed
banman: reformulate nBanUtil calculation
Avoid reassigning parameters.
1 parent daae598 commit 1ffa4ce

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/banman.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,14 @@ void BanMan::Ban(const CSubNet& subNet, const BanReason& banReason, int64_t bant
104104
{
105105
CBanEntry banEntry(GetTime());
106106
banEntry.banReason = banReason;
107+
108+
int64_t normalized_bantimeoffset = bantimeoffset;
109+
bool normalized_sinceUnixEpoch = sinceUnixEpoch;
107110
if (bantimeoffset <= 0) {
108-
bantimeoffset = m_default_ban_time;
109-
sinceUnixEpoch = false;
111+
normalized_bantimeoffset = m_default_ban_time;
112+
normalized_sinceUnixEpoch = false;
110113
}
111-
banEntry.nBanUntil = (sinceUnixEpoch ? 0 : GetTime()) + bantimeoffset;
114+
banEntry.nBanUntil = (normalized_sinceUnixEpoch ? 0 : GetTime()) + normalized_bantimeoffset;
112115

113116
{
114117
LOCK(m_cs_banned);

0 commit comments

Comments
 (0)