Merge txpool-runtime-api with txpool-api (#4320)

* Remove transaction-pool-runtime-api

* Merge runtime-api with transaction-pool.
This commit is contained in:
Tomasz Drwięga
2019-12-06 17:24:17 +01:00
committed by Bastian Köcher
parent 70db5da6c4
commit 3805393a13
22 changed files with 386 additions and 372 deletions
+1 -1
View File
@@ -39,7 +39,7 @@ use sp_api::ConstructRuntimeApi;
use sp_runtime::{generic, traits::{self, ProvideRuntimeApi}};
use txpool_api::{
TransactionPool, InPoolTransaction, TransactionStatus,
BlockHash, TxHash, TransactionFor, IntoPoolError,
BlockHash, TxHash, TransactionFor, error::IntoPoolError,
};
use session::SessionKeys;
+1 -2
View File
@@ -41,12 +41,11 @@ chain-spec = { package = "sc-chain-spec", path = "../chain-spec" }
client-api = { package = "sc-client-api", path = "../api" }
client = { package = "sc-client", path = "../" }
sp-api = { path = "../../primitives/sr-api" }
txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../primitives/transaction-pool/runtime-api" }
client_db = { package = "sc-client-db", path = "../db" }
codec = { package = "parity-scale-codec", version = "1.0.0" }
sc-executor = { path = "../executor" }
txpool = { package = "sc-transaction-pool", path = "../transaction-pool" }
txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" }
sp-transaction-pool = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" }
rpc-servers = { package = "sc-rpc-server", path = "../rpc-servers" }
rpc = { package = "sc-rpc", path = "../rpc" }
tel = { package = "sc-telemetry", path = "../telemetry" }
+2 -2
View File
@@ -52,7 +52,7 @@ use std::{
};
use sysinfo::{get_current_pid, ProcessExt, System, SystemExt};
use tel::{telemetry, SUBSTRATE_INFO};
use txpool_api::{TransactionPool, TransactionPoolMaintainer};
use sp_transaction_pool::{TransactionPool, TransactionPoolMaintainer};
use sp_blockchain;
use grafana_data_source::{self, record_metrics};
@@ -714,7 +714,7 @@ ServiceBuilder<
<Client<TBackend, TExec, TBl, TRtApi> as ProvideRuntimeApi>::Api:
sp_api::Metadata<TBl> +
offchain::OffchainWorkerApi<TBl> +
txpool_runtime_api::TaggedTransactionQueue<TBl> +
sp_transaction_pool::runtime_api::TaggedTransactionQueue<TBl> +
session::SessionKeys<TBl> +
sp_api::ApiExt<TBl, Error = sp_blockchain::Error>,
TBl: BlockT<Hash = <Blake2Hasher as Hasher>::Out>,
+4 -4
View File
@@ -56,7 +56,7 @@ pub use self::error::Error;
pub use self::builder::{ServiceBuilder, ServiceBuilderCommand};
pub use config::{Configuration, Roles, PruningMode};
pub use chain_spec::{ChainSpec, Properties, RuntimeGenesis, Extension as ChainSpecExtension};
pub use txpool_api::{TransactionPool, TransactionPoolMaintainer, InPoolTransaction, IntoPoolError};
pub use sp_transaction_pool::{TransactionPool, TransactionPoolMaintainer, InPoolTransaction, error::IntoPoolError};
pub use txpool::txpool::Options as TransactionPoolOptions;
pub use client::FinalityNotifications;
pub use rpc::Metadata as RpcMetadata;
@@ -599,7 +599,7 @@ where
Pool: TransactionPool<Block=B, Hash=H, Error=E>,
B: BlockT,
H: std::hash::Hash + Eq + sp_runtime::traits::Member + sp_runtime::traits::MaybeSerialize,
E: IntoPoolError + From<txpool_api::error::Error>,
E: IntoPoolError + From<sp_transaction_pool::error::Error>,
{
pool.ready()
.filter(|t| t.is_propagateable())
@@ -618,7 +618,7 @@ where
Pool: 'static + TransactionPool<Block=B, Hash=H, Error=E>,
B: BlockT,
H: std::hash::Hash + Eq + sp_runtime::traits::Member + sp_runtime::traits::MaybeSerialize,
E: 'static + IntoPoolError + From<txpool_api::error::Error>,
E: 'static + IntoPoolError + From<sp_transaction_pool::error::Error>,
{
fn transactions(&self) -> Vec<(H, <B as BlockT>::Extrinsic)> {
transactions_to_propagate(&*self.pool)
@@ -651,7 +651,7 @@ where
match import_result {
Ok(_) => report_handle.report_peer(who, reputation_change_good),
Err(e) => match e.into_pool_error() {
Ok(txpool_api::error::Error::AlreadyImported(_)) => (),
Ok(sp_transaction_pool::error::Error::AlreadyImported(_)) => (),
Ok(e) => {
report_handle.report_peer(who, reputation_change_bad);
debug!("Error adding transaction to the pool: {:?}", e)
@@ -15,7 +15,6 @@ sp-api = { path = "../../primitives/sr-api" }
sp-runtime = { path = "../../primitives/sr-primitives" }
txpool = { package = "sc-transaction-graph", path = "./graph" }
txpool-api = { package = "sp-transaction-pool-api", path = "../../primitives/transaction-pool" }
txpool-runtime-api = { package = "sp-transaction-pool-runtime-api", path = "../../primitives/transaction-pool/runtime-api" }
client-api = { package = "sc-client-api", path = "../api" }
sp-blockchain = { path = "../../primitives/blockchain" }
+1 -1
View File
@@ -26,7 +26,7 @@ use client_api::{
};
use primitives::{H256, Blake2Hasher, Hasher};
use sp_runtime::{generic::BlockId, traits::{self, Block as BlockT}, transaction_validity::TransactionValidity};
use txpool_runtime_api::TaggedTransactionQueue;
use txpool_api::runtime_api::TaggedTransactionQueue;
use crate::error::{self, Error};
@@ -16,6 +16,8 @@
//! Transaction pool error.
use txpool_api::error::Error as TxPoolError;
/// Transaction pool result.
pub type Result<T> = std::result::Result<T, Error>;
@@ -23,7 +25,7 @@ pub type Result<T> = std::result::Result<T, Error>;
#[derive(Debug, derive_more::Display, derive_more::From)]
pub enum Error {
/// Pool error.
Pool(txpool_api::error::Error),
Pool(TxPoolError),
/// Blockchain error.
Blockchain(sp_blockchain::Error),
/// Error while converting a `BlockId`.
@@ -45,8 +47,8 @@ impl std::error::Error for Error {
}
}
impl txpool_api::IntoPoolError for Error {
fn into_pool_error(self) -> std::result::Result<txpool_api::error::Error, Self> {
impl txpool_api::error::IntoPoolError for Error {
fn into_pool_error(self) -> std::result::Result<TxPoolError, Self> {
match self {
Error::Pool(e) => Ok(e),
e => Err(e),
@@ -37,7 +37,7 @@ use sp_runtime::{
};
use sp_blockchain::HeaderBackend;
use txpool_api::TransactionPoolMaintainer;
use txpool_runtime_api::TaggedTransactionQueue;
use txpool_api::runtime_api::TaggedTransactionQueue;
use txpool::{self, ChainApi};