Skip to content
Snippets Groups Projects
Commit 1ee4a0d9 authored by Wei Tang's avatar Wei Tang
Browse files

Add block vote cache

parent 0d8b2332
Branches
No related merge requests found
......@@ -22,6 +22,12 @@ pub struct ActiveState {
pub recent_block_hashes: Vec<H256>,
}
#[derive(Encode, Decode)]
pub struct BlockVoteInfo {
pub voter_indices: Vec<usize>,
pub total_voter_deposits: u128,
}
impl ActiveState {
pub fn block_hash(&self, current_slot: u64, target_slot: u64) -> H256 {
let current_slot = current_slot as usize;
......
......@@ -4,7 +4,7 @@ use rstd::prelude::*;
use super::{BlockNumber, Hash, Block};
use header::Header;
use state::{ActiveState, CrystallizedState};
use state::{ActiveState, CrystallizedState, BlockVoteInfo};
storage_items! {
Number: b"sys:num" => required BlockNumber;
......@@ -15,6 +15,7 @@ storage_items! {
JustifiedBlockHashes: b"sys:justifiedblockhashes" => required map [ u64 => H256 ];
Active: b"sys:active" => required ActiveState;
Crystallized: b"sys:crystallized" => required CrystallizedState;
BlockVoteCache: b"sys:blockvotecache" => required map [ H256 => BlockVoteInfo ];
}
pub fn initialise_block(header: Header) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment