ckb_chain_spec::consensus

Struct Consensus

Source
pub struct Consensus {
Show 31 fields pub id: String, pub genesis_block: BlockView, pub genesis_hash: Byte32, pub dao_type_hash: Byte32, pub secp256k1_blake160_sighash_all_type_hash: Option<Byte32>, pub secp256k1_blake160_multisig_all_type_hash: Option<Byte32>, pub initial_primary_epoch_reward: Capacity, pub secondary_epoch_reward: Capacity, pub max_uncles_num: usize, pub orphan_rate_target: RationalU256, pub epoch_duration_target: u64, pub tx_proposal_window: ProposalWindow, pub proposer_reward_ratio: Ratio, pub pow: Pow, pub cellbase_maturity: EpochNumberWithFraction, pub median_time_block_count: usize, pub max_block_cycles: Cycle, pub max_block_bytes: u64, pub block_version: Version, pub tx_version: Version, pub type_id_code_hash: H256, pub max_block_proposals_limit: u64, pub genesis_epoch_ext: EpochExt, pub satoshi_pubkey_hash: H160, pub satoshi_cell_occupied_ratio: Ratio, pub primary_epoch_reward_halving_interval: EpochNumber, pub permanent_difficulty_in_dummy: bool, pub hardfork_switch: HardForks, pub deployments: HashMap<DeploymentPos, Deployment>, pub versionbits_caches: VersionbitsCache, pub starting_block_limiting_dao_withdrawing_lock: u64,
}
Expand description

Struct Consensus defines various parameters that influence chain consensus

Fields§

§id: String

Names the network.

§genesis_block: BlockView

The genesis block

§genesis_hash: Byte32

The genesis block hash

§dao_type_hash: Byte32

The dao type hash

nervos-dao

§secp256k1_blake160_sighash_all_type_hash: Option<Byte32>

The secp256k1_blake160_sighash_all_type_hash

SECP256K1/blake160

§secp256k1_blake160_multisig_all_type_hash: Option<Byte32>

The secp256k1_blake160_multisig_all_type_hash

SECP256K1/multisig

§initial_primary_epoch_reward: Capacity

The initial primary_epoch_reward

token-issuance

§secondary_epoch_reward: Capacity

The secondary primary_epoch_reward

token-issuance

§max_uncles_num: usize

The maximum amount of uncles allowed for a block

§orphan_rate_target: RationalU256

The expected orphan_rate

§epoch_duration_target: u64

The expected epoch_duration

§tx_proposal_window: ProposalWindow

The two-step-transaction-confirmation proposal window

§proposer_reward_ratio: Ratio

The two-step-transaction-confirmation proposer reward ratio

§pow: Pow

The pow parameters

§cellbase_maturity: EpochNumberWithFraction

The Cellbase maturity For each input, if the referenced output transaction is cellbase, it must have at least cellbase_maturity confirmations; else reject this transaction.

§median_time_block_count: usize

This parameter indicates the count of past blocks used in the median time calculation

§max_block_cycles: Cycle

Maximum cycles that all the scripts in all the commit transactions can take

§max_block_bytes: u64

Maximum number of bytes to use for the entire block

§block_version: Version

The block version number supported

§tx_version: Version

The tx version number supported

§type_id_code_hash: H256

The “TYPE_ID” in hex

§max_block_proposals_limit: u64

The Limit to the number of proposals per block

§genesis_epoch_ext: EpochExt

The genesis epoch information

§satoshi_pubkey_hash: H160

Satoshi’s pubkey hash in Bitcoin genesis.

§satoshi_cell_occupied_ratio: Ratio

Ratio of satoshi cell occupied of capacity, only affects genesis cellbase’s satoshi lock cells.

§primary_epoch_reward_halving_interval: EpochNumber

Primary reward is cut in half every halving_interval epoch which will occur approximately every 4 years.

§permanent_difficulty_in_dummy: bool

Keep difficulty be permanent if the pow is dummy

§hardfork_switch: HardForks

A switch to select hard fork features base on the epoch number.

§deployments: HashMap<DeploymentPos, Deployment>

Soft fork deployments

§versionbits_caches: VersionbitsCache

Soft fork state cache

§starting_block_limiting_dao_withdrawing_lock: u64

Starting block where DAO withdrawing lock is limited in size

Implementations§

Source§

impl Consensus

Source

pub fn genesis_block(&self) -> &BlockView

The genesis block

Source

pub fn proposer_reward_ratio(&self) -> Ratio

The two-step-transaction-confirmation proposer reward ratio

Source

pub fn finalization_delay_length(&self) -> BlockNumber

The two-step-transaction-confirmation block reward delay length

Source

pub fn finalize_target(&self, block_number: BlockNumber) -> Option<BlockNumber>

Get block reward finalize number from specified block number

Source

pub fn genesis_hash(&self) -> Byte32

The genesis block hash

Source

pub fn dao_type_hash(&self) -> Byte32

The dao type hash

nervos-dao

Source

pub fn secp256k1_blake160_sighash_all_type_hash(&self) -> Option<Byte32>

The secp256k1_blake160_sighash_all_type_hash

SECP256K1/blake160

Source

pub fn secp256k1_blake160_multisig_all_type_hash(&self) -> Option<Byte32>

The secp256k1_blake160_multisig_all_type_hash

SECP256K1/multisig

Source

pub fn max_uncles_num(&self) -> usize

The maximum amount of uncles allowed for a block

Source

pub fn min_difficulty(&self) -> U256

The minimum difficulty (genesis_block difficulty)

Source

pub fn initial_primary_epoch_reward(&self) -> Capacity

The minimum difficulty (genesis_block difficulty)

Source

pub fn primary_epoch_reward(&self, epoch_number: u64) -> Capacity

The initial primary_epoch_reward

token-issuance

Source

pub fn primary_epoch_reward_halving_interval(&self) -> EpochNumber

Primary reward is cut in half every halving_interval epoch which will occur approximately every 4 years.

Source

pub fn epoch_duration_target(&self) -> u64

The expected epoch_duration

Source

pub fn genesis_epoch_ext(&self) -> &EpochExt

The genesis epoch information

Source

pub fn max_epoch_length(&self) -> BlockNumber

The maximum epoch length

Source

pub fn min_epoch_length(&self) -> BlockNumber

The minimum epoch length

Source

pub fn secondary_epoch_reward(&self) -> Capacity

The secondary primary_epoch_reward

token-issuance

Source

pub fn orphan_rate_target(&self) -> &RationalU256

The expected orphan_rate

Source

pub fn pow_engine(&self) -> Arc<dyn PowEngine>

The pow_engine

Source

pub fn permanent_difficulty(&self) -> bool

The permanent_difficulty mode

Source

pub fn cellbase_maturity(&self) -> EpochNumberWithFraction

The cellbase_maturity

Source

pub fn median_time_block_count(&self) -> usize

This parameter indicates the count of past blocks used in the median time calculation

Source

pub fn max_block_cycles(&self) -> Cycle

Maximum cycles that all the scripts in all the commit transactions can take

Source

pub fn max_block_bytes(&self) -> u64

Maximum number of bytes to use for the entire block

Source

pub fn max_block_proposals_limit(&self) -> u64

The Limit to the number of proposals per block

Source

pub fn block_version(&self) -> Version

The current block version

Source

pub fn tx_version(&self) -> Version

The current transaction version

Source

pub fn type_id_code_hash(&self) -> &H256

The “TYPE_ID” in hex

Source

pub fn tx_proposal_window(&self) -> ProposalWindow

The two-step-transaction-confirmation proposal window

Source

pub fn starting_block_limiting_dao_withdrawing_lock(&self) -> u64

The starting block number where Nervos DAO withdrawing cell’s lock is size limited.

Source

pub fn next_epoch_ext<P: EpochProvider>( &self, header: &HeaderView, provider: &P, ) -> Option<NextBlockEpoch>

Source

pub fn identify_name(&self) -> String

The network identify name, used for network identify protocol

Source

pub fn get_secp_type_script_hash(&self) -> Byte32

The secp256k1_blake160_sighash_all code hash

Source

pub fn hardfork_switch(&self) -> &HardForks

Returns the hardfork switch.

Source

pub fn rfc0044_active(&self, target: EpochNumber) -> bool

Returns whether rfc0044 is active based on the epoch number

Source

pub fn compute_versionbits<I: VersionbitsIndexer>( &self, parent: &HeaderView, indexer: &I, ) -> Option<Version>

Returns what version a new block should use.

Source

pub fn versionbits_state<I: VersionbitsIndexer>( &self, pos: DeploymentPos, parent: &HeaderView, indexer: &I, ) -> Option<ThresholdState>

Returns specified softfork deployment state

Source

pub fn versionbits_state_since_epoch<I: VersionbitsIndexer>( &self, pos: DeploymentPos, parent: &HeaderView, indexer: &I, ) -> Option<EpochNumber>

Returns the first epoch which the current state applies

Source

pub fn is_public_chain(&self) -> bool

If the CKB block chain specification is for an public chain.

Source

pub fn is_in_delay_window(&self, epoch: &EpochNumberWithFraction) -> bool

Return true if specifies epoch is between delay window.

Trait Implementations§

Source§

impl Clone for Consensus

Source§

fn clone(&self) -> Consensus

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Consensus

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Consensus

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<Consensus> for Consensus

Source§

fn from(consensus: Consensus) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: Any,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Cast to trait Any
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V