never speak of the verifier cache again (#3628)
This commit is contained in:
+4
-7
@@ -17,7 +17,6 @@
|
||||
use crate::chain::{Chain, SyncState};
|
||||
use crate::core::core::hash::Hash;
|
||||
use crate::core::core::transaction::Transaction;
|
||||
use crate::core::core::verifier_cache::VerifierCache;
|
||||
use crate::handlers::blocks_api::{BlockHandler, HeaderHandler};
|
||||
use crate::handlers::chain_api::{ChainHandler, KernelHandler, OutputHandler};
|
||||
use crate::handlers::pool_api::PoolHandler;
|
||||
@@ -39,22 +38,20 @@ use std::sync::Weak;
|
||||
/// Methods in this API are intended to be 'single use'.
|
||||
///
|
||||
|
||||
pub struct Foreign<B, P, V>
|
||||
pub struct Foreign<B, P>
|
||||
where
|
||||
B: BlockChain,
|
||||
P: PoolAdapter,
|
||||
V: VerifierCache + 'static,
|
||||
{
|
||||
pub chain: Weak<Chain>,
|
||||
pub tx_pool: Weak<RwLock<pool::TransactionPool<B, P, V>>>,
|
||||
pub tx_pool: Weak<RwLock<pool::TransactionPool<B, P>>>,
|
||||
pub sync_state: Weak<SyncState>,
|
||||
}
|
||||
|
||||
impl<B, P, V> Foreign<B, P, V>
|
||||
impl<B, P> Foreign<B, P>
|
||||
where
|
||||
B: BlockChain,
|
||||
P: PoolAdapter,
|
||||
V: VerifierCache + 'static,
|
||||
{
|
||||
/// Create a new API instance with the chain, transaction pool, peers and `sync_state`. All subsequent
|
||||
/// API calls will operate on this instance of node API.
|
||||
@@ -71,7 +68,7 @@ where
|
||||
|
||||
pub fn new(
|
||||
chain: Weak<Chain>,
|
||||
tx_pool: Weak<RwLock<pool::TransactionPool<B, P, V>>>,
|
||||
tx_pool: Weak<RwLock<pool::TransactionPool<B, P>>>,
|
||||
sync_state: Weak<SyncState>,
|
||||
) -> Self {
|
||||
Foreign {
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
use crate::core::core::hash::Hash;
|
||||
use crate::core::core::transaction::Transaction;
|
||||
use crate::core::core::verifier_cache::VerifierCache;
|
||||
use crate::foreign::Foreign;
|
||||
use crate::pool::PoolEntry;
|
||||
use crate::pool::{BlockChain, PoolAdapter};
|
||||
@@ -742,11 +741,10 @@ pub trait ForeignRpc: Sync + Send {
|
||||
fn push_transaction(&self, tx: Transaction, fluff: Option<bool>) -> Result<(), ErrorKind>;
|
||||
}
|
||||
|
||||
impl<B, P, V> ForeignRpc for Foreign<B, P, V>
|
||||
impl<B, P> ForeignRpc for Foreign<B, P>
|
||||
where
|
||||
B: BlockChain,
|
||||
P: PoolAdapter,
|
||||
V: VerifierCache + 'static,
|
||||
{
|
||||
fn get_header(
|
||||
&self,
|
||||
@@ -856,7 +854,7 @@ macro_rules! doctest_helper_json_rpc_foreign_assert_response {
|
||||
// create temporary grin server, run jsonrpc request on node api, delete server, return
|
||||
// json response.
|
||||
|
||||
{
|
||||
{
|
||||
/*use grin_servers::test_framework::framework::run_doctest;
|
||||
use grin_util as util;
|
||||
use serde_json;
|
||||
@@ -890,6 +888,6 @@ macro_rules! doctest_helper_json_rpc_foreign_assert_response {
|
||||
serde_json::to_string_pretty(&expected_response).unwrap()
|
||||
);
|
||||
}*/
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+7
-12
@@ -26,7 +26,6 @@ use crate::auth::{
|
||||
};
|
||||
use crate::chain;
|
||||
use crate::chain::{Chain, SyncState};
|
||||
use crate::core::core::verifier_cache::VerifierCache;
|
||||
use crate::foreign::Foreign;
|
||||
use crate::foreign_rpc::ForeignRpc;
|
||||
use crate::owner::Owner;
|
||||
@@ -48,10 +47,10 @@ use std::sync::{Arc, Weak};
|
||||
|
||||
/// Listener version, providing same API but listening for requests on a
|
||||
/// port and wrapping the calls
|
||||
pub fn node_apis<B, P, V>(
|
||||
pub fn node_apis<B, P>(
|
||||
addr: &str,
|
||||
chain: Arc<chain::Chain>,
|
||||
tx_pool: Arc<RwLock<pool::TransactionPool<B, P, V>>>,
|
||||
tx_pool: Arc<RwLock<pool::TransactionPool<B, P>>>,
|
||||
peers: Arc<p2p::Peers>,
|
||||
sync_state: Arc<chain::SyncState>,
|
||||
api_secret: Option<String>,
|
||||
@@ -61,7 +60,6 @@ pub fn node_apis<B, P, V>(
|
||||
where
|
||||
B: BlockChain + 'static,
|
||||
P: PoolAdapter + 'static,
|
||||
V: VerifierCache + 'static,
|
||||
{
|
||||
let mut router = Router::new();
|
||||
|
||||
@@ -173,27 +171,25 @@ impl crate::router::Handler for OwnerAPIHandlerV2 {
|
||||
}
|
||||
|
||||
/// V2 API Handler/Wrapper for foreign functions
|
||||
pub struct ForeignAPIHandlerV2<B, P, V>
|
||||
pub struct ForeignAPIHandlerV2<B, P>
|
||||
where
|
||||
B: BlockChain,
|
||||
P: PoolAdapter,
|
||||
V: VerifierCache + 'static,
|
||||
{
|
||||
pub chain: Weak<Chain>,
|
||||
pub tx_pool: Weak<RwLock<pool::TransactionPool<B, P, V>>>,
|
||||
pub tx_pool: Weak<RwLock<pool::TransactionPool<B, P>>>,
|
||||
pub sync_state: Weak<SyncState>,
|
||||
}
|
||||
|
||||
impl<B, P, V> ForeignAPIHandlerV2<B, P, V>
|
||||
impl<B, P> ForeignAPIHandlerV2<B, P>
|
||||
where
|
||||
B: BlockChain,
|
||||
P: PoolAdapter,
|
||||
V: VerifierCache + 'static,
|
||||
{
|
||||
/// Create a new foreign API handler for GET methods
|
||||
pub fn new(
|
||||
chain: Weak<Chain>,
|
||||
tx_pool: Weak<RwLock<pool::TransactionPool<B, P, V>>>,
|
||||
tx_pool: Weak<RwLock<pool::TransactionPool<B, P>>>,
|
||||
sync_state: Weak<SyncState>,
|
||||
) -> Self {
|
||||
ForeignAPIHandlerV2 {
|
||||
@@ -204,11 +200,10 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
impl<B, P, V> crate::router::Handler for ForeignAPIHandlerV2<B, P, V>
|
||||
impl<B, P> crate::router::Handler for ForeignAPIHandlerV2<B, P>
|
||||
where
|
||||
B: BlockChain + 'static,
|
||||
P: PoolAdapter + 'static,
|
||||
V: VerifierCache + 'static,
|
||||
{
|
||||
fn post(&self, req: Request<Body>) -> ResponseFuture {
|
||||
let api = Foreign::new(
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
use super::utils::w;
|
||||
use crate::core::core::hash::Hashed;
|
||||
use crate::core::core::verifier_cache::VerifierCache;
|
||||
use crate::core::core::Transaction;
|
||||
use crate::core::ser::{self, ProtocolVersion};
|
||||
use crate::pool::{self, BlockChain, PoolAdapter, PoolEntry};
|
||||
@@ -30,20 +29,18 @@ use std::sync::Weak;
|
||||
|
||||
/// Get basic information about the transaction pool.
|
||||
/// GET /v1/pool
|
||||
pub struct PoolInfoHandler<B, P, V>
|
||||
pub struct PoolInfoHandler<B, P>
|
||||
where
|
||||
B: BlockChain,
|
||||
P: PoolAdapter,
|
||||
V: VerifierCache + 'static,
|
||||
{
|
||||
pub tx_pool: Weak<RwLock<pool::TransactionPool<B, P, V>>>,
|
||||
pub tx_pool: Weak<RwLock<pool::TransactionPool<B, P>>>,
|
||||
}
|
||||
|
||||
impl<B, P, V> Handler for PoolInfoHandler<B, P, V>
|
||||
impl<B, P> Handler for PoolInfoHandler<B, P>
|
||||
where
|
||||
B: BlockChain,
|
||||
P: PoolAdapter,
|
||||
V: VerifierCache + 'static,
|
||||
{
|
||||
fn get(&self, _req: Request<Body>) -> ResponseFuture {
|
||||
let pool_arc = w_fut!(&self.tx_pool);
|
||||
@@ -55,20 +52,18 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub struct PoolHandler<B, P, V>
|
||||
pub struct PoolHandler<B, P>
|
||||
where
|
||||
B: BlockChain,
|
||||
P: PoolAdapter,
|
||||
V: VerifierCache + 'static,
|
||||
{
|
||||
pub tx_pool: Weak<RwLock<pool::TransactionPool<B, P, V>>>,
|
||||
pub tx_pool: Weak<RwLock<pool::TransactionPool<B, P>>>,
|
||||
}
|
||||
|
||||
impl<B, P, V> PoolHandler<B, P, V>
|
||||
impl<B, P> PoolHandler<B, P>
|
||||
where
|
||||
B: BlockChain,
|
||||
P: PoolAdapter,
|
||||
V: VerifierCache + 'static,
|
||||
{
|
||||
pub fn get_pool_size(&self) -> Result<usize, Error> {
|
||||
let pool_arc = w(&self.tx_pool)?;
|
||||
@@ -117,23 +112,21 @@ struct TxWrapper {
|
||||
|
||||
/// Push new transaction to our local transaction pool.
|
||||
/// POST /v1/pool/push_tx
|
||||
pub struct PoolPushHandler<B, P, V>
|
||||
pub struct PoolPushHandler<B, P>
|
||||
where
|
||||
B: BlockChain,
|
||||
P: PoolAdapter,
|
||||
V: VerifierCache + 'static,
|
||||
{
|
||||
pub tx_pool: Weak<RwLock<pool::TransactionPool<B, P, V>>>,
|
||||
pub tx_pool: Weak<RwLock<pool::TransactionPool<B, P>>>,
|
||||
}
|
||||
|
||||
async fn update_pool<B, P, V>(
|
||||
pool: Weak<RwLock<pool::TransactionPool<B, P, V>>>,
|
||||
async fn update_pool<B, P>(
|
||||
pool: Weak<RwLock<pool::TransactionPool<B, P>>>,
|
||||
req: Request<Body>,
|
||||
) -> Result<(), Error>
|
||||
where
|
||||
B: BlockChain,
|
||||
P: PoolAdapter,
|
||||
V: VerifierCache + 'static,
|
||||
{
|
||||
let pool = w(&pool)?;
|
||||
let params = QueryParams::from(req.uri().query());
|
||||
@@ -169,11 +162,10 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
impl<B, P, V> Handler for PoolPushHandler<B, P, V>
|
||||
impl<B, P> Handler for PoolPushHandler<B, P>
|
||||
where
|
||||
B: BlockChain + 'static,
|
||||
P: PoolAdapter + 'static,
|
||||
V: VerifierCache + 'static,
|
||||
{
|
||||
fn post(&self, req: Request<Body>) -> ResponseFuture {
|
||||
let pool = self.tx_pool.clone();
|
||||
|
||||
Reference in New Issue
Block a user