feat: Add mechanism to check era's features (#120)

This commit is contained in:
Santiago Carmuega 2022-06-15 10:03:29 -03:00 committed by GitHub
parent 00c9e1835e
commit a4840b5ae3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,17 @@
use crate::{Era, Feature};
impl Era {
#[allow(clippy::match_like_matches_macro)]
pub fn has_feature(&self, feature: Feature) -> bool {
match (self, feature) {
(Era::Byron, _) => false,
(Era::Shelley, Feature::SmartContracts) => false,
(Era::Shelley, Feature::TimeLocks) => false,
(Era::Shelley, Feature::MultiAssets) => false,
(Era::Allegra, Feature::MultiAssets) => false,
(Era::Allegra, Feature::SmartContracts) => false,
(Era::Mary, Feature::SmartContracts) => false,
_ => true,
}
}
}

View file

@ -8,6 +8,7 @@ use thiserror::Error;
pub mod block;
pub mod cert;
pub mod era;
pub mod output;
pub mod probe;
mod support;
@ -23,6 +24,15 @@ pub enum Era {
Alonzo, // smart-contracts
}
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
#[non_exhaustive]
pub enum Feature {
TimeLocks,
MultiAssets,
Staking,
SmartContracts,
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub enum MultiEraBlock<'b> {