// Copyright 2018-2019 Parity Technologies (UK) Ltd.
// This file is part of Substrate.
// Substrate is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// Substrate is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with Substrate. If not, see .
use std::{
collections::{HashSet, HashMap},
hash,
sync::Arc,
time,
};
use crate::base_pool as base;
use crate::error;
use crate::listener::Listener;
use crate::rotator::PoolRotator;
use crate::watcher::Watcher;
use serde::Serialize;
use log::debug;
use futures::sync::mpsc;
use parking_lot::{Mutex, RwLock};
use sr_primitives::{
generic::BlockId,
traits::{self, SaturatedConversion},
transaction_validity::{TransactionValidity, TransactionTag as Tag},
};
pub use crate::base_pool::Limit;
/// Modification notification event stream type;
pub type EventStream = mpsc::UnboundedReceiver<()>;
/// Extrinsic hash type for a pool.
pub type ExHash = ::Hash;
/// Block hash type for a pool.
pub type BlockHash = <::Block as traits::Block>::Hash;
/// Extrinsic type for a pool.
pub type ExtrinsicFor = <::Block as traits::Block>::Extrinsic;
/// Block number type for the ChainApi
pub type NumberFor = traits::NumberFor<::Block>;
/// A type of transaction stored in the pool
pub type TransactionFor = Arc, ExtrinsicFor>>;
/// Concrete extrinsic validation and query logic.
pub trait ChainApi: Send + Sync {
/// Block type.
type Block: traits::Block;
/// Transaction Hash type
type Hash: hash::Hash + Eq + traits::Member + Serialize;
/// Error type.
type Error: From + error::IntoPoolError;
/// Verify extrinsic at given block.
fn validate_transaction(&self, at: &BlockId, uxt: ExtrinsicFor) -> Result;
/// Returns a block number given the block id.
fn block_id_to_number(&self, at: &BlockId) -> Result