Change state_hash to be a struct

This commit is contained in:
Paul Hauner
2018-07-10 19:07:41 +10:00
parent 242318f7c2
commit 0f0212bd1d
6 changed files with 56 additions and 8 deletions

View File

@@ -2,5 +2,8 @@ extern crate ethereum_types;
extern crate blake2;
extern crate crypto_mac;
use super::state::active_state;
use super::state::crystallized_state;
pub mod types;
pub mod bls;

View File

@@ -1,4 +1,6 @@
use super::ethereum_types::{ H256, H160 };
use super::active_state::ActiveState;
use super::crystallized_state::CrystallizedState;
pub use super::blake2::Blake2s;
@@ -10,6 +12,25 @@ pub type Blake2sDigest = H256;
pub type Address = H160;
pub type StateHash = [u8; 64];
pub struct StateHash {
pub active_state: Blake2sDigest,
pub crystallized_state: Blake2sDigest
}
impl StateHash {
pub fn zero() -> Self {
Self {
active_state: Blake2sDigest::zero(),
crystallized_state: Blake2sDigest::zero()
}
}
pub fn from_states(active: &ActiveState, crystal: &CrystallizedState) -> Self {
Self {
active_state: active.blake2s_hash(),
crystallized_state: crystal.blake2s_hash()
}
}
}
pub type Bitfield = Vec<u8>;