// 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::{
hash,
collections::HashMap,
sync::Arc,
};
use crate::base_pool as base;
use crate::error;
use crate::watcher::Watcher;
use serde::Serialize;
use futures::{
Future, FutureExt,
channel::mpsc,
future::{Either, ready, join_all},
};
use sr_primitives::{
generic::BlockId,
traits::{self, SaturatedConversion},
transaction_validity::{TransactionValidity, TransactionTag as Tag, TransactionValidityError},
};
use crate::validated_pool::{ValidatedPool, ValidatedTransaction};
/// 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>>;
/// A type of validated transaction stored in the pool.
pub type ValidatedTransactionFor = ValidatedTransaction<
ExHash,
ExtrinsicFor,
::Error,
>;
/// 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;
/// Validate transaction future.
type ValidationFuture: Future