-
Notifications
You must be signed in to change notification settings - Fork 37.7k
net processing: Remove hash and fValidatedHeaders from QueuedBlock #22141
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
Conversation
MarkBlockAsInFlight is always called with a non-null pindex. Just get the block hash from that pindex inside the function.
Since headers-first syncing, we only ever request a block if we've already validated its headers. Therefore QueuedBlock.fValidatedHeaders is always set to true. Remove it.
nBlocksInFlightValidHeaders always has the same value as nBlocksInFlight, since we only download blocks with valid headers.
-BEGIN VERIFY SCRIPT- ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ./src ./test); } ren nPeersWithValidatedDownloads m_peers_downloading_from -END VERIFY SCRIPT-
It's redundant with CBlockIndex::GetBlockHash()
MarkBlockAsReceived() should not be used for both removing the block from mapBlocksInFlight and checking whether it was in the map.
-BEGIN VERIFY SCRIPT- ren() { sed -i "s:\<$1\>:$2:g" $(git grep -l "\<$1\>" ./src ./test); } ren MarkBlockAsInFlight BlockRequested ren MarkBlockAsReceived RemoveBlockRequest -END VERIFY SCRIPT-
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
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.
utACK 2f4ad6b
Very nice cleanup.
Concept ACK |
crACK 2f4ad6b |
Thanks for the review @mjdietzx. I've answered your review questions. Feel free to ask more if there's anything that's still unclear about this PR. |
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.
review ACK 2f4ad6b 📊
Show signature and timestamp
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
review ACK 2f4ad6b7efa408b8a858e87499bf6cfcdf936d73 📊
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUhXzwv9HniRZ2DZea8vtfP9W0XCvKLSaLzohfoLcy8LV+kuq0kzasQQWYfqy6s+
9ZUkOV/pxBsrl55Pfk/MvhbHOMw2t4Y/2RP7foRm/GZVbF2W5eMkg58L3R0CIXsi
k4/dxINftIkNObRMtsYSjNWBwVaYiMHbAB8CHYH+B43/yE3otQ8QweT8IG7/r9VV
ZWSkw9P2Z7tUQw9FeiaOYxteDK/W+dxec0m3+iIvOJeloc/UHKXM+wI15E/KoSK/
S9ttkHCRzius/M3a54JqmgkA73vnDwcjQe7NLVphl2f/UbIgf2cE2PH/BIiL4k72
tNye+KKxMqknxsdMRjQXVs6biQp2crxu/pNSUS5kw6z6vvb0SQgF6zZtWzs2c77D
1r+Zo0eHhzxyLodbxwgtZzZmr5HvMzHMnAqhp/7aDWTqpeGRYeGC0Klqko9wXipB
dxs8nre5S/5XnJHt5DJ3DHiVLRGk0g7xldCDrv0A2KAJOI8whbHt8aEp1SojfM5I
0eVnuNvO
=itrW
-----END PGP SIGNATURE-----
Timestamp of file with hash f0a6a932acf4e1e73bf07c8f0433dd6b510a91f4061198f5afafddba6da52c6d -
…s from QueuedBlock 2f4ad6b scripted-diff: rename MarkBlockAs functions (John Newbery) 2c45f83 [net processing] Tidy up MarkBlockAsReceived() (John Newbery) 6299350 [net processing] Add IsBlockRequested() function (John Newbery) 4e90d2d [net processing] Remove QueuedBlock.hash (John Newbery) 156a19e scripted-diff: rename nPeersWithValidatedDownloads (John Newbery) b03de9c [net processing] Remove CNodeState.nBlocksInFlightValidHeaders (John Newbery) b4e29f2 [net processing] Remove QueuedBlock.fValidatedHeaders (John Newbery) 85e058b [net processing] Remove unnecessary hash arg from MarkBlockAsInFlight() (John Newbery) Pull request description: The QueuedBlock struct contains a `fValidatedHeaders` field that indicates whether we have already validated a header for the requested block. Since headers-first syncing, we only request blocks where the header is already validated, so `fValidatedHeaders` is always true. Remove it and clean up the logic that uses that field. Likewise, QueuedBlock contains a `hash` field that is set to the block hash. Since headers-first syncing, we always have a CBlockIndex, which contains the block hash, so remove the redundant `hash` field. Tidy up the logic and rename functions to better indicate what they're doing. ACKs for top commit: mjdietzx: crACK 2f4ad6b sipa: utACK 2f4ad6b MarcoFalke: review ACK 2f4ad6b 📊 Tree-SHA512: 3d31d2bcb4d35d0fdb7c1da624c2878203218026445e8f76c4a2df68cc7183ce0e7d0c47c7c0a3242e55efaca7c9f5532b683cf6ec7c03d23fa83764fdb82fd2
The QueuedBlock struct contains a
fValidatedHeaders
field that indicates whether we have already validated a header for the requested block. Since headers-first syncing, we only request blocks where the header is already validated, sofValidatedHeaders
is always true. Remove it and clean up the logic that uses that field.Likewise, QueuedBlock contains a
hash
field that is set to the block hash. Since headers-first syncing, we always have a CBlockIndex, which contains the block hash, so remove the redundanthash
field.Tidy up the logic and rename functions to better indicate what they're doing.