Move impl_hashencode to internal_macros
We are emptying the `hash_types` module. `impl_hashencode!` is an internal macro, as such it can live in the `internal_macros` module.
This commit is contained in:
parent
2a0ac1258a
commit
2b4b66dee3
|
@ -49,7 +49,7 @@ use crate::blockdata::script::Script;
|
||||||
use crate::blockdata::transaction::OutPoint;
|
use crate::blockdata::transaction::OutPoint;
|
||||||
use crate::consensus::encode::VarInt;
|
use crate::consensus::encode::VarInt;
|
||||||
use crate::consensus::{Decodable, Encodable};
|
use crate::consensus::{Decodable, Encodable};
|
||||||
use crate::hash_types::impl_hashencode;
|
use crate::internal_macros::impl_hashencode;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
|
|
||||||
/// Golomb encoding parameter as in BIP-158, see also https://gist.github.com/sipa/576d5f09c3b86c3b1b75598d799fc845
|
/// Golomb encoding parameter as in BIP-158, see also https://gist.github.com/sipa/576d5f09c3b86c3b1b75598d799fc845
|
||||||
|
|
|
@ -16,8 +16,7 @@ use super::Weight;
|
||||||
use crate::blockdata::script;
|
use crate::blockdata::script;
|
||||||
use crate::blockdata::transaction::{Transaction, Txid, Wtxid};
|
use crate::blockdata::transaction::{Transaction, Txid, Wtxid};
|
||||||
use crate::consensus::{encode, Decodable, Encodable};
|
use crate::consensus::{encode, Decodable, Encodable};
|
||||||
use crate::hash_types::impl_hashencode;
|
use crate::internal_macros::{impl_consensus_encoding, impl_hashencode};
|
||||||
use crate::internal_macros::impl_consensus_encoding;
|
|
||||||
use crate::pow::{CompactTarget, Target, Work};
|
use crate::pow::{CompactTarget, Target, Work};
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::{merkle_tree, Network, VarInt};
|
use crate::{merkle_tree, Network, VarInt};
|
||||||
|
|
|
@ -23,8 +23,7 @@ use crate::blockdata::locktime::relative;
|
||||||
use crate::blockdata::script::{Script, ScriptBuf};
|
use crate::blockdata::script::{Script, ScriptBuf};
|
||||||
use crate::blockdata::witness::Witness;
|
use crate::blockdata::witness::Witness;
|
||||||
use crate::consensus::{encode, Decodable, Encodable};
|
use crate::consensus::{encode, Decodable, Encodable};
|
||||||
use crate::hash_types::impl_hashencode;
|
use crate::internal_macros::{impl_consensus_encoding, impl_hashencode};
|
||||||
use crate::internal_macros::impl_consensus_encoding;
|
|
||||||
use crate::parse::impl_parse_str_from_int_infallible;
|
use crate::parse::impl_parse_str_from_int_infallible;
|
||||||
use crate::prelude::*;
|
use crate::prelude::*;
|
||||||
use crate::script::Push;
|
use crate::script::Push;
|
||||||
|
|
|
@ -8,25 +8,6 @@
|
||||||
//! hash).
|
//! hash).
|
||||||
//!
|
//!
|
||||||
|
|
||||||
#[rustfmt::skip]
|
|
||||||
macro_rules! impl_hashencode {
|
|
||||||
($hashtype:ident) => {
|
|
||||||
impl $crate::consensus::Encodable for $hashtype {
|
|
||||||
fn consensus_encode<W: $crate::io::Write + ?Sized>(&self, w: &mut W) -> Result<usize, $crate::io::Error> {
|
|
||||||
self.0.consensus_encode(w)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl $crate::consensus::Decodable for $hashtype {
|
|
||||||
fn consensus_decode<R: $crate::io::Read + ?Sized>(r: &mut R) -> Result<Self, $crate::consensus::encode::Error> {
|
|
||||||
use $crate::hashes::Hash;
|
|
||||||
Ok(Self::from_byte_array(<<$hashtype as $crate::hashes::Hash>::Bytes>::consensus_decode(r)?))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
pub(crate) use impl_hashencode;
|
|
||||||
|
|
||||||
#[rustfmt::skip]
|
#[rustfmt::skip]
|
||||||
macro_rules! impl_asref_push_bytes {
|
macro_rules! impl_asref_push_bytes {
|
||||||
($($hashtype:ident),*) => {
|
($($hashtype:ident),*) => {
|
||||||
|
|
|
@ -191,3 +191,22 @@ macro_rules! impl_bytes_newtype {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
pub(crate) use impl_bytes_newtype;
|
pub(crate) use impl_bytes_newtype;
|
||||||
|
|
||||||
|
#[rustfmt::skip]
|
||||||
|
macro_rules! impl_hashencode {
|
||||||
|
($hashtype:ident) => {
|
||||||
|
impl $crate::consensus::Encodable for $hashtype {
|
||||||
|
fn consensus_encode<W: $crate::io::Write + ?Sized>(&self, w: &mut W) -> Result<usize, $crate::io::Error> {
|
||||||
|
self.0.consensus_encode(w)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl $crate::consensus::Decodable for $hashtype {
|
||||||
|
fn consensus_decode<R: $crate::io::Read + ?Sized>(r: &mut R) -> Result<Self, $crate::consensus::encode::Error> {
|
||||||
|
use $crate::hashes::Hash;
|
||||||
|
Ok(Self::from_byte_array(<<$hashtype as $crate::hashes::Hash>::Bytes>::consensus_decode(r)?))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
pub(crate) use impl_hashencode;
|
||||||
|
|
Loading…
Reference in New Issue