From b24f53f4a1dfaa03ce81db15706749f3f2f96320 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Mon, 3 Feb 2020 15:36:48 -0800 Subject: [PATCH] Add From impls for InventoryHash --- zebra-network/src/protocol/external/inv.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/zebra-network/src/protocol/external/inv.rs b/zebra-network/src/protocol/external/inv.rs index f3c6aeac..f22389ba 100644 --- a/zebra-network/src/protocol/external/inv.rs +++ b/zebra-network/src/protocol/external/inv.rs @@ -40,6 +40,20 @@ pub enum InventoryHash { FilteredBlock(BlockHeaderHash), } +impl From for InventoryHash { + fn from(tx: TransactionHash) -> InventoryHash { + InventoryHash::Tx(tx) + } +} + +impl From 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(&self, mut writer: W) -> Result<(), SerializationError> { let (code, bytes) = match *self {