From ba6c0d7110925609c61cd27e61c5f2d6a72a7a19 Mon Sep 17 00:00:00 2001 From: Marek Date: Mon, 22 Apr 2024 20:22:07 +0200 Subject: [PATCH] Impl `zcash_protocol::consensus::Parameters` --- Cargo.lock | 1 + zebra-chain/Cargo.toml | 4 ++-- zebra-chain/src/parameters/network.rs | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e33c79bc1..75ab1682f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5898,6 +5898,7 @@ dependencies = [ "zcash_history", "zcash_note_encryption", "zcash_primitives", + "zcash_protocol", "zebra-test", ] diff --git a/zebra-chain/Cargo.toml b/zebra-chain/Cargo.toml index 2abde7524..617e45157 100644 --- a/zebra-chain/Cargo.toml +++ b/zebra-chain/Cargo.toml @@ -98,6 +98,8 @@ zcash_encoding = "0.2.0" zcash_history = "0.4.0" zcash_note_encryption = "0.4.0" zcash_primitives = { version = "0.13.0-rc.1", features = ["transparent-inputs"] } +zcash_protocol = { version = "0.1.1" } +zcash_address = { version = "0.3.2" } # Time chrono = { version = "0.4.38", default-features = false, features = ["clock", "std", "serde"] } @@ -131,8 +133,6 @@ serde_json = { version = "1.0.115", optional = true } # Production feature async-error and testing feature proptest-impl tokio = { version = "1.37.0", optional = true } -zcash_address = { version = "0.3.2" } - # Experimental feature shielded-scan zcash_client_backend = { version = "0.10.0-rc.1", optional = true } diff --git a/zebra-chain/src/parameters/network.rs b/zebra-chain/src/parameters/network.rs index d8cee48f0..2166a5d16 100644 --- a/zebra-chain/src/parameters/network.rs +++ b/zebra-chain/src/parameters/network.rs @@ -339,3 +339,18 @@ impl zcash_primitives::consensus::Parameters for Network { self.kind().b58_script_address_prefix() } } + +impl zcash_protocol::consensus::Parameters for Network { + fn network_type(&self) -> zcash_address::Network { + self.kind().into() + } + + fn activation_height( + &self, + nu: zcash_protocol::consensus::NetworkUpgrade, + ) -> Option { + NetworkUpgrade::from(nu) + .activation_height(self) + .map(|Height(h)| zcash_protocol::consensus::BlockHeight::from_u32(h)) + } +}