mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 03:01:07 +00:00
combine relay chain primitives into one module
This commit is contained in:
@@ -18,7 +18,7 @@
|
||||
|
||||
use state_machine;
|
||||
use error;
|
||||
use primitives::block;
|
||||
use primitives::relay::block;
|
||||
use blockchain::{self, BlockId};
|
||||
|
||||
/// Block insertion transction. Keeps hold if the inseted block state and data.
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! Polkadot blockchain trait
|
||||
|
||||
use std::fmt::{Display, Formatter, Error as FmtError};
|
||||
use primitives::block;
|
||||
use primitives::relay::block;
|
||||
use error::Result;
|
||||
|
||||
/// Block indentification.
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
//! Tool for creating the genesis block.
|
||||
|
||||
use std::collections::HashMap;
|
||||
use primitives::block::{Block, Header};
|
||||
use primitives::relay::{Block, Header};
|
||||
use triehash::trie_root;
|
||||
|
||||
/// Create a genesis block, given the initial storage.
|
||||
@@ -47,8 +47,7 @@ mod tests {
|
||||
use state_machine::backend::InMemory;
|
||||
use polkadot_executor::executor;
|
||||
use primitives::{AccountId, Hash};
|
||||
use primitives::block::{Number as BlockNumber, Header, Digest};
|
||||
use primitives::transaction::{UncheckedTransaction, Transaction, Function};
|
||||
use primitives::relay::{BlockNumber, Header, Digest, UncheckedTransaction, Transaction, Function};
|
||||
use primitives::contract::CallData;
|
||||
use ed25519::Pair;
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ use error;
|
||||
use backend;
|
||||
use primitives;
|
||||
use ser;
|
||||
use primitives::block::{self, HeaderHash};
|
||||
use primitives::relay::block::{self, HeaderHash};
|
||||
use blockchain::{self, BlockId, BlockStatus};
|
||||
|
||||
fn header_hash(header: &primitives::block::Header) -> primitives::block::HeaderHash {
|
||||
fn header_hash(header: &block::Header) -> block::HeaderHash {
|
||||
primitives::hashing::blake2_256(&ser::to_vec(header)).into()
|
||||
}
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ pub use genesis::construct_genesis_block;
|
||||
pub use blockchain::Info as ChainInfo;
|
||||
pub use blockchain::BlockId;
|
||||
|
||||
use primitives::{block};
|
||||
use primitives::relay::block;
|
||||
use primitives::contract::{CallData, StorageKey, StorageData};
|
||||
|
||||
use blockchain::Backend as BlockchainBackend;
|
||||
|
||||
@@ -64,8 +64,7 @@ mod tests {
|
||||
use native_runtime::runtime::staking::balance;
|
||||
use state_machine::TestExternalities;
|
||||
use primitives::{twox_128, Hash};
|
||||
use primitives::block::{Header, Number as BlockNumber, Block, Digest};
|
||||
use primitives::transaction::{Transaction, UncheckedTransaction, Function};
|
||||
use primitives::relay::{Header, BlockNumber, Block, Digest, Transaction, UncheckedTransaction, Function};
|
||||
use ed25519::Pair;
|
||||
|
||||
const BLOATY_CODE: &[u8] = include_bytes!("../../wasm-runtime/target/wasm32-unknown-unknown/release/runtime_polkadot.wasm");
|
||||
|
||||
@@ -294,8 +294,7 @@ mod tests {
|
||||
use native_runtime::runtime::staking::balance;
|
||||
use state_machine::TestExternalities;
|
||||
use primitives::{twox_128, AccountId};
|
||||
use primitives::block::Header;
|
||||
use primitives::transaction::{Transaction, UncheckedTransaction, Function};
|
||||
use primitives::relay::{Header, Transaction, UncheckedTransaction, Function};
|
||||
use runtime_std;
|
||||
use ed25519::Pair;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ use std::ops::Range;
|
||||
use std::collections::{HashMap, BTreeMap};
|
||||
use std::collections::hash_map::Entry;
|
||||
use network::PeerId;
|
||||
use primitives::block::{Number as BlockNumber};
|
||||
use primitives::relay::BlockNumber;
|
||||
use message;
|
||||
|
||||
const MAX_PARALLEL_DOWNLOADS: u32 = 1;
|
||||
@@ -190,7 +190,7 @@ impl BlockCollection {
|
||||
mod test {
|
||||
use super::{BlockCollection, BlockData};
|
||||
use message;
|
||||
use primitives::block::{HeaderHash};
|
||||
use primitives::relay::{HeaderHash};
|
||||
|
||||
fn is_empty(bc: &BlockCollection) -> bool {
|
||||
bc.blocks.is_empty() &&
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use client::{self, Client as PolkadotClient, ImportResult, ClientInfo, BlockStatus};
|
||||
use client::error::Error;
|
||||
use state_machine;
|
||||
use primitives::block;
|
||||
use primitives::relay::block;
|
||||
|
||||
pub trait Client : Send + Sync {
|
||||
/// Given a hash return a header
|
||||
|
||||
@@ -56,7 +56,7 @@ pub use protocol::{ProtocolStatus};
|
||||
pub use network::{NonReservedPeerMode, ConnectionFilter, ConnectionDirection, NetworkConfiguration};
|
||||
|
||||
// TODO: move it elsewhere
|
||||
fn header_hash(header: &primitives::block::Header) -> primitives::block::HeaderHash {
|
||||
fn header_hash(header: &primitives::relay::Header) -> primitives::relay::HeaderHash {
|
||||
primitives::hashing::blake2_256(&ser::to_vec(header)).into()
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
use std::borrow::Borrow;
|
||||
use primitives::parachain::Id as ParachainId;
|
||||
use primitives::AccountId;
|
||||
use primitives::block::{Number as BlockNumber, HeaderHash, Header, Body};
|
||||
use primitives::relay::{BlockNumber, HeaderHash, Header, Body};
|
||||
use service::Role as RoleFlags;
|
||||
|
||||
pub type RequestId = u64;
|
||||
|
||||
@@ -20,7 +20,7 @@ use std::sync::Arc;
|
||||
use parking_lot::RwLock;
|
||||
use serde_json;
|
||||
use std::time;
|
||||
use primitives::block::{HeaderHash, TransactionHash, Number as BlockNumber, Header};
|
||||
use primitives::relay::{HeaderHash, TransactionHash, BlockNumber, Header};
|
||||
use network::{PeerId, NodeId};
|
||||
|
||||
use message::{self, Message};
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::collections::{BTreeMap};
|
||||
use std::io;
|
||||
use network::{NetworkProtocolHandler, NetworkService, NetworkContext, HostInfo, PeerId, ProtocolId,
|
||||
NetworkConfiguration , NonReservedPeerMode, ErrorKind};
|
||||
use primitives::block::{TransactionHash, Header};
|
||||
use primitives::relay::{TransactionHash, Header};
|
||||
use core_io::{TimerToken};
|
||||
use io::NetSyncIo;
|
||||
use protocol::{Protocol, ProtocolStatus, PeerInfo as ProtocolPeerInfo, TransactionStats};
|
||||
|
||||
@@ -19,7 +19,7 @@ use io::SyncIo;
|
||||
use protocol::Protocol;
|
||||
use network::PeerId;
|
||||
use client::{ImportResult, BlockStatus, ClientInfo};
|
||||
use primitives::block::{HeaderHash, Number as BlockNumber, Header};
|
||||
use primitives::relay::{HeaderHash, BlockNumber, Header};
|
||||
use blocks::{self, BlockCollection};
|
||||
use message::{self, Message};
|
||||
use super::header_hash;
|
||||
|
||||
@@ -65,12 +65,11 @@ macro_rules! try_opt {
|
||||
}
|
||||
|
||||
mod bytes;
|
||||
pub mod block;
|
||||
pub mod contract;
|
||||
pub mod hash;
|
||||
pub mod hexdisplay;
|
||||
pub mod parachain;
|
||||
pub mod transaction;
|
||||
pub mod relay;
|
||||
pub mod uint;
|
||||
pub mod validator;
|
||||
|
||||
@@ -81,6 +80,7 @@ mod tests;
|
||||
pub mod hashing;
|
||||
|
||||
pub use self::hash::{H160, H256};
|
||||
pub use self::relay::BlockNumber;
|
||||
pub use self::uint::{U256, U512};
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
@@ -101,9 +101,6 @@ pub type SessionKey = AccountId;
|
||||
/// Indentifier for a chain.
|
||||
pub type ChainID = u64;
|
||||
|
||||
/// Index of a block in the chain.
|
||||
pub type BlockNumber = u64;
|
||||
|
||||
/// Index of a transaction.
|
||||
pub type TxOrder = u64;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ use bytes::Vec;
|
||||
use codec::Slicable;
|
||||
use hash::H256;
|
||||
use parachain;
|
||||
use transaction::UncheckedTransaction;
|
||||
use relay::transaction::UncheckedTransaction;
|
||||
|
||||
/// Used to refer to a block number.
|
||||
pub type Number = u64;
|
||||
@@ -0,0 +1,9 @@
|
||||
//! Relay chain primitives.
|
||||
|
||||
pub mod block;
|
||||
pub mod transaction;
|
||||
|
||||
pub use self::block::*;
|
||||
pub use self::transaction::*;
|
||||
|
||||
pub use self::block::Number as BlockNumber;
|
||||
+2
-2
@@ -25,7 +25,7 @@ use std::fmt;
|
||||
#[cfg(not(feature = "std"))]
|
||||
use alloc::fmt;
|
||||
|
||||
use block::Number as BlockNumber;
|
||||
use relay::block::Number as BlockNumber;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "std", derive(Serialize, Deserialize))]
|
||||
@@ -217,7 +217,7 @@ pub enum Function {
|
||||
/// Make a proposal for the governance system.
|
||||
GovernancePropose(Proposal),
|
||||
/// Approve a proposal for the governance system.
|
||||
GovernanceApprove(::block::Number),
|
||||
GovernanceApprove(BlockNumber),
|
||||
}
|
||||
|
||||
impl Slicable for Function {
|
||||
@@ -19,8 +19,8 @@
|
||||
use codec::Slicable;
|
||||
|
||||
use ::AccountId;
|
||||
use block::{Block, Header, Digest, Log};
|
||||
use transaction::{UncheckedTransaction, Transaction, Function};
|
||||
use relay::block::{Block, Header, Digest, Log};
|
||||
use relay::transaction::{UncheckedTransaction, Transaction, Function};
|
||||
|
||||
#[test]
|
||||
fn serialise_transaction_works() {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
//! Polkadot blockchain API.
|
||||
|
||||
use primitives::block;
|
||||
use primitives::relay::block;
|
||||
use client;
|
||||
use state_machine;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ mod error;
|
||||
mod tests;
|
||||
|
||||
use client::{self, Client};
|
||||
use primitives::{block};
|
||||
use primitives::relay::block;
|
||||
use primitives::contract::{CallData, StorageKey, StorageData};
|
||||
use state_machine;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ pub mod prelude {
|
||||
|
||||
/// Type definitions and helpers for transactions.
|
||||
pub mod transaction {
|
||||
pub use primitives::transaction::{Transaction, UncheckedTransaction};
|
||||
pub use primitives::relay::{Transaction, UncheckedTransaction};
|
||||
use primitives::Signature;
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
|
||||
@@ -40,8 +40,7 @@ pub mod runtime;
|
||||
|
||||
use runtime_std::prelude::*;
|
||||
use codec::Slicable;
|
||||
use primitives::transaction::UncheckedTransaction;
|
||||
use primitives::block::{Header, Block};
|
||||
use primitives::relay::{Header, Block, UncheckedTransaction};
|
||||
|
||||
/// Execute a block, with `input` being the canonical serialisation of the block. Returns the
|
||||
/// empty vector.
|
||||
|
||||
@@ -20,7 +20,7 @@ use std::collections::HashMap;
|
||||
use runtime_std::twox_128;
|
||||
use codec::{KeyedVec, Joiner};
|
||||
use support::Hashable;
|
||||
use primitives::block::{Number as BlockNumber, Block};
|
||||
use primitives::relay::{Number as BlockNumber, Block};
|
||||
use primitives::AccountId;
|
||||
use runtime::staking::Balance;
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ use runtime_std::prelude::*;
|
||||
use codec::KeyedVec;
|
||||
use support::storage;
|
||||
use primitives::{AccountId, Hash, BlockNumber};
|
||||
use primitives::transaction::Proposal;
|
||||
use primitives::relay::Proposal;
|
||||
use runtime::{staking, system, session};
|
||||
|
||||
const APPROVALS_REQUIRED: &[u8] = b"gov:apr";
|
||||
@@ -95,7 +95,7 @@ pub mod privileged {
|
||||
|
||||
pub mod internal {
|
||||
use super::*;
|
||||
use primitives::transaction::{Proposal, InternalFunction};
|
||||
use primitives::relay::{Proposal, InternalFunction};
|
||||
|
||||
/// Current era is ending; we should finish up any proposals.
|
||||
pub fn end_of_an_era() {
|
||||
@@ -150,7 +150,7 @@ mod tests {
|
||||
use codec::{KeyedVec, Joiner};
|
||||
use support::{one, two, with_env};
|
||||
use primitives::AccountId;
|
||||
use primitives::transaction::InternalFunction;
|
||||
use primitives::relay::InternalFunction;
|
||||
use runtime::{staking, session};
|
||||
|
||||
fn new_test_ext() -> TestExternalities {
|
||||
|
||||
@@ -21,9 +21,8 @@ use runtime_std::prelude::*;
|
||||
use runtime_std::{mem, storage_root, enumerated_trie_root};
|
||||
use codec::{KeyedVec, Slicable};
|
||||
use support::{Hashable, storage, with_env};
|
||||
use primitives::{AccountId, Hash, TxOrder};
|
||||
use primitives::block::{Block, Header, Number as BlockNumber};
|
||||
use primitives::transaction::{UncheckedTransaction, Function};
|
||||
use primitives::{AccountId, Hash, TxOrder, BlockNumber};
|
||||
use primitives::relay::{Block, Header, UncheckedTransaction, Function, Log};
|
||||
use runtime::{staking, session};
|
||||
|
||||
const NONCE_OF: &[u8] = b"sys:non:";
|
||||
@@ -55,7 +54,7 @@ pub mod internal {
|
||||
struct CheckedTransaction(UncheckedTransaction);
|
||||
|
||||
/// Deposits a log and ensures it matches the blocks log data.
|
||||
pub fn deposit_log(log: ::primitives::block::Log) {
|
||||
pub fn deposit_log(log: Log) {
|
||||
with_env(|e| e.digest.logs.push(log));
|
||||
}
|
||||
|
||||
@@ -222,8 +221,7 @@ mod tests {
|
||||
use runtime_std::{with_externalities, twox_128, TestExternalities};
|
||||
use codec::{Joiner, KeyedVec, Slicable};
|
||||
use support::{StaticHexInto, HexDisplay, one, two};
|
||||
use primitives::transaction::{UncheckedTransaction, Transaction, Function};
|
||||
use primitives::block::{Header, Digest};
|
||||
use primitives::relay::{Header, Digest, UncheckedTransaction, Transaction, Function};
|
||||
use runtime::staking;
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -21,7 +21,7 @@ use runtime_std::mem;
|
||||
use runtime_std::cell::RefCell;
|
||||
use runtime_std::rc::Rc;
|
||||
|
||||
use primitives::block::{Number as BlockNumber, Digest};
|
||||
use primitives::relay::{BlockNumber, Digest};
|
||||
use primitives::Hash;
|
||||
|
||||
#[derive(Default)]
|
||||
|
||||
@@ -338,7 +338,7 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn proposals_can_be_stored() {
|
||||
use primitives::transaction::{Proposal, InternalFunction};
|
||||
use primitives::relay::{Proposal, InternalFunction};
|
||||
let mut t = TestExternalities { storage: HashMap::new(), };
|
||||
with_externalities(&mut t, || {
|
||||
let x = Proposal {
|
||||
|
||||
Reference in New Issue
Block a user