Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions fuzz/fuzz_targets/decode_program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ fn do_test(data: &[u8]) {
let wit_iter = BitIter::new(core::iter::repeat(0));
if let Ok(program) = RedeemNode::<Core>::decode(prog_iter, wit_iter) {
let mut prog_reser = Vec::<u8>::new();
let mut wit_reser = std::io::sink();
let mut wit_reser = Vec::<u8>::new();

let mut prog_w = BitWriter::from(&mut prog_reser);
let mut wit_w = BitWriter::from(&mut wit_reser);
let mut prog_w = BitWriter::from(&mut prog_reser as &mut dyn std::io::Write);
let mut wit_w = BitWriter::from(&mut wit_reser as &mut dyn std::io::Write);
program
.encode(&mut prog_w, &mut wit_w)
.expect("encoding to vector");
Expand Down
8 changes: 4 additions & 4 deletions src/bit_encoding/encode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,9 @@ impl<N: node::Marker> SharingTracker<EncodeNode<'_, N>> for EncodeSharing<N> {
/// Encode a Simplicity program to bits, without witness data.
///
/// Returns the number of written bits.
pub fn encode_program<W: io::Write, N: node::Marker>(
pub fn encode_program<N: node::Marker>(
program: &node::Node<N>,
w: &mut BitWriter<W>,
w: &mut BitWriter<&mut dyn io::Write>,
) -> io::Result<usize> {
let iter = EncodeNode::Node(program).post_order_iter::<EncodeSharing<N>>();

Expand All @@ -172,9 +172,9 @@ pub fn encode_program<W: io::Write, N: node::Marker>(
}

/// Encode a node to bits.
fn encode_node<W: io::Write, N: node::Marker>(
fn encode_node<N: node::Marker>(
data: PostOrderIterItem<EncodeNode<N>>,
w: &mut BitWriter<W>,
w: &mut BitWriter<&mut dyn io::Write>,
) -> io::Result<()> {
// Handle Hidden nodes specially
let node = match data.node {
Expand Down
2 changes: 1 addition & 1 deletion src/human_encoding/named_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl<J: Jet> NamedCommitNode<J> {

/// Encode a Simplicity expression to bits without any witness data
#[deprecated(since = "0.5.0", note = "use Self::encode_without_witness instead")]
pub fn encode<W: io::Write>(&self, w: &mut BitWriter<W>) -> io::Result<usize> {
pub fn encode(&self, w: &mut BitWriter<&mut dyn io::Write>) -> io::Result<usize> {
let program_bits = encode::encode_program(self, w)?;
w.flush_all()?;
Ok(program_bits)
Expand Down
2 changes: 1 addition & 1 deletion src/node/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ impl<J: Jet> CommitNode<J> {

/// Encode a Simplicity expression to bits without any witness data
#[deprecated(since = "0.5.0", note = "use Self::encode_without_witness instead")]
pub fn encode<W: io::Write>(&self, w: &mut BitWriter<W>) -> io::Result<usize> {
pub fn encode(&self, w: &mut BitWriter<&mut dyn io::Write>) -> io::Result<usize> {
let program_bits = encode::encode_program(self, w)?;
w.flush_all()?;
Ok(program_bits)
Expand Down
2 changes: 1 addition & 1 deletion src/node/construct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ impl<'brand, J: Jet> ConstructNode<'brand, J> {

/// Encode a Simplicity expression to bits, with no witness data
#[deprecated(since = "0.5.0", note = "use Self::encode_without_witness instead")]
pub fn encode<W: io::Write>(&self, w: &mut BitWriter<W>) -> io::Result<usize> {
pub fn encode(&self, w: &mut BitWriter<&mut dyn io::Write>) -> io::Result<usize> {
let program_bits = encode::encode_program(self, w)?;
w.flush_all()?;
Ok(program_bits)
Expand Down
8 changes: 4 additions & 4 deletions src/node/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ impl<N: Marker> Node<N> {
}

/// Encode a Simplicity expression to bits without any witness data.
pub fn encode_without_witness<W: io::Write>(&self, prog: W) -> io::Result<usize> {
pub fn encode_without_witness(&self, prog: &mut dyn io::Write) -> io::Result<usize> {
let mut w = BitWriter::new(prog);
let program_bits = encode::encode_program(self, &mut w)?;
w.flush_all()?;
Expand All @@ -779,10 +779,10 @@ impl<N: Marker<Witness = Value>> Node<N> {
/// Encode the program and witness data to bits.
///
/// Returns the number of written bits for the program and witness, respectively.
pub fn encode_with_witness<W1: io::Write, W2: io::Write>(
pub fn encode_with_witness(
&self,
prog: W1,
witness: W2,
prog: &mut dyn io::Write,
witness: &mut dyn io::Write,
) -> io::Result<(usize, usize)> {
let mut prog = BitWriter::new(prog);
let mut witness = BitWriter::new(witness);
Expand Down
12 changes: 4 additions & 8 deletions src/node/redeem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -580,15 +580,11 @@ impl<J: Jet> RedeemNode<J> {
///
/// Includes witness data. Returns the number of written bits.
#[deprecated(since = "0.5.0", note = "use Self::encode_with_witness instead")]
pub fn encode<W1, W2>(
pub fn encode(
&self,
prog: &mut BitWriter<W1>,
witness: &mut BitWriter<W2>,
) -> io::Result<usize>
where
W1: io::Write,
W2: io::Write,
{
prog: &mut BitWriter<&mut dyn io::Write>,
witness: &mut BitWriter<&mut dyn io::Write>,
) -> io::Result<usize> {
let sharing_iter = self.post_order_iter::<MaxSharing<Redeem<J>>>();
let program_bits = encode::encode_program(self, prog)?;
prog.flush_all()?;
Expand Down
Loading