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

core: optimize HasBlock check for recent blocks #2759

Merged
merged 1 commit into from
Oct 24, 2022

Conversation

roman-khimov
Copy link
Member

When block is being spread through the network we can get a lot of invs with the same hash. Some more stale nodes may also announce previous or some earlier block. We can avoid full DB lookup for them and minimize inv handling time (timeouts in inv handler had happened in #2744).

It doesn't affect tests, just makes node a little less likely to spend some considerable amount of time in the inv handler.

When block is being spread through the network we can get a lot of invs with
the same hash. Some more stale nodes may also announce previous or some
earlier block. We can avoid full DB lookup for them and minimize inv handling
time (timeouts in inv handler had happened in #2744).

It doesn't affect tests, just makes node a little less likely to spend some
considerable amount of time in the inv handler.
@roman-khimov roman-khimov added this to the v0.99.5 milestone Oct 21, 2022
@codecov
Copy link

codecov bot commented Oct 21, 2022

Codecov Report

Merging #2759 (0c3b036) into master (bf4636f) will increase coverage by 0.02%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #2759      +/-   ##
==========================================
+ Coverage   85.21%   85.24%   +0.02%     
==========================================
  Files         324      324              
  Lines       40150    40159       +9     
==========================================
+ Hits        34215    34234      +19     
+ Misses       4562     4555       -7     
+ Partials     1373     1370       -3     
Impacted Files Coverage Δ
pkg/core/blockchain.go 81.30% <100.00%> (+0.15%) ⬆️
pkg/core/transaction/transaction.go 86.66% <0.00%> (+1.48%) ⬆️
pkg/network/message.go 94.02% <0.00%> (+1.49%) ⬆️
pkg/network/compress.go 76.00% <0.00%> (+12.00%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@roman-khimov roman-khimov merged commit a17d9f8 into master Oct 24, 2022
@roman-khimov roman-khimov deleted the avoid-db-lookup-in-hasblock branch October 24, 2022 07:33
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.

2 participants