reuse rlp generation

This commit is contained in:
keorn 2016-11-24 19:57:58 +00:00
parent 8f37807d4b
commit 04acdd6ca0
1 changed files with 4 additions and 8 deletions

View File

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