Shield hash_newtypes from rustfmt
In preparation for running the formatter on root level modules and a submodule that holds all the macro calls in `hash_types` so we can configure rustfmt to skip formatting them.
This commit is contained in:
parent
65d19d9044
commit
01471f7e65
|
@ -9,8 +9,6 @@
|
||||||
//! hash).
|
//! hash).
|
||||||
//!
|
//!
|
||||||
|
|
||||||
use bitcoin_hashes::{sha256, sha256d, hash160, hash_newtype};
|
|
||||||
|
|
||||||
macro_rules! impl_hashencode {
|
macro_rules! impl_hashencode {
|
||||||
($hashtype:ident) => {
|
($hashtype:ident) => {
|
||||||
impl $crate::consensus::Encodable for $hashtype {
|
impl $crate::consensus::Encodable for $hashtype {
|
||||||
|
@ -28,8 +26,15 @@ macro_rules! impl_hashencode {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
hash_newtype!(
|
// newtypes module is solely here so we can rustfmt::skip.
|
||||||
Txid, sha256d::Hash, 32, doc="A bitcoin transaction hash/transaction ID.
|
pub use newtypes::*;
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
|
mod newtypes {
|
||||||
|
use crate::hashes::{sha256, sha256d, hash160, hash_newtype};
|
||||||
|
|
||||||
|
hash_newtype!(
|
||||||
|
Txid, sha256d::Hash, 32, doc="A bitcoin transaction hash/transaction ID.
|
||||||
|
|
||||||
For compatibility with the existing Bitcoin infrastructure and historical
|
For compatibility with the existing Bitcoin infrastructure and historical
|
||||||
and current versions of the Bitcoin Core software itself, this and
|
and current versions of the Bitcoin Core software itself, this and
|
||||||
|
@ -37,31 +42,31 @@ other [`sha256d::Hash`] types, are serialized in reverse
|
||||||
byte order when converted to a hex string via [`std::fmt::Display`] trait operations.
|
byte order when converted to a hex string via [`std::fmt::Display`] trait operations.
|
||||||
See [`hashes::Hash::DISPLAY_BACKWARD`] for more details.
|
See [`hashes::Hash::DISPLAY_BACKWARD`] for more details.
|
||||||
");
|
");
|
||||||
hash_newtype!(Wtxid, sha256d::Hash, 32, doc="A bitcoin witness transaction ID.");
|
hash_newtype!(Wtxid, sha256d::Hash, 32, doc="A bitcoin witness transaction ID.");
|
||||||
hash_newtype!(BlockHash, sha256d::Hash, 32, doc="A bitcoin block hash.");
|
hash_newtype!(BlockHash, sha256d::Hash, 32, doc="A bitcoin block hash.");
|
||||||
hash_newtype!(Sighash, sha256d::Hash, 32, doc="Hash of the transaction according to the signature algorithm");
|
hash_newtype!(Sighash, sha256d::Hash, 32, doc="Hash of the transaction according to the signature algorithm");
|
||||||
|
|
||||||
hash_newtype!(PubkeyHash, hash160::Hash, 20, doc="A hash of a public key.");
|
hash_newtype!(PubkeyHash, hash160::Hash, 20, doc="A hash of a public key.");
|
||||||
hash_newtype!(ScriptHash, hash160::Hash, 20, doc="A hash of Bitcoin Script bytecode.");
|
hash_newtype!(ScriptHash, hash160::Hash, 20, doc="A hash of Bitcoin Script bytecode.");
|
||||||
hash_newtype!(WPubkeyHash, hash160::Hash, 20, doc="SegWit version of a public key hash.");
|
hash_newtype!(WPubkeyHash, hash160::Hash, 20, doc="SegWit version of a public key hash.");
|
||||||
hash_newtype!(WScriptHash, sha256::Hash, 32, doc="SegWit version of a Bitcoin Script bytecode hash.");
|
hash_newtype!(WScriptHash, sha256::Hash, 32, doc="SegWit version of a Bitcoin Script bytecode hash.");
|
||||||
|
|
||||||
hash_newtype!(TxMerkleNode, sha256d::Hash, 32, doc="A hash of the Merkle tree branch or root for transactions");
|
hash_newtype!(TxMerkleNode, sha256d::Hash, 32, doc="A hash of the Merkle tree branch or root for transactions");
|
||||||
hash_newtype!(WitnessMerkleNode, sha256d::Hash, 32, doc="A hash corresponding to the Merkle tree root for witness data");
|
hash_newtype!(WitnessMerkleNode, sha256d::Hash, 32, doc="A hash corresponding to the Merkle tree root for witness data");
|
||||||
hash_newtype!(WitnessCommitment, sha256d::Hash, 32, doc="A hash corresponding to the witness structure commitment in the coinbase transaction");
|
hash_newtype!(WitnessCommitment, sha256d::Hash, 32, doc="A hash corresponding to the witness structure commitment in the coinbase transaction");
|
||||||
hash_newtype!(XpubIdentifier, hash160::Hash, 20, doc="XpubIdentifier as defined in BIP-32.");
|
hash_newtype!(XpubIdentifier, hash160::Hash, 20, doc="XpubIdentifier as defined in BIP-32.");
|
||||||
|
|
||||||
hash_newtype!(FilterHash, sha256d::Hash, 32, doc="Filter hash, as defined in BIP-157");
|
hash_newtype!(FilterHash, sha256d::Hash, 32, doc="Filter hash, as defined in BIP-157");
|
||||||
hash_newtype!(FilterHeader, sha256d::Hash, 32, doc="Filter header, as defined in BIP-157");
|
hash_newtype!(FilterHeader, sha256d::Hash, 32, doc="Filter header, as defined in BIP-157");
|
||||||
|
|
||||||
|
impl_hashencode!(Txid);
|
||||||
|
impl_hashencode!(Wtxid);
|
||||||
|
impl_hashencode!(BlockHash);
|
||||||
|
impl_hashencode!(Sighash);
|
||||||
|
|
||||||
impl_hashencode!(Txid);
|
impl_hashencode!(TxMerkleNode);
|
||||||
impl_hashencode!(Wtxid);
|
impl_hashencode!(WitnessMerkleNode);
|
||||||
impl_hashencode!(BlockHash);
|
|
||||||
impl_hashencode!(Sighash);
|
|
||||||
|
|
||||||
impl_hashencode!(TxMerkleNode);
|
impl_hashencode!(FilterHash);
|
||||||
impl_hashencode!(WitnessMerkleNode);
|
impl_hashencode!(FilterHeader);
|
||||||
|
}
|
||||||
impl_hashencode!(FilterHash);
|
|
||||||
impl_hashencode!(FilterHeader);
|
|
||||||
|
|
Loading…
Reference in New Issue