From 09aac202931fc9ad134b5a001e9ba40495cce9fa Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Tue, 21 May 2024 07:06:13 -0400 Subject: [PATCH] Set the BufReader capacity to 0 Fixes issues with bitcoin. We only use a BufReader as it's the only way to use a std::io::Read generic as a bitcoin::io::Read object. --- coins/bitcoin/src/wallet/mod.rs | 2 +- processor/src/networks/bitcoin.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/coins/bitcoin/src/wallet/mod.rs b/coins/bitcoin/src/wallet/mod.rs index ed6f00ce..195182ff 100644 --- a/coins/bitcoin/src/wallet/mod.rs +++ b/coins/bitcoin/src/wallet/mod.rs @@ -93,7 +93,7 @@ impl ReceivedOutput { let output; let outpoint; { - let mut buf_r = BufReader::new(r); + let mut buf_r = BufReader::with_capacity(0, r); output = TxOut::consensus_decode(&mut buf_r).map_err(|_| io::Error::other("invalid TxOut"))?; outpoint = diff --git a/processor/src/networks/bitcoin.rs b/processor/src/networks/bitcoin.rs index e89c9138..183444b1 100644 --- a/processor/src/networks/bitcoin.rs +++ b/processor/src/networks/bitcoin.rs @@ -242,7 +242,7 @@ impl EventualityTrait for Eventuality { buf } fn read_completion(reader: &mut R) -> io::Result { - Transaction::consensus_decode(&mut io::BufReader::new(reader)) + Transaction::consensus_decode(&mut io::BufReader::with_capacity(0, reader)) .map_err(|e| io::Error::other(format!("{e}"))) } }