nimiq_rpc/policy

Types

pub type PolicyConstants {
  PolicyConstants(
    staking_contract_address: String,
    coinbase_address: String,
    transaction_validity_window: Int,
    max_size_micro_body: Int,
    version: Int,
    slots: Int,
    blocks_per_batch: Int,
    batches_per_epoch: Int,
    blocks_per_epoch: Int,
    validator_deposit: Int,
    minimum_stake: Int,
    total_supply: Int,
    block_separation_time: Int,
    jail_epochs: Int,
    genesis_block_number: Int,
  )
}

Constructors

  • PolicyConstants(
      staking_contract_address: String,
      coinbase_address: String,
      transaction_validity_window: Int,
      max_size_micro_body: Int,
      version: Int,
      slots: Int,
      blocks_per_batch: Int,
      batches_per_epoch: Int,
      blocks_per_epoch: Int,
      validator_deposit: Int,
      minimum_stake: Int,
      total_supply: Int,
      block_separation_time: Int,
      jail_epochs: Int,
      genesis_block_number: Int,
    )

Values

pub fn get_batch_at(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Int, String)

Returns the batch number at a given block_number (height).

pub fn get_batch_index_at(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Int, String)

Returns the batch index at a given block number. The batch index is the number of a block relative to the batch it is in. For example, the first block of any batch always has an batch index of 0.

pub fn get_block_after_jail(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Int, String)

Returns the first block after the jail period of a given block number has ended.

pub fn get_block_after_reporting_window(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Int, String)

Returns the first block after the reporting window of a given block number has ended.

pub fn get_election_block_after(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Int, String)

Returns the number (height) of the next election macro block after a given block number (height).

pub fn get_election_block_before(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Int, String)

Returns the number block (height) of the preceding election macro block before a given block number (height). If the given block number is an election macro block, it returns the election macro block before it.

pub fn get_election_block_of(
  client: process.Subject(@internal Message),
  epoch epoch: Int,
) -> Result(Int, String)

Returns the block number of the election macro block of the given epoch (which is always the last block).

pub fn get_epoch_at(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Int, String)

Returns the epoch number at a given block number (height).

pub fn get_epoch_index_at(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Int, String)

Returns the epoch index at a given block number. The epoch index is the number of a block relative to the epoch it is in. For example, the first block of any epoch always has an epoch index of 0.

pub fn get_first_batch_of_epoch(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Bool, String)

Returns a boolean expressing if the batch at a given block number (height) is the first batch of the epoch.

pub fn get_first_block_of(
  client: process.Subject(@internal Message),
  epoch epoch: Int,
) -> Result(Int, String)

Returns the block number of the first block of the given epoch (which is always a micro block).

pub fn get_first_block_of_batch(
  client: process.Subject(@internal Message),
  batch batch: Int,
) -> Result(Int, String)

Returns the block number of the first block of the given batch (which is always a micro block).

pub fn get_last_election_block(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Int, String)

Returns the block number (height) of the last election macro block at a given block number (height). If the given block number is an election macro block, then it returns that block number.

pub fn get_last_macro_block(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Int, String)

Returns block the number (height) of the last macro block at a given block number (height). If the given block number is a macro block, then it returns that block number.

pub fn get_macro_block_after(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Int, String)

Returns the block number (height) of the next macro block after a given block number (height).

pub fn get_macro_block_before(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Int, String)

Returns the block number (height) of the preceding macro block before a given block number (height). If the given block number is a macro block, it returns the macro block before it.

pub fn get_macro_block_of(
  client: process.Subject(@internal Message),
  batch batch: Int,
) -> Result(Int, String)

Returns the block number of the macro block (checkpoint or election) of the given batch (which is always the last block).

pub fn get_policy_constants(
  client: process.Subject(@internal Message),
) -> Result(PolicyConstants, String)

Returns a bundle of policy constants.

pub fn get_supply_at(
  client: process.Subject(@internal Message),
  genesis_supply genesis_supply: Int,
  genesis_time genesis_time: Int,
  current_time current_time: Int,
) -> Result(Int, String)

Returns the supply at a given time (as Unix time) in Lunas (1 NIM = 100,000 Lunas). It is calculated using the following formula:

supply(t) = total_supply - (total_supply - genesis_supply) * supply_decay^t

Where t is the time in milliseconds since the PoS genesis block and genesis_supply is the supply at the genesis of the Nimiq 2.0 chain.

pub fn is_election_block_at(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Bool, String)

Returns a boolean expressing if the block at a given block number (height) is an election macro block.

pub fn is_macro_block_at(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Bool, String)

Returns a boolean expressing if the block at a given block number (height) is a macro block.

pub fn is_micro_block_at(
  client: process.Subject(@internal Message),
  block_number block_number: Int,
) -> Result(Bool, String)

Returns a boolean expressing if the block at a given block number (height) is a micro block.

Search Document