Move the bip158 filter hash types
We would like all the various hash types to be defined where they rightly live instead of in the `hash_types` module. Move the BIP-158 filter hash types to the `bip158` module.
This commit is contained in:
parent
3107f80aac
commit
2a0ac1258a
|
@ -41,7 +41,7 @@
|
|||
use core::cmp::{self, Ordering};
|
||||
use core::fmt::{self, Display, Formatter};
|
||||
|
||||
use hashes::{siphash24, Hash};
|
||||
use hashes::{sha256d, siphash24, Hash};
|
||||
use internals::write_err;
|
||||
|
||||
use crate::blockdata::block::{Block, BlockHash};
|
||||
|
@ -49,13 +49,23 @@ use crate::blockdata::script::Script;
|
|||
use crate::blockdata::transaction::OutPoint;
|
||||
use crate::consensus::encode::VarInt;
|
||||
use crate::consensus::{Decodable, Encodable};
|
||||
use crate::hash_types::{FilterHash, FilterHeader};
|
||||
use crate::hash_types::impl_hashencode;
|
||||
use crate::prelude::*;
|
||||
|
||||
/// Golomb encoding parameter as in BIP-158, see also https://gist.github.com/sipa/576d5f09c3b86c3b1b75598d799fc845
|
||||
const P: u8 = 19;
|
||||
const M: u64 = 784931;
|
||||
|
||||
hashes::hash_newtype! {
|
||||
/// Filter hash, as defined in BIP-157
|
||||
pub struct FilterHash(sha256d::Hash);
|
||||
/// Filter header, as defined in BIP-157
|
||||
pub struct FilterHeader(sha256d::Hash);
|
||||
}
|
||||
|
||||
impl_hashencode!(FilterHash);
|
||||
impl_hashencode!(FilterHeader);
|
||||
|
||||
/// Errors for blockfilter.
|
||||
#[derive(Debug)]
|
||||
#[non_exhaustive]
|
||||
|
|
|
@ -23,9 +23,9 @@ use internals::write_err;
|
|||
use io::{Cursor, Read};
|
||||
|
||||
use crate::bip152::{PrefilledTransaction, ShortId};
|
||||
use crate::bip158::{FilterHash, FilterHeader};
|
||||
use crate::blockdata::block::{self, BlockHash, TxMerkleNode};
|
||||
use crate::blockdata::transaction::{Transaction, TxIn, TxOut};
|
||||
use crate::hash_types::{FilterHash, FilterHeader};
|
||||
#[cfg(feature = "std")]
|
||||
use crate::p2p::{
|
||||
address::{AddrV2Message, Address},
|
||||
|
|
|
@ -49,25 +49,8 @@ macro_rules! impl_asref_push_bytes {
|
|||
}
|
||||
pub(crate) use impl_asref_push_bytes;
|
||||
|
||||
// newtypes module is solely here so we can rustfmt::skip.
|
||||
#[rustfmt::skip]
|
||||
#[doc(inline)]
|
||||
pub use newtypes::*;
|
||||
|
||||
#[rustfmt::skip]
|
||||
mod newtypes {
|
||||
use hashes::{sha256d, hash_newtype};
|
||||
|
||||
hash_newtype! {
|
||||
/// Filter hash, as defined in BIP-157
|
||||
pub struct FilterHash(sha256d::Hash);
|
||||
/// Filter header, as defined in BIP-157
|
||||
pub struct FilterHeader(sha256d::Hash);
|
||||
}
|
||||
|
||||
impl_hashencode!(FilterHash);
|
||||
impl_hashencode!(FilterHeader);
|
||||
}
|
||||
|
||||
#[deprecated(since = "0.0.0-NEXT-RELEASE", note = "use crate::T instead")]
|
||||
pub use crate::{BlockHash, TxMerkleNode, Txid, WitnessCommitment, WitnessMerkleNode, Wtxid};
|
||||
pub use crate::{
|
||||
BlockHash, FilterHash, FilterHeader, TxMerkleNode, Txid, WitnessCommitment, WitnessMerkleNode,
|
||||
Wtxid,
|
||||
};
|
||||
|
|
|
@ -121,6 +121,7 @@ pub mod taproot;
|
|||
pub use crate::{
|
||||
address::{Address, AddressType},
|
||||
amount::{Amount, Denomination, SignedAmount},
|
||||
bip158::{FilterHash, FilterHeader},
|
||||
bip32::XKeyIdentifier,
|
||||
blockdata::block::{self, Block, BlockHash, TxMerkleNode, WitnessMerkleNode, WitnessCommitment},
|
||||
blockdata::constants,
|
||||
|
@ -137,7 +138,6 @@ pub use crate::{
|
|||
crypto::ecdsa,
|
||||
crypto::key::{self, PrivateKey, PubkeyHash, PublicKey, WPubkeyHash, XOnlyPublicKey},
|
||||
crypto::sighash::{self, LegacySighash, SegwitV0Sighash, TapSighash, TapSighashTag},
|
||||
hash_types::{FilterHash, FilterHeader},
|
||||
merkle_tree::MerkleBlock,
|
||||
network::Network,
|
||||
pow::{CompactTarget, Target, Work},
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
//! This module describes BIP157 Client Side Block Filtering network messages.
|
||||
//!
|
||||
|
||||
use crate::bip158::{FilterHash, FilterHeader};
|
||||
use crate::blockdata::block::BlockHash;
|
||||
use crate::hash_types::{FilterHash, FilterHeader};
|
||||
use crate::internal_macros::impl_consensus_encoding;
|
||||
|
||||
/// getcfilters message
|
||||
|
|
Loading…
Reference in New Issue