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

Extract common types from sync #7843

Merged
merged 10 commits into from
Nov 18, 2020
Merged

Extract common types from sync #7843

merged 10 commits into from
Nov 18, 2020

Conversation

farazdagi
Copy link
Contributor

@farazdagi farazdagi commented Nov 17, 2020

What type of PR is this?

Other/Refactoring

What does this PR do? Why is it needed?

  • Extracted from Peer status peer scorer #7480
  • Peer scorers need access to common sync errors and possible goodbye messages (codes). Particularly, status peer scorer (implemented in Peer status peer scorer #7480, that scorer decides whether peer is good/bad based on validation error).
  • When it comes to goodbye codes - then they are used as an extra elaboration on why peer is considered bad:
// Disconnect from peers that are considered bad by any of the registered scorers.
if s.p2p.Peers().Scorers().IsBadPeer(id) {
	goodbyeCode := p2ptypes.ErrToGoodbyeCode(s.p2p.Peers().Scorers().ValidationError(id))
	if err := s.sendGoodByeAndDisconnect(s.ctx, goodbyeCode, id); err != nil {
		log.Debugf("Error when disconnecting with bad peer: %v", err)
	}
	return
}
  • This PR moves error messages and goodbye codes into p2p/types sub-package (we cannot move to p2p as it will create circular dependency p2p/peers/scorers -> p2p -> p2p/peers/scorers).

Which issues(s) does this PR fix?

N/A

Other notes for review

@farazdagi farazdagi self-assigned this Nov 17, 2020
@farazdagi farazdagi marked this pull request as ready for review November 17, 2020 18:39
@farazdagi farazdagi requested a review from a team as a code owner November 17, 2020 18:39
@farazdagi farazdagi added OK to merge Ready For Review A pull request ready for code review labels Nov 17, 2020
@prylabs-bulldozer prylabs-bulldozer bot merged commit 7735a08 into master Nov 18, 2020
@delete-merged-branch delete-merged-branch bot deleted the extract-p2p-types branch November 18, 2020 04:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ready For Review A pull request ready for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants