-
Notifications
You must be signed in to change notification settings - Fork 37.7k
banlist updates #6371
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
banlist updates #6371
Conversation
LogPrintf("Invalid or missing banlist.dat; recreating\n"); | ||
} else { | ||
CNode::SetBanned(banmap); // thread save setter | ||
CNode::SetBannedSetDirty(false); // no need to write down, just read data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line CNode::SetBannedSetDirty(false);
should be called even if bandb.Read(ban map)
failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As written in the code, it is false as default, so it isn't dirty, because no functions were called that change the flag :).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it's default false (net.cppL448)? I would recommend to call
CNode::SetBannedSetDirty(false);` when we start up a node. There is no case where the list can be "dirty" in this state.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO an not explicitly initialized bool defaults to false (0).
This call here (where the comment is), is necessary because we just read and didn't change anything, as the CNode::SetBanned()
call sets setBannedIsDirty = true
.
utACK (mind the nit above). |
} | ||
|
||
//try to read stored banlist | ||
uiInterface.InitMessage(_("Loading banned addresses...")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jonasschnelli Should this be ips/subnets
rather than addresses
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm.... it could be _("Loading banned addresses/subnets...")
but if we be particular about this: a subnet defines an amount of "addresses". But i don't care about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Loading ban list..."
@jonasschnelli Would be nice if you could test this pull and review commit 4, so this can get merged soon. I've got further small fixes for this but don't want to blow up this pull ;). |
@jonasschnelli Ping |
@jonasschnelli @laanwj Can we get this in please? |
@jonasschnelli Too sad you couldn't yet ACK this, mind taking a look? |
banmap.size(), GetTimeMillis() - nStart); | ||
LogPrint("net", "Flushed %d banned node ips/subnets to banlist.dat %dms\n", | ||
banmap.size(), GetTimeMillis() - nStart); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General principle: Code like "if (!dirty) return;" reduces the indentation level for the standard case, and makes the code more readable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So you would have written?
if (bandb.Write(banmap)) CNode::SetBannedSetDirty(false);
Or are you talking about:
LogPrint("net", "Flushed %d banned node ips/subnets to banlist.dat %dms\n", banmap.size(), GetTimeMillis() - Start);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it was if (!CNode::BannedSetIsDirty()) return;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LOL, got it now ;)... thanks for that hint.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ut ACK |
@jgarzik Thanks for review :). |
@@ -555,11 +555,13 @@ void CNode::SweepBanned() | |||
banmap_t::iterator it = setBanned.begin(); | |||
while(it != setBanned.end()) | |||
{ | |||
CSubNet subNet = (*it).first; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not used a single time currently in net.cpp with (*it), so I'll leave that. But I'm open for further comments on this.
utACK |
@Diapolo re-reviewed commit-by-commit. utACK / concept ACK (683275e) |
Seems unrelated!?
|
- move the SetBannedSetDirty(false) call from DumpData() into DumpBanlist() - ensure we only set false, if the write succeeded
- only start working on/with banlist data, if reading in the banlist from disk didn't fail - as CNode::setBannedIsDirty is false (default) when reading fails, we don't need to explicitly set it to false to prevent writing banlist.dat in that case either
- to match the peers.dat handling also supply a debug.log entry for how many entries were loaded from banlist.dat and how long it took - add a GUI init message for loading the banlist (same as with peers.dat) - move the same message for peers.dat upwards in the code, to be able to reuse the timing variable nStart and also just log, if our read from peers.dat didn't fail
- allows CNode::SweepBanned() to run, even if !CNode::BannedSetIsDirty(), because if nBanUntil is over we want the ban to be disabled for these nodes
What is holding up the merge here? |
utACK |
All utACK but I can't really see from the code changes whether it's correct. No one has tested this yet? Or is this covered by the current tests? |
Well, I tested it :-D and I also was aware of these things while @jonasschnelli implemented it, but AFAIK no one was interrested in fixing/improving at that time... |
utACK. A unittest would be nice (or extending the rpc test with some banlist.dat checking on file basis). |
banlist: update set dirty to be more fine grained
banlist: better handling of banlist in StartNode()
disk didn't fail
don't need to explicitly set it to false to prevent writing banlist.dat
in that case either
banlist: add more banlist infos to log / add GUI signal
many entries were loaded from banlist.dat and how long it took
reuse the timing variable nStart and also just log, if our read from
peers.dat didn't fail
banlist (bugfix): allow CNode::SweepBanned() to run on interval
because if nBanUntil is over we want the ban to be disabled for these
nodes