-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(net): add logs and adjust disconnection strategy #5944
feat(net): add logs and adjust disconnection strategy #5944
Conversation
if (peers.size() > disconnectSize) { | ||
peers = peers.subList(0, disconnectSize); | ||
} | ||
peers.forEach(peer -> disconnectFromPeer(peer, ReasonCode.BAD_PROTOCOL)); | ||
logger.info("All peer Size:{}, plan size:{}, candidate size:{}, real size:{}", peerSize, |
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 log will refresh the screen.
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.
No, only isolated node will print this log but this condition is rare. Even in this case, its period is 30 seconds.
// disconnect from the node that has keep inactive for more than inactiveThreshold | ||
// and its lastActiveTime is smallest | ||
int peerSize = tronNetDelegate.getActivePeer().size(); | ||
if (peerSize >= CommonParameter.getInstance().getMinConnections()) { |
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.
Is this conditional statement redundant?
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.
It's not redundant, condition of lan is different: peerSize > CommonParameter.getInstance().getMinActiveConnections().
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 '>', shouldn't lan nodes be '=' in most scenarios?
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.
It's ">=", not ">".
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'm talking about why the comparison in the isLanNode method is '>'
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.
You are right, I will revise it.
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 let's go back to the original question. How do you think about it?
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.
Even it's a lan node, it will disconnect from some nodes only if peerSize >= CommonParameter.getInstance().getMinConnections(). Later condition is more strict. It's not redundant.
What does this PR do?
Why are these changes required?
This PR has been tested by:
Follow up
Extra details