diff --git a/bitcoin/src/blockdata/block.rs b/bitcoin/src/blockdata/block.rs index dfa2381a..be5427f4 100644 --- a/bitcoin/src/blockdata/block.rs +++ b/bitcoin/src/blockdata/block.rs @@ -637,7 +637,7 @@ mod benches { use super::Block; use crate::consensus::{deserialize, Decodable, Encodable}; - use crate::EmptyWrite; + use crate::io::sink; #[bench] pub fn bench_stream_reader(bh: &mut Bencher) { @@ -674,7 +674,7 @@ mod benches { let block: Block = deserialize(&raw_block[..]).unwrap(); bh.iter(|| { - let size = block.consensus_encode(&mut EmptyWrite); + let size = block.consensus_encode(&mut sink()); black_box(&size); }); } diff --git a/bitcoin/src/blockdata/transaction.rs b/bitcoin/src/blockdata/transaction.rs index 22c4b3b0..21ee67b7 100644 --- a/bitcoin/src/blockdata/transaction.rs +++ b/bitcoin/src/blockdata/transaction.rs @@ -2112,7 +2112,7 @@ mod benches { use super::Transaction; use crate::consensus::{deserialize, Encodable}; - use crate::EmptyWrite; + use crate::io::sink; const SOME_TX: &str = "0100000001a15d57094aa7a21a28cb20b59aab8fc7d1149a3bdbcddba9c622e4f5f6a99ece010000006c493046022100f93bb0e7d8db7bd46e40132d1f8242026e045f03a0efe71bbb8e3f475e970d790221009337cd7f1f929f00cc6ff01f03729b069a7c21b59b1736ddfee5db5946c5da8c0121033b9b137ee87d5a812d6f506efdd37f0affa7ffc310711c06c7f3e097c9447c52ffffffff0100e1f505000000001976a9140389035a9225b3839e2bbf32d826a1e222031fd888ac00000000"; @@ -2147,7 +2147,7 @@ mod benches { let tx: Transaction = deserialize(&raw_tx).unwrap(); bh.iter(|| { - let size = tx.consensus_encode(&mut EmptyWrite); + let size = tx.consensus_encode(&mut sink()); black_box(&size); }); } diff --git a/bitcoin/src/lib.rs b/bitcoin/src/lib.rs index 03d516ed..65984cbf 100644 --- a/bitcoin/src/lib.rs +++ b/bitcoin/src/lib.rs @@ -196,27 +196,3 @@ mod prelude { pub use hex::DisplayHex; } - -#[cfg(bench)] -use bench::EmptyWrite; - -#[cfg(bench)] -mod bench { - use core::fmt::Arguments; - - use crate::io::{IoSlice, Result, Write}; - - #[derive(Default, Clone, Debug, PartialEq, Eq)] - pub struct EmptyWrite; - - impl Write for EmptyWrite { - fn write(&mut self, buf: &[u8]) -> Result { Ok(buf.len()) } - fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result { - Ok(bufs.iter().map(|s| s.len()).sum()) - } - fn flush(&mut self) -> Result<()> { Ok(()) } - - fn write_all(&mut self, _: &[u8]) -> Result<()> { Ok(()) } - fn write_fmt(&mut self, _: Arguments) -> Result<()> { Ok(()) } - } -} diff --git a/bitcoin/src/p2p/message_bloom.rs b/bitcoin/src/p2p/message_bloom.rs index e3dcbe18..812ce2f5 100644 --- a/bitcoin/src/p2p/message_bloom.rs +++ b/bitcoin/src/p2p/message_bloom.rs @@ -5,10 +5,9 @@ //! This module describes BIP37 Connection Bloom filtering network messages. //! -use std::io; - use crate::consensus::{encode, Decodable, Encodable, ReadExt}; use crate::internal_macros::impl_consensus_encoding; +use crate::io; /// `filterload` message sets the current bloom filter #[derive(Clone, PartialEq, Eq, Debug)] diff --git a/io/src/lib.rs b/io/src/lib.rs index e09557a1..e4a4a79e 100644 --- a/io/src/lib.rs +++ b/io/src/lib.rs @@ -36,7 +36,7 @@ pub mod io { compile_error!("At least one of std or core2 must be enabled"); #[cfg(feature = "std")] - pub use std::io::{Read, Write, Cursor, Take, IoSlice, Error, ErrorKind, Result}; + pub use std::io::{Read, Write, sink, Cursor, Take, Error, ErrorKind, Result}; #[cfg(not(feature = "std"))] pub use core2::io::{Read, Write, Cursor, Take, Error, ErrorKind, Result};