Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
Balance is 128-bit value.
Browse files Browse the repository at this point in the history
  • Loading branch information
gavofyork committed May 14, 2018
1 parent 1de2727 commit de1f0c3
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions polkadot/primitives/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ pub use primitives::block::Id as BlockId;
pub use primitives::block::Log as Log;

/// An index to a block.
pub type BlockNumber = u64;
/// 32-bits will allow for 136 years of blocks assuming 1 block per second.
pub type BlockNumber = u32;

/// Alias to Ed25519 pubkey that identifies an account on the relay chain. This will almost
/// certainly continue to be the same as the substrate's `AuthorityId`.
Expand All @@ -60,11 +61,11 @@ pub type AccountId = primitives::AuthorityId;
/// exactly equivalent to what the substrate calls an "authority".
pub type SessionKey = primitives::AuthorityId;

/// Indentifier for a chain.
pub type ChainId = u64;
/// Indentifier for a chain. 32-bit should be plenty.
pub type ChainId = u32;

/// Index of a transaction in the relay chain.
pub type Index = u64;
/// Index of a transaction in the relay chain. 32-bit should be plenty.
pub type Index = u32;

/// A hash of some data used by the relay chain.
pub type Hash = primitives::H256;
Expand All @@ -76,4 +77,10 @@ pub type Signature = runtime_primitives::Ed25519Signature;
pub type Timestamp = u64;

/// The balance of an account.
pub type Balance = u64;
/// 128-bits (or 38 significant decimal figures) will allow for 10m currency (10^7) at a resolution
/// to all for one second's worth of an annualised 50% reward be paid to a unit holder (10^11 unit
/// denomination), or 10^18 total atomic units, to grow at 50%/year for 51 years (10^9 multiplier)
/// for an eventual total of 10^27 units (27 significant decimal figures).
/// We round denomination to 10^12 (12 sdf), and leave the other redundancy at the upper end so
/// that 32 bits may be multiplied with a balance in 128 bits without worrying about overflow.
pub type Balance = u128;
2 changes: 1 addition & 1 deletion substrate/codec/src/slicable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ macro_rules! impl_non_endians {
)* }
}

impl_endians!(u16, u32, u64, usize, i16, i32, i64, isize);
impl_endians!(u16, u32, u64, u128, usize, i16, i32, i64, i128, isize);
impl_non_endians!(i8, [u8; 1], [u8; 2], [u8; 3], [u8; 4], [u8; 5], [u8; 6], [u8; 7], [u8; 8],
[u8; 10], [u8; 12], [u8; 14], [u8; 16], [u8; 20], [u8; 24], [u8; 28], [u8; 32], [u8; 40],
[u8; 48], [u8; 56], [u8; 64], [u8; 80], [u8; 96], [u8; 112], [u8; 128], bool);
Expand Down
4 changes: 2 additions & 2 deletions substrate/runtime/primitives/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub trait As<T> {
macro_rules! impl_numerics {
( $( $t:ty ),* ) => {
$(
impl_numerics!($t: u8, u16, u32, u64, usize, i8, i16, i32, i64, isize,);
impl_numerics!($t: u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize,);
)*
};
( $f:ty : $t:ty, $( $rest:ty, )* ) => {
Expand All @@ -74,7 +74,7 @@ macro_rules! impl_numerics {
( $f:ty : ) => {}
}

impl_numerics!(u8, u16, u32, u64, usize, i8, i16, i32, i64, isize);
impl_numerics!(u8, u16, u32, u64, u128, usize, i8, i16, i32, i64, i128, isize);

pub struct Identity;
impl<T> Convert<T, T> for Identity {
Expand Down

0 comments on commit de1f0c3

Please sign in to comment.