Move constants to top of files (even though they're private)

This commit is contained in:
Gav
2018-01-28 21:47:49 +01:00
parent a4e7f17a19
commit c245b38eaa
5 changed files with 36 additions and 36 deletions
@@ -31,6 +31,10 @@ use support::storage;
use primitives::{AccountID, Hash, BlockNumber, Proposal}; use primitives::{AccountID, Hash, BlockNumber, Proposal};
use runtime::{staking, system, session}; use runtime::{staking, system, session};
const APPROVALS_REQUIRED: &[u8] = b"gov:apr";
const CURRENT_PROPOSAL: &[u8] = b"gov:pro";
const APPROVAL_OF: &[u8] = b"gov:app:";
/// The proportion of validators required for a propsal to be approved measured as the number out /// The proportion of validators required for a propsal to be approved measured as the number out
/// of 1000. /// of 1000.
pub fn approval_ppm_required() -> u32 { pub fn approval_ppm_required() -> u32 {
@@ -107,10 +111,6 @@ pub mod internal {
} }
} }
const APPROVALS_REQUIRED: &[u8] = b"gov:apr";
const CURRENT_PROPOSAL: &[u8] = b"gov:pro";
const APPROVAL_OF: &[u8] = b"gov:app:";
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
@@ -23,6 +23,18 @@ use support::{storage, StorageVec};
use primitives::{AccountID, SessionKey, BlockNumber}; use primitives::{AccountID, SessionKey, BlockNumber};
use runtime::{system, staking, consensus}; use runtime::{system, staking, consensus};
const SESSION_LENGTH: &[u8] = b"ses:len";
const CURRENT_INDEX: &[u8] = b"ses:ind";
const LAST_LENGTH_CHANGE: &[u8] = b"ses:llc";
const NEXT_KEY_FOR: &[u8] = b"ses:nxt:";
const NEXT_SESSION_LENGTH: &[u8] = b"ses:nln";
struct ValidatorStorageVec {}
impl StorageVec for ValidatorStorageVec {
type Item = AccountID;
const PREFIX: &'static[u8] = b"ses:val:";
}
/// Get the current set of authorities. These are the session keys. /// Get the current set of authorities. These are the session keys.
pub fn validators() -> Vec<AccountID> { pub fn validators() -> Vec<AccountID> {
ValidatorStorageVec::items() ValidatorStorageVec::items()
@@ -93,18 +105,6 @@ pub mod internal {
} }
} }
const SESSION_LENGTH: &[u8] = b"ses:len";
const CURRENT_INDEX: &[u8] = b"ses:ind";
const LAST_LENGTH_CHANGE: &[u8] = b"ses:llc";
const NEXT_KEY_FOR: &[u8] = b"ses:nxt:";
const NEXT_SESSION_LENGTH: &[u8] = b"ses:nln";
struct ValidatorStorageVec {}
impl StorageVec for ValidatorStorageVec {
type Item = AccountID;
const PREFIX: &'static[u8] = b"ses:val:";
}
/// Move onto next session: register the new authority set. /// Move onto next session: register the new authority set.
fn rotate_session() { fn rotate_session() {
// Increment current session index. // Increment current session index.
@@ -29,6 +29,21 @@ pub type Balance = u64;
/// The amount of bonding period left in an account. Measured in eras. /// The amount of bonding period left in an account. Measured in eras.
pub type Bondage = u64; pub type Bondage = u64;
struct IntentionStorageVec {}
impl StorageVec for IntentionStorageVec {
type Item = AccountID;
const PREFIX: &'static[u8] = b"sta:wil:";
}
const BONDING_DURATION: &[u8] = b"sta:loc";
const VALIDATOR_COUNT: &[u8] = b"sta:vac";
const SESSIONS_PER_ERA: &[u8] = b"sta:spe";
const NEXT_SESSIONS_PER_ERA: &[u8] = b"sta:nse";
const CURRENT_ERA: &[u8] = b"sta:era";
const LAST_ERA_LENGTH_CHANGE: &[u8] = b"sta:lec";
const BALANCE_OF: &[u8] = b"sta:bal:";
const BONDAGE_OF: &[u8] = b"sta:bon:";
/// The length of the bonding duration in eras. /// The length of the bonding duration in eras.
pub fn bonding_duration() -> BlockNumber { pub fn bonding_duration() -> BlockNumber {
storage::get_or_default(BONDING_DURATION) storage::get_or_default(BONDING_DURATION)
@@ -149,21 +164,6 @@ pub mod internal {
} }
} }
struct IntentionStorageVec {}
impl StorageVec for IntentionStorageVec {
type Item = AccountID;
const PREFIX: &'static[u8] = b"sta:wil:";
}
const BONDING_DURATION: &[u8] = b"sta:loc";
const VALIDATOR_COUNT: &[u8] = b"sta:vac";
const SESSIONS_PER_ERA: &[u8] = b"sta:spe";
const NEXT_SESSIONS_PER_ERA: &[u8] = b"sta:nse";
const CURRENT_ERA: &[u8] = b"sta:era";
const LAST_ERA_LENGTH_CHANGE: &[u8] = b"sta:lec";
const BALANCE_OF: &[u8] = b"sta:bal:";
const BONDAGE_OF: &[u8] = b"sta:bon:";
/// The era has changed - enact new staking set. /// The era has changed - enact new staking set.
/// ///
/// NOTE: This always happens immediately before a session change to ensure that new validators /// NOTE: This always happens immediately before a session change to ensure that new validators
@@ -24,6 +24,9 @@ use support::{Hashable, storage, with_env};
use primitives::{Block, BlockNumber, Hash, UncheckedTransaction, TxOrder}; use primitives::{Block, BlockNumber, Hash, UncheckedTransaction, TxOrder};
use runtime::{staking, session}; use runtime::{staking, session};
const BLOCK_HASH_AT: &[u8] = b"sys:old:";
const CODE: &[u8] = b"sys:cod";
/// The current block number being processed. Set by `execute_block`. /// The current block number being processed. Set by `execute_block`.
pub fn block_number() -> BlockNumber { pub fn block_number() -> BlockNumber {
with_env(|e| e.block_number) with_env(|e| e.block_number)
@@ -119,9 +122,6 @@ fn final_checks(_block: &Block) {
}); });
} }
const BLOCK_HASH_AT: &[u8] = b"sys:old:";
const CODE: &[u8] = b"sys:cod";
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;
@@ -18,6 +18,8 @@
use support::storage; use support::storage;
const CURRENT_TIMESTAMP: &[u8] = b"tim:val";
/// Representation of a time. /// Representation of a time.
pub type Timestamp = u64; pub type Timestamp = u64;
@@ -35,8 +37,6 @@ pub mod public {
} }
} }
const CURRENT_TIMESTAMP: &[u8] = b"tim:val";
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {
use super::*; use super::*;