mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-14 10:22:38 +00:00
Change state_hash to be a struct
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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>;
|
||||
|
||||
Reference in New Issue
Block a user