Use consts rather than direct names.

This commit is contained in:
Gav
2018-01-28 20:00:06 +01:00
parent 3491e1609e
commit 825cb6b9d4
5 changed files with 86 additions and 58 deletions
@@ -31,7 +31,7 @@ pub fn block_number() -> BlockNumber {
/// Get the block hash of a given block (uses storage).
pub fn block_hash(number: BlockNumber) -> Hash {
storage::get_default(&number.to_keyed_vec(b"sys:old:"))
storage::get_default(&number.to_keyed_vec(BLOCK_HASH_AT))
}
pub mod privileged {
@@ -39,7 +39,7 @@ pub mod privileged {
/// Set the new code.
pub fn set_code(new: &[u8]) {
storage::put_raw(b":code", new);
storage::put_raw(CODE, new);
}
}
@@ -76,7 +76,7 @@ pub mod internal {
// so will wait until a little later.
// store the header hash in storage.
let header_hash_key = header.number.to_keyed_vec(b"sys:old:");
let header_hash_key = header.number.to_keyed_vec(BLOCK_HASH_AT);
storage::put(&header_hash_key, &header.blake2_256());
// execute transactions
@@ -119,6 +119,9 @@ fn final_checks(_block: &Block) {
});
}
const BLOCK_HASH_AT: &[u8] = b"sys:old:";
const CODE: &[u8] = b"sys:cod";
#[cfg(test)]
mod tests {
use super::*;