Skip to content
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

Merged
merged 10 commits into from
Aug 14, 2024

Conversation

317787106
Copy link
Contributor

@317787106 317787106 commented Aug 7, 2024

What does this PR do?

  • add some logs for isolated2 disconnection
  • only disconnect from broadcasting peers when node is in LAN or 'isOpenFullTcpDisconnect' is true.

Why are these changes required?

This PR has been tested by:

  • Unit Tests
  • Manual Testing

Follow up

Extra details

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,
Copy link
Contributor

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.

Copy link
Contributor Author

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()) {
Copy link
Contributor

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?

Copy link
Contributor Author

@317787106 317787106 Aug 13, 2024

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().

Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ">=", not ">".

Copy link
Contributor

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 '>'

Copy link
Contributor Author

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.

Copy link
Contributor

@fyyhtx fyyhtx Aug 13, 2024

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?

Copy link
Contributor Author

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.

@lvs007 lvs007 changed the title feat(net): add some log for isolated2 disconnection feat(net): add some log and adjustment of disconnection strategy Aug 14, 2024
@lvs007 lvs007 merged commit 424a3dd into tronprotocol:release_v4.7.6 Aug 14, 2024
5 checks passed
@lvs007 lvs007 changed the title feat(net): add some log and adjustment of disconnection strategy feat(net): add some logs and adjustment of disconnection strategy Aug 14, 2024
@317787106 317787106 changed the title feat(net): add some logs and adjustment of disconnection strategy feat(net): add logs for isolated2 and adjust disconnection strategy Aug 14, 2024
@317787106 317787106 changed the title feat(net): add logs for isolated2 and adjust disconnection strategy feat(net): add logs and adjust disconnection strategy Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants