-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
89 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//! Ergo blockchain state (for ErgoTree evaluation) | ||
use ergo_lib::chain; | ||
|
||
/// Blockchain parameters | ||
#[derive(PartialEq, Eq, Debug, Clone)] | ||
pub struct Parameters(pub(crate) chain::parameters::Parameters); | ||
pub type ParametersPtr = *mut Parameters; | ||
pub type ConstParametersPtr = *const Parameters; | ||
|
||
/// Return default blockchain parameters that were set at genesis | ||
pub unsafe fn parameters_default(parameters_out: *mut ParametersPtr) { | ||
*parameters_out = Box::into_raw(Box::new(Parameters( | ||
chain::parameters::Parameters::default(), | ||
))); | ||
} | ||
|
||
pub unsafe fn parameters_delete(parameters: ParametersPtr) { | ||
if !parameters.is_null() { | ||
let boxed = Box::from_raw(parameters); | ||
std::mem::drop(boxed); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
//! Blockchain parameters. This module defines adjustable blockchain parameters that can be voted on by miners | ||
use wasm_bindgen::prelude::*; | ||
use ergo_lib::chain::parameters; | ||
extern crate derive_more; | ||
use derive_more::{From, Into}; | ||
|
||
/// Blockchain parameters | ||
#[wasm_bindgen] | ||
#[derive(PartialEq, Debug, Clone, Eq, From, Into)] | ||
pub struct Parameters(pub (crate) parameters::Parameters); | ||
|
||
#[wasm_bindgen] | ||
impl Parameters { | ||
/// Return default blockchain parameters that were set at genesis | ||
pub fn default_parameters() -> Parameters { | ||
parameters::Parameters::default().into() | ||
} | ||
/// Get current block version | ||
pub fn block_version(&self) -> i32 { | ||
self.0.block_version() | ||
} | ||
/// Cost of storing 1 byte per Storage Period of block chain | ||
pub fn storage_fee_factor(&self) -> i32 { | ||
self.0.storage_fee_factor() | ||
} | ||
/// Minimum value per byte an output must have to not be considered dust | ||
pub fn min_value_per_byte(&self) -> i32 { | ||
self.0.min_value_per_byte() | ||
} | ||
/// Maximum size of transactions size in a block | ||
pub fn max_block_size(&self) -> i32 { | ||
self.0.max_block_size() | ||
} | ||
/// Maximum total computation cost in a block | ||
pub fn max_block_cost(&self) -> i32 { | ||
self.0.max_block_cost() | ||
} | ||
/// Cost of accessing a single token | ||
pub fn token_access_cost(&self) -> i32 { | ||
self.0.token_access_cost() | ||
} | ||
/// Validation cost per one transaction input | ||
pub fn input_cost(&self) -> i32 { | ||
self.0.input_cost() | ||
} | ||
/// Validation cost per data input | ||
pub fn data_input_cost(&self) -> i32 { | ||
self.0.data_input_cost() | ||
} | ||
/// Validation cost per one output | ||
pub fn output_cost(&self) -> i32 { | ||
self.0.output_cost() | ||
} | ||
} |