Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Add all_zeros method to Hash trait#148

Merged
apoelstra merged 1 commit intorust-bitcoin:masterfrom
tcharding:all-zeros
May 10, 2022
Merged

Add all_zeros method to Hash trait#148
apoelstra merged 1 commit intorust-bitcoin:masterfrom
tcharding:all-zeros

Conversation

@tcharding
Copy link
Copy Markdown
Member

Currently we use Default::default() to get an all zeros hash. This is confusing because an all zeroes hash does not have a real meaning since there is no known input to create it. The all zeros hash is, however used by the Bitcoin network to signify certain things (e.g. the previous blockhash in the genesis block).

Remove the Default implementation from the Hash trait and add a all_zeros method instead. Remove the Default derive from any hash type that has it.

To see the patch to rust-bitcoin that this PR imposes, check out this branch.

Resolves #139

Currently we use `Default::default()` to get an all zeros hash. This is
misleading because an all zeroes hash does not have a real meaning since
there is no known input to create it. The all zeros has is used by the
Bitcoin network to signify certain things (e.g. the previous blockhash
in the genesis block).

Remove the `Default` implementation from the `Hash` trait and add a
`all_zeros` method instead.
Copy link
Copy Markdown
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

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

ACK 51be9bd

This is a breaking change and requires a major version bump.

@tcharding
Copy link
Copy Markdown
Member Author

This is a breaking change and requires a major version bump.

Whats the policy for changes like this across the rust-bitcoin stack? Should this PR have included a change to bump the version number or do we rely on you to work this out when you do the release?

@apoelstra
Copy link
Copy Markdown
Member

@tcharding we don't have an explicit policy ... but yes, "we rely on me to work it out" is usually what we do.

Sometimes people want a minor version bump for some specific feature, in which case I ask them to put the bump into the PR ... but for major ones I don't think we ever do that.

@tcharding tcharding mentioned this pull request Apr 6, 2022
@tcharding
Copy link
Copy Markdown
Member Author

Friendly bump please review crew.

@apoelstra
Copy link
Copy Markdown
Member

Let's do it. We can bring this into the MSRV-bumping release, this crate is simple enough that I don't worry about breaking too much at once.

@apoelstra apoelstra merged commit aff0e6f into rust-bitcoin:master May 10, 2022
@tcharding tcharding deleted the all-zeros branch June 22, 2022 06:45
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

impl Default for sha256::Hash is weird

2 participants