Replace convert_transaction with From.

This commit is contained in:
Andreas Fackler 2018-06-26 14:13:15 +02:00
parent fd8e7a5900
commit a2c213d0aa
1 changed files with 10 additions and 9 deletions

View File

@ -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()
}
@ -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,
@ -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> {