finished for BlockLocation

This commit is contained in:
Nikolay Volf 2016-04-17 18:30:42 +03:00
parent bd2149406d
commit 17f26ad588
1 changed files with 14 additions and 0 deletions

View File

@ -80,3 +80,17 @@ impl ToBytesWithMap for BranchBecomingCanonChainData {
(&self.enacted, &self.retracted, &self.ancestor).to_bytes_map()
}
}
impl ToBytesWithMap for BlockLocation {
fn to_bytes_map(&self) -> Vec<u8> {
match *self {
BlockLocation::CanonChain => vec![0u8],
BlockLocation::Branch => vec![1u8],
BlockLocation::BranchBecomingCanonChain(ref data) => {
let mut bytes = (&data.enacted, &data.retracted, &data.ancestor).to_bytes_map();
bytes.insert(0, 2u8);
bytes
}
}
}
}