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

Backport Bitcoin PR#8822: net: Consistent checksum handling #1565

Merged
merged 2 commits into from
Aug 8, 2017

Conversation

OlegGirko
Copy link

This is backport of Bitcoin PR bitcoin#8822.

This is the last PR I'm sending before main.{h,cpp} split.

The original PR description follows.

In principle, the checksums of P2P packets are simply 4-byte blobs which are the first bytes of SHA256(SHA256(payload)).

Currently they are handled as little-endian 32-bit integers half of the time, as blobs the other half, sometimes copying the one to the other, resulting in somewhat confused code.

This PR changes the handling to be consistent both at packet creation and receiving, making it (I think) easier to understand.

In principle, the checksums of P2P packets are simply 4-byte blobs which
are the first four bytes of SHA256(SHA256(payload)).

Currently they are handled as little-endian 32-bit integers half of the
time, as blobs the other half, sometimes copying the one to the other,
resulting in somewhat confused code.

This PR changes the handling to be consistent both at packet creation
and receiving, making it (I think) easier to understand.
The P2P network uses a fixed protocol, these sizes shouldn't change
based on what happens to be the architecture.
Copy link

@UdjinM6 UdjinM6 left a comment

Choose a reason for hiding this comment

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

utACK

@UdjinM6 UdjinM6 added this to the 12.2 milestone Aug 8, 2017
@UdjinM6 UdjinM6 merged commit bcf5455 into dashpay:v0.12.2.x Aug 8, 2017
@OlegGirko OlegGirko deleted the bc-pr-8822 branch August 8, 2017 18:54
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.

3 participants