Add From impls for InventoryHash

This commit is contained in:
Henry de Valence 2020-02-03 15:36:48 -08:00
parent b860461644
commit b24f53f4a1
1 changed files with 14 additions and 0 deletions

View File

@ -40,6 +40,20 @@ pub enum InventoryHash {
FilteredBlock(BlockHeaderHash),
}
impl From<TransactionHash> for InventoryHash {
fn from(tx: TransactionHash) -> InventoryHash {
InventoryHash::Tx(tx)
}
}
impl From<BlockHeaderHash> for InventoryHash {
fn from(block: BlockHeaderHash) -> InventoryHash {
// Auto-convert to Block rather than FilteredBlock because filtered
// blocks aren't useful for Zcash.
InventoryHash::Block(block)
}
}
impl ZcashSerialize for InventoryHash {
fn zcash_serialize<W: Write>(&self, mut writer: W) -> Result<(), SerializationError> {
let (code, bytes) = match *self {