Skip to content

Commit

Permalink
Set the BufReader capacity to 0
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kayabaNerve committed May 21, 2024
1 parent f932140 commit 09aac20
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion coins/bitcoin/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion processor/src/networks/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl EventualityTrait for Eventuality {
buf
}
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}")))
}
}
Expand Down

0 comments on commit 09aac20

Please sign in to comment.