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

optimization p2p #1242

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ private void changeState(State newState) {
replaceCandidate.changeState(State.Active);
} else if (oldState == State.Alive) {
// ok the old node was better, nothing to do here
nodeManager.table.touchNode(node);
} else {
// wrong state transition
}
Expand All @@ -209,7 +210,10 @@ private void changeState(State newState) {
sendPing();
}
state = newState;
stateChanged(oldState, newState);
if (newState == State.Active) {
stateChanged(oldState, newState);
}
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand why this change doesn't break anything. Why stateChanged() should be called only on Active?

Copy link
Author

@lyy4j lyy4j Dec 4, 2018

Choose a reason for hiding this comment

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

firstly, when the oldest node challenge With the new node,and the oldest node win,we should update the oldest timestap,or else, the node will be get when a new node was added and the bucket was full at next time.

secondly, as the origin code did ,when a node state was change ,the method stateChanged was called every time ,and the method is mainly to establish tcp connect with the peer node ,did it need ?I think when the node in active status, they should start a connect


}

protected void stateChanged(State oldState, State newState) {
Expand Down