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.
This commit is contained in:
Luke Parker 2024-05-21 07:06:13 -04:00
parent f93214012d
commit 09aac20293
No known key found for this signature in database
2 changed files with 2 additions and 2 deletions

View file

@ -93,7 +93,7 @@ impl ReceivedOutput {
let output; let output;
let outpoint; let outpoint;
{ {
let mut buf_r = BufReader::new(r); let mut buf_r = BufReader::with_capacity(0, r);
output = output =
TxOut::consensus_decode(&mut buf_r).map_err(|_| io::Error::other("invalid TxOut"))?; TxOut::consensus_decode(&mut buf_r).map_err(|_| io::Error::other("invalid TxOut"))?;
outpoint = outpoint =

View file

@ -242,7 +242,7 @@ impl EventualityTrait for Eventuality {
buf buf
} }
fn read_completion<R: io::Read>(reader: &mut R) -> io::Result<Transaction> { fn read_completion<R: io::Read>(reader: &mut R) -> io::Result<Transaction> {
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}"))) .map_err(|e| io::Error::other(format!("{e}")))
} }
} }