This macro is pretty weird -- it requires that a freestanding `from_engine` method exists, which it uses to implement a `from_engine` method within an impl block, by just calling through to the freestanding method. To reduce indirection, at a very small cost in increased repeated code (we now need to add a `impl Hash {` and `}` and doccomment around each freestanding function, we just remove this from the macro entirely. This will allow us to implement `from_engine` for `sha256t::Hash` in a different way than for the non-generic hash types. To minimize the diff, we do not re-indent the freestanding `from_engine`. We will do that in the next commit. However, the diff is still a bit noisy because I had to replace `fn from_engine` with `pub fn from_engine` in every case. I took the opportunity to also change the return type from `Hash` to `Self` to make it clearer that these are constructors. |
||
---|---|---|
.. | ||
contrib | ||
embedded | ||
src | ||
tests | ||
CHANGELOG.md | ||
Cargo.toml | ||
README.md |
README.md
Bitcoin Hashes Library
This is a simple, no-dependency library which implements the hash functions needed by Bitcoin. These are SHA1, SHA256, SHA256d, SHA512, and RIPEMD160. As an ancillary thing, it exposes hexadecimal serialization and deserialization, since these are needed to display hashes anyway.
Minimum Supported Rust Version (MSRV)
This library should always compile with any combination of features on Rust 1.63.0.
Contributions
Contributions are welcome, including additional hash function implementations.
Githooks
To assist devs in catching errors before running CI we provide some githooks. If you do not already have locally configured githooks you can use the ones in this repository by running, in the root directory of the repository:
git config --local core.hooksPath githooks/
Alternatively add symlinks in your .git/hooks
directory to any of the githooks we provide.
Running Benchmarks
We use a custom Rust compiler configuration conditional to guard the benchmark code. To run the
benchmarks use: RUSTFLAGS='--cfg=bench' cargo +nightly bench
.