-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Improve ReceiptsDownloader: replace timeout with request counter #1099
Comments
@mkalinin Can I pick this one? |
@dhingra sure! feel free to ask me if anything unclear will be found |
@mkalinin Few questions:
Can you please elaborate little more on requirement? thanks |
Hi @mkalinin I submitted a pull request for this enhancement. I hope this is what was required but if not, feel free to reach out to me as I don't mind working on it more and I am eager to learn. |
Current implementation
Above steps describe this piece of code ethereumj/ethereumj-core/src/main/java/org/ethereum/sync/ReceiptsDownloader.java Lines 170 to 175 in 7e3b9dd
Proposed improvementAn improvement should update step 2 in a following way: |
@mkalinin thank you for the clarification. I will work on this and get back to you with an updated PR. |
For this enhancement I created counters requestedBlocksCounter and receivedBlocksCounter My thought process being that each time we create a callback/request we will increment requestedBlocksCounter. Upon a successful response back we will increment receivedBlocksCounter. Whenever we had previously requested in the past (requestedBlocksCounter > 0) AND the value also matches the receivedBlocksCounter, we can skip the REQUEST_TIMEOUT and reinitialize the download queue. The reason why I didn't use one counter to keep track (by increment/decrement) is because we intialize the counter to 0 and we would also skip the REQUEST_TIMEOUT on the first loop. Comparing two counters help to prevent this. @mkalinin Does this pull request / logic make more sense? If not, how could I improve it? Thank you for your patience. |
I see your point. But some of requests may never be responded. Since one of such requests occurs there will be no way that this specific logic with counters works, each time it will fallback to the old way with timeout. So, counter should be reset from time to time. And there is no way to find an algo which would work in all cases, and we don't need it, actually. Just need a solution that works in most of the cases. |
@mkalinin Okay how about we use the size of toDownload() as the counter? This way it will always start with the correct size and eventually get reset to 0 as we removed requests from the list. The first time its empty we will not have to wait for the timeout. Like this:
|
The logic worth to be implemented can be found in BlockDownloader
The text was updated successfully, but these errors were encountered: