Skip to content

Commit

Permalink
zcash_protocol: Added constructors to LocalNetwork
Browse files Browse the repository at this point in the history
  • Loading branch information
Oscar-Pepper committed Mar 18, 2024
1 parent e0227ed commit f668e1f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
2 changes: 2 additions & 0 deletions components/zcash_protocol/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ and this library adheres to Rust's notion of
### Added
- `zcash_protocol::memo`:
- `impl TryFrom<&MemoBytes> for Memo`
- `zcash_protocol::local_consensus`:
- `new`, `all_upgrades_active` and `canopy_active` constructors to `LocalNetwork`

### Removed
- `unstable-nu6` and `zfuture` feature flags (use `--cfg zcash_unstable=\"nu6\"`
Expand Down
31 changes: 31 additions & 0 deletions components/zcash_protocol/src/local_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,37 @@ pub struct LocalNetwork {
pub z_future: Option<BlockHeight>,
}

impl LocalNetwork {
pub fn new(

Check warning on line 47 in components/zcash_protocol/src/local_consensus.rs

View check run for this annotation

Codecov / codecov/patch

components/zcash_protocol/src/local_consensus.rs#L47

Added line #L47 was not covered by tests
overwinter: u64,
sapling: u64,
blossom: u64,
heartwood: u64,
canopy: u64,
nu5: u64,
) -> Self {
LocalNetwork {
overwinter: Some(BlockHeight::from_u32(overwinter as u32)),
sapling: Some(BlockHeight::from_u32(sapling as u32)),
blossom: Some(BlockHeight::from_u32(blossom as u32)),
heartwood: Some(BlockHeight::from_u32(heartwood as u32)),
canopy: Some(BlockHeight::from_u32(canopy as u32)),
nu5: Some(BlockHeight::from_u32(nu5 as u32)),

Check warning on line 61 in components/zcash_protocol/src/local_consensus.rs

View check run for this annotation

Codecov / codecov/patch

components/zcash_protocol/src/local_consensus.rs#L56-L61

Added lines #L56 - L61 were not covered by tests
}
}

/// Creates a `LocalNetwork` with all network upgrades initially active.
pub fn all_upgrades_active() -> Self {
Self::new(1, 1, 1, 1, 1, 1)

Check warning on line 67 in components/zcash_protocol/src/local_consensus.rs

View check run for this annotation

Codecov / codecov/patch

components/zcash_protocol/src/local_consensus.rs#L66-L67

Added lines #L66 - L67 were not covered by tests
}

/// Creates a `LocalNetwork` with all network upgrades up to and including canopy
/// initally active.
pub fn canopy_active(nu5_activation_height: u64) -> Self {
Self::new(1, 1, 1, 1, 1, nu5_activation_height)

Check warning on line 73 in components/zcash_protocol/src/local_consensus.rs

View check run for this annotation

Codecov / codecov/patch

components/zcash_protocol/src/local_consensus.rs#L72-L73

Added lines #L72 - L73 were not covered by tests
}
}

/// Parameters implementation for `LocalNetwork`
impl Parameters for LocalNetwork {
fn network_type(&self) -> NetworkType {
Expand Down

0 comments on commit f668e1f

Please sign in to comment.