mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 19:21:13 +00:00
Make AuthorityId generic (#1296)
* BlockAuthorityId convenience type * Rename AuthorityId -> Ed25519AuthorityId to make it more precise * Generalize AuthorityId up to substrate-client * Fix in client-db * rename: BlockAuthorityId -> AuthorityIdFor * typo: should be digest item * Fix test-runtime authorityId mismatch One states that AuthorityId is u64 while the other states that it's Ed25519AuthorityId. * Fix more u64 - Ed25519AuthorityId mismatch * Fix compile of most of the srml modules * Continue to pin aura and grandpa with ed25519 and fix compile * Add MaybeHash trait * Fix node-runtime compile * Fix network tests
This commit is contained in:
committed by
Benjamin Kampmann
parent
043831cfb0
commit
71d889b692
@@ -22,10 +22,10 @@ use parking_lot::RwLock;
|
||||
use error;
|
||||
use backend::{self, NewBlockState};
|
||||
use light;
|
||||
use primitives::{AuthorityId, storage::well_known_keys};
|
||||
use primitives::storage::well_known_keys;
|
||||
use runtime_primitives::generic::BlockId;
|
||||
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, Zero,
|
||||
NumberFor, As, Digest, DigestItem};
|
||||
NumberFor, As, Digest, DigestItem, AuthorityIdFor};
|
||||
use runtime_primitives::{Justification, StorageMap, ChildrenStorageMap};
|
||||
use blockchain::{self, BlockStatus, HeaderBackend};
|
||||
use state_machine::backend::{Backend as StateBackend, InMemory, Consolidate};
|
||||
@@ -108,7 +108,7 @@ pub struct Blockchain<Block: BlockT> {
|
||||
|
||||
struct Cache<Block: BlockT> {
|
||||
storage: Arc<RwLock<BlockchainStorage<Block>>>,
|
||||
authorities_at: RwLock<HashMap<Block::Hash, Option<Vec<AuthorityId>>>>,
|
||||
authorities_at: RwLock<HashMap<Block::Hash, Option<Vec<AuthorityIdFor<Block>>>>>,
|
||||
}
|
||||
|
||||
impl<Block: BlockT + Clone> Clone for Blockchain<Block> {
|
||||
@@ -368,7 +368,7 @@ impl<Block: BlockT> light::blockchain::Storage<Block> for Blockchain<Block>
|
||||
fn import_header(
|
||||
&self,
|
||||
header: Block::Header,
|
||||
authorities: Option<Vec<AuthorityId>>,
|
||||
authorities: Option<Vec<AuthorityIdFor<Block>>>,
|
||||
state: NewBlockState,
|
||||
aux_ops: Vec<(Vec<u8>, Option<Vec<u8>>)>,
|
||||
) -> error::Result<()> {
|
||||
@@ -409,7 +409,7 @@ impl<Block: BlockT> light::blockchain::Storage<Block> for Blockchain<Block>
|
||||
/// In-memory operation.
|
||||
pub struct BlockImportOperation<Block: BlockT, H: Hasher> {
|
||||
pending_block: Option<PendingBlock<Block>>,
|
||||
pending_authorities: Option<Vec<AuthorityId>>,
|
||||
pending_authorities: Option<Vec<AuthorityIdFor<Block>>>,
|
||||
old_state: InMemory<H>,
|
||||
new_state: Option<InMemory<H>>,
|
||||
changes_trie_update: Option<MemoryDB<H>>,
|
||||
@@ -444,7 +444,7 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn update_authorities(&mut self, authorities: Vec<AuthorityId>) {
|
||||
fn update_authorities(&mut self, authorities: Vec<AuthorityIdFor<Block>>) {
|
||||
self.pending_authorities = Some(authorities);
|
||||
}
|
||||
|
||||
@@ -632,13 +632,13 @@ where
|
||||
{}
|
||||
|
||||
impl<Block: BlockT> Cache<Block> {
|
||||
fn insert(&self, at: Block::Hash, authorities: Option<Vec<AuthorityId>>) {
|
||||
fn insert(&self, at: Block::Hash, authorities: Option<Vec<AuthorityIdFor<Block>>>) {
|
||||
self.authorities_at.write().insert(at, authorities);
|
||||
}
|
||||
}
|
||||
|
||||
impl<Block: BlockT> blockchain::Cache<Block> for Cache<Block> {
|
||||
fn authorities_at(&self, block: BlockId<Block>) -> Option<Vec<AuthorityId>> {
|
||||
fn authorities_at(&self, block: BlockId<Block>) -> Option<Vec<AuthorityIdFor<Block>>> {
|
||||
let hash = match block {
|
||||
BlockId::Hash(hash) => hash,
|
||||
BlockId::Number(number) => self.storage.read().hashes.get(&number).cloned()?,
|
||||
@@ -652,7 +652,7 @@ impl<Block: BlockT> blockchain::Cache<Block> for Cache<Block> {
|
||||
pub fn cache_authorities_at<Block: BlockT>(
|
||||
blockchain: &Blockchain<Block>,
|
||||
at: Block::Hash,
|
||||
authorities: Option<Vec<AuthorityId>>
|
||||
authorities: Option<Vec<AuthorityIdFor<Block>>>
|
||||
) {
|
||||
blockchain.cache.insert(at, authorities);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user