Client provide uncles (#1609)

* feat: add children function to backend

* feat: add test for children hashes

* feat: add uncles function to client

* fix: improve uncles function adds few more tests

* fix: remove children when reverting

* fix: typo and spec version
This commit is contained in:
Marcio Diaz
2019-02-25 11:21:36 +01:00
committed by GitHub
parent 63ec8b335b
commit 43e4544884
10 changed files with 392 additions and 8 deletions
+10 -6
View File
@@ -19,22 +19,23 @@
use std::collections::HashMap;
use std::sync::Arc;
use parking_lot::RwLock;
use crate::error;
use crate::backend::{self, NewBlockState};
use crate::light;
use primitives::{ChangesTrieConfiguration, storage::well_known_keys};
use runtime_primitives::generic::BlockId;
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, Zero,
NumberFor, As, Digest, DigestItem, AuthorityIdFor};
use runtime_primitives::{Justification, StorageOverlay, ChildrenStorageOverlay};
use crate::blockchain::{self, BlockStatus, HeaderBackend};
use state_machine::backend::{Backend as StateBackend, InMemory, Consolidate};
use state_machine::{self, InMemoryChangesTrieStorage, ChangesTrieAnchorBlockId};
use hash_db::Hasher;
use heapsize::HeapSizeOf;
use crate::leaves::LeafSet;
use trie::MemoryDB;
use crate::error;
use crate::backend::{self, NewBlockState};
use crate::light;
use crate::leaves::LeafSet;
use crate::blockchain::{self, BlockStatus, HeaderBackend};
struct PendingBlock<B: BlockT> {
block: StoredBlock<B>,
state: NewBlockState,
@@ -168,7 +169,6 @@ impl<Block: BlockT> Blockchain<Block> {
new_state: NewBlockState,
) -> crate::error::Result<()> {
let number = header.number().clone();
if new_state.is_best() {
self.apply_head(&header)?;
}
@@ -362,6 +362,10 @@ impl<Block: BlockT> blockchain::Backend<Block> for Blockchain<Block> {
fn leaves(&self) -> error::Result<Vec<Block::Hash>> {
Ok(self.storage.read().leaves.hashes())
}
fn children(&self, _parent_hash: Block::Hash) -> error::Result<Vec<Block::Hash>> {
unimplemented!()
}
}
impl<Block: BlockT> backend::AuxStore for Blockchain<Block> {