Refactor sr_primitives. (#3214)

* refactor sr_primitives.

* Fix try build error.

* Line-width

* Ui test.

* Final fixes.

* Fix build again.

* bring back ui test.

* Fix unsigned import.

* Another ui fix.

* Also refactor substrate-primitives

* Fix benchmarks.

* Fix doc test.

* fix doc tests
This commit is contained in:
Kian Paimani
2019-07-29 14:43:53 +02:00
committed by Bastian Köcher
parent cf80af9255
commit 79feb23a22
259 changed files with 667 additions and 665 deletions
@@ -25,8 +25,8 @@ use log::{trace, debug};
use futures::sync::mpsc;
use lru_cache::LruCache;
use libp2p::PeerId;
use runtime_primitives::traits::{Block as BlockT, Hash, HashFor};
use runtime_primitives::ConsensusEngineId;
use sr_primitives::traits::{Block as BlockT, Hash, HashFor};
use sr_primitives::ConsensusEngineId;
pub use crate::message::generic::{Message, ConsensusMessage};
use crate::protocol::Context;
use crate::config::Roles;
@@ -556,7 +556,7 @@ impl<B: BlockT> ConsensusGossip<B> {
#[cfg(test)]
mod tests {
use runtime_primitives::testing::{H256, Block as RawBlock, ExtrinsicWrapper};
use sr_primitives::testing::{H256, Block as RawBlock, ExtrinsicWrapper};
use futures::Stream;
use super::*;
@@ -17,7 +17,7 @@
//! Network packet message types. These get serialized and put into the lower level protocol payload.
use bitflags::bitflags;
use runtime_primitives::{ConsensusEngineId, traits::{Block as BlockT, Header as HeaderT}};
use sr_primitives::{ConsensusEngineId, traits::{Block as BlockT, Header as HeaderT}};
use parity_codec::{Encode, Decode, Input, Output};
pub use self::generic::{
BlockAnnounce, RemoteCallRequest, RemoteReadRequest,
@@ -126,7 +126,7 @@ pub struct RemoteReadResponse {
/// Generic types.
pub mod generic {
use parity_codec::{Encode, Decode};
use runtime_primitives::Justification;
use sr_primitives::Justification;
use crate::config::Roles;
use super::{
RemoteReadResponse, Transactions, Direction,
@@ -29,7 +29,7 @@ use client::light::fetcher::{FetchChecker, RemoteHeaderRequest,
use crate::message::{self, BlockAttributes, Direction, FromBlock, RequestId};
use libp2p::PeerId;
use crate::config::Roles;
use runtime_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor};
use sr_primitives::traits::{Block as BlockT, Header as HeaderT, NumberFor};
/// Remote request timeout.
const REQUEST_TIMEOUT: Duration = Duration::from_secs(15);
@@ -637,7 +637,7 @@ pub mod tests {
use std::sync::Arc;
use std::time::Instant;
use futures::{Future, sync::oneshot};
use runtime_primitives::traits::{Block as BlockT, NumberFor, Header as HeaderT};
use sr_primitives::traits::{Block as BlockT, NumberFor, Header as HeaderT};
use client::{error::{Error as ClientError, Result as ClientResult}};
use client::light::fetcher::{FetchChecker, RemoteHeaderRequest,
ChangesProof, RemoteCallRequest, RemoteReadRequest,
@@ -20,7 +20,7 @@ pub use crate::protocol::event::{DhtEvent, Event};
use crate::protocol::Context;
use libp2p::PeerId;
use runtime_primitives::traits::Block as BlockT;
use sr_primitives::traits::Block as BlockT;
/// A specialization of the substrate network protocol. Handles events and sends messages.
pub trait NetworkSpecialization<B: BlockT>: Send + Sync + 'static {
+1 -1
View File
@@ -39,7 +39,7 @@ use either::Either;
use extra_requests::ExtraRequests;
use libp2p::PeerId;
use log::{debug, trace, warn, info, error};
use runtime_primitives::{
use sr_primitives::{
Justification,
generic::BlockId,
traits::{Block as BlockT, Header, NumberFor, Zero, One, CheckedSub, SaturatedConversion}
@@ -21,7 +21,7 @@ use std::collections::{HashMap, BTreeMap};
use std::collections::hash_map::Entry;
use log::trace;
use libp2p::PeerId;
use runtime_primitives::traits::{Block as BlockT, NumberFor, One};
use sr_primitives::traits::{Block as BlockT, NumberFor, One};
use crate::message;
const MAX_PARALLEL_DOWNLOADS: u32 = 1;
@@ -202,7 +202,7 @@ impl<B: BlockT> BlockCollection<B> {
mod test {
use super::{BlockCollection, BlockData, BlockRangeState};
use crate::{message, PeerId};
use runtime_primitives::testing::{Block as RawBlock, ExtrinsicWrapper};
use sr_primitives::testing::{Block as RawBlock, ExtrinsicWrapper};
use primitives::H256;
type Block = RawBlock<ExtrinsicWrapper<u64>>;
@@ -19,7 +19,7 @@ use crate::protocol::sync::{PeerSync, PeerSyncState};
use fork_tree::ForkTree;
use libp2p::PeerId;
use log::warn;
use runtime_primitives::traits::{Block as BlockT, NumberFor};
use sr_primitives::traits::{Block as BlockT, NumberFor};
use std::collections::{HashMap, HashSet, VecDeque};
use std::time::{Duration, Instant};