reuse rlp generation

This commit is contained in:
keorn 2016-11-24 19:57:58 +00:00
parent 8f37807d4b
commit 04acdd6ca0

View File

@ -18,7 +18,7 @@
use util::*;
use super::{Height, Round, BlockHash, Step};
use error::{Error, BlockError};
use error::Error;
use header::Header;
use rlp::*;
use ethkey::{recover, public_to_address};
@ -49,7 +49,6 @@ impl ConsensusMessage {
})
}
pub fn is_height(&self, height: Height) -> bool {
self.height == height
}
@ -140,16 +139,13 @@ impl Decodable for ConsensusMessage {
})
}
}
impl Encodable for ConsensusMessage {
fn rlp_append(&self, s: &mut RlpStream) {
let info = message_info_rlp(self.height, self.round, self.step, self.block_hash);
s.begin_list(2)
.append(&self.signature)
// TODO: figure out whats wrong with nested list encoding
.begin_list(5)
.append(&self.height)
.append(&self.round)
.append(&self.step)
.append(&self.block_hash.unwrap_or(H256::zero()));
.append_raw(&info, 1);
}
}