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

refactor: cat replenish polish #14

Merged
merged 2 commits into from Feb 11, 2020
Merged

refactor: cat replenish polish #14

merged 2 commits into from Feb 11, 2020

Conversation

PaulBernier
Copy link
Contributor

Spent sometime carefully reading the catReplenish function as it looks a pretty important functions. Only found some minor polish details that help the readability and comprehension, to me at least, so we can discuss it.

  • Added a comment about the sources of new peers and their priority order
  • I changed deny for canDial. It allows to remove some negation in condition and have condition read if canDial then add to the list of endpoints to try to connect to instead of having a guard statement with immediate continue. Matter of style but, I think it's slightly better...
  • I moved some small block of codes that were declared "too early", for instance minReseed declaration happening before the special peers handling while not being until after it. (same for the declaration of attemptsLimit)
  • Moved peer.lastPeerSend as close as possible to the actual send, for consistency


if uint(c.peers.Total()) >= c.net.conf.Target {
break
}
}

connect = nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I was wondering if this nil assignment is actually necessary

Copy link
Owner

Choose a reason for hiding this comment

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

It is not necessary

Copy link
Owner

@WhoSoup WhoSoup left a comment

Choose a reason for hiding this comment

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

Spent sometime carefully reading the catReplenish function as it looks a pretty important functions.

This function is already the third or fourth rework. I constantly feel like there's an easier way to do it all but I can't think of one, You not finding anything substantially wrong with it makes me feel better about it.

I like these changes.


if uint(c.peers.Total()) >= c.net.conf.Target {
break
}
}

connect = nil
Copy link
Owner

Choose a reason for hiding this comment

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

It is not necessary

@WhoSoup WhoSoup merged commit 2f77f66 into WhoSoup:develop Feb 11, 2020
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.

None yet

2 participants