-
Notifications
You must be signed in to change notification settings - Fork 474
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
Catchup: NetworkFetcher service to export fetchBlock #4388
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4388 +/- ##
==========================================
- Coverage 55.34% 55.33% -0.02%
==========================================
Files 400 401 +1
Lines 50797 50852 +55
==========================================
+ Hits 28112 28137 +25
- Misses 20311 20335 +24
- Partials 2374 2380 +6
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
… catchup-networkFetch-interface merge master
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.
Looks very good.
Some comments. The major 2 things are:
- The fetcher should have a retry loop
- There are 3 criteria for ranking the peer
catchup/networkFetcher.go
Outdated
) | ||
|
||
// NetworkFetcher is the interface used to export fetchBlock function from universalFetcher | ||
type NetworkFetcher interface { |
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 don't think you need it as an interface and an implementation.
Just use the implementation. You are not using the interface with a different impl.
… catchup-networkFetch-interface merge master
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.
Thanks for addressing the comments.
Getting close. A few more comments.
… catchup-networkFetch-interface
… catchup-networkFetch-interface
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.
Looks great!
Will it be possible to test all or some of the error branches in the code?
I've added tests to test most of the error branches and increase codecov |
catchup/networkFetcher.go
Outdated
@@ -52,7 +52,7 @@ func MakeNetworkFetcher(log logging.Logger, net network.GossipNode, cfg config.L | |||
} | |||
|
|||
func (netFetcher *NetworkFetcher) getHTTPPeer() (network.HTTPPeer, *peerSelectorPeer, error) { | |||
for retryCount := 0; retryCount < netFetcher.cfg.CatchupBlockDownloadRetryAttempts; retryCount++ { | |||
for retryCount := 1; retryCount <= netFetcher.cfg.CatchupBlockDownloadRetryAttempts; retryCount++ { |
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 this change?
catchup/networkFetcher.go
Outdated
@@ -79,7 +79,7 @@ func (netFetcher *NetworkFetcher) getHTTPPeer() (network.HTTPPeer, *peerSelector | |||
func (netFetcher *NetworkFetcher) FetchBlock(ctx context.Context, round basics.Round) (*bookkeeping.Block, | |||
*agreement.Certificate, time.Duration, error) { | |||
// internal retry attempt to fetch the block | |||
for retryCount := 0; retryCount < netFetcher.cfg.CatchupBlockDownloadRetryAttempts; retryCount++ { | |||
for retryCount := 1; retryCount <= netFetcher.cfg.CatchupBlockDownloadRetryAttempts; retryCount++ { |
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???
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.
to say attempt 1 out of 100 instead of 0 out of 100 while logging
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 is a confusing notation. All the loops start from 0 (usually). You can add +1 in the logging statement.
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.
More testing might be needed, but I am fine the the changes to the existing code and the implementation of the new interfaces.
Great job!
Thank you! |
Summary
fetchBlock
function from universalFetcher.createPeerSelector
has been partially exported.