Skip to content

Commit

Permalink
Replace convert_transaction with From.
Browse files Browse the repository at this point in the history
  • Loading branch information
afck committed Jun 26, 2018
1 parent fd8e7a5 commit a2c213d
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/dynamic_honey_badger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ where
type Error = Error;

fn input(&mut self, input: Self::Input) -> Result<()> {
let tx = self.convert_transaction(input);
self.honey_badger.input(tx)?;
self.honey_badger.input(input.into())?;
self.process_output()
}

Expand Down Expand Up @@ -143,13 +142,6 @@ where
Ok(dyn_hb)
}

fn convert_transaction(&self, input: Input<Tx, NodeUid>) -> Transaction<Tx, NodeUid> {
match input {
Input::User(tx) => Transaction::User(tx),
Input::Change(change) => Transaction::Change(change),
}
}

/// Handles a message for the `HoneyBadger` instance.
fn handle_honey_badger_message(
&mut self,
Expand Down Expand Up @@ -381,6 +373,15 @@ enum Transaction<Tx, NodeUid> {
Accept(NodeUid, Accept, Box<Signature>),
}

impl<Tx, NodeUid> From<Input<Tx, NodeUid>> for Transaction<Tx, NodeUid> {
fn from(input: Input<Tx, NodeUid>) -> Transaction<Tx, NodeUid> {
match input {
Input::User(tx) => Transaction::User(tx),
Input::Change(change) => Transaction::Change(change),
}
}
}

/// A batch of transactions the algorithm has output.
#[derive(Clone)]
pub struct Batch<Tx, NodeUid> {
Expand Down

0 comments on commit a2c213d

Please sign in to comment.