This repository has been archived by the owner on Jul 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor constants & primitives (#72)
- Loading branch information
1 parent
e66caee
commit 8382b58
Showing
5 changed files
with
84 additions
and
54 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,38 @@ | ||
// Currency constants. | ||
pub mod currency { | ||
use crate::primitives::Balance; | ||
|
||
// Currencies constants. | ||
// Decimals. | ||
pub const DECIMALS: u32 = 10; | ||
|
||
// 1 PONT. | ||
pub const PONT: Balance = u64::pow(10, DECIMALS); | ||
} | ||
|
||
// Time related constants. | ||
pub mod time { | ||
use crate::primitives::{BlockNumber}; | ||
|
||
/// This determines the average expected block time that we are targeting. | ||
/// Blocks will be produced at a minimum duration defined by `SLOT_DURATION`. | ||
/// `SLOT_DURATION` is picked up by `pallet_timestamp` which is in turn picked | ||
/// up by `pallet_aura` to implement `fn slot_duration()`. | ||
/// | ||
/// Change this to adjust the block time. | ||
pub const MILLISECS_PER_BLOCK: u64 = 6000; | ||
|
||
// Network slot duration allocated for block producing. | ||
pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK; | ||
|
||
// Time is measured by number of blocks. | ||
|
||
// 10 blocks per minute. | ||
pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber); | ||
|
||
// 600 blocks per hour. | ||
pub const HOURS: BlockNumber = MINUTES * 60; | ||
|
||
// 14400 blocks per day. | ||
pub const DAYS: BlockNumber = HOURS * 24; | ||
} |
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,30 @@ | ||
#![cfg_attr(not(feature = "std"), no_std)] | ||
|
||
use sp_runtime::{generic, MultiSignature}; | ||
use sp_runtime::traits::{Verify, IdentifyAccount}; | ||
|
||
/// An index to a block. | ||
pub type BlockNumber = u32; | ||
|
||
/// Alias to 512-bit hash when used in the context of a transaction signature on the chain. | ||
pub type Signature = MultiSignature; | ||
|
||
/// Some way of identifying an account on the chain. We intentionally make it equivalent | ||
/// to the public key of our transaction signing scheme. | ||
pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId; | ||
|
||
/// The type for looking up accounts. We don't expect more than 4 billion of them, but you | ||
/// never know... | ||
pub type AccountIndex = u32; | ||
|
||
/// Balance of an account. | ||
pub type Balance = u64; | ||
|
||
/// Index of a transaction in the chain. | ||
pub type Index = u32; | ||
|
||
/// A hash of some data used by the chain. | ||
pub type Hash = sp_core::H256; | ||
|
||
/// Digest item type. | ||
pub type DigestItem = generic::DigestItem<Hash>; |