@@ -19,8 +19,8 @@ use ethereum_types::{H160, H256, U256};
1919use fc_rpc:: { internal_err, public_key} ;
2020use jsonrpsee:: core:: RpcResult ;
2121pub use rpc_core_txpool:: { GetT , Summary , Transaction , TransactionMap , TxPoolResult , TxPoolServer } ;
22- use sc_transaction_pool:: { ChainApi , Pool } ;
23- use sc_transaction_pool_api:: InPoolTransaction ;
22+ use sc_transaction_pool:: ChainApi ;
23+ use sc_transaction_pool_api:: TransactionPool as _ ;
2424use serde:: Serialize ;
2525use sha3:: { Digest , Keccak256 } ;
2626use sp_api:: { ApiExt , ProvideRuntimeApi } ;
@@ -30,19 +30,19 @@ use std::{marker::PhantomData, sync::Arc};
3030
3131use rpc_primitives_txpool:: { Transaction as TransactionV2 , TxPoolResponse , TxPoolRuntimeApi } ;
3232
33- pub struct TxPool < B : BlockT , C , A : ChainApi > {
33+ pub struct TxPool < B : BlockT , C , P > {
3434 client : Arc < C > ,
35- graph : Arc < Pool < A > > ,
35+ pool : Arc < P > ,
3636 _marker : PhantomData < B > ,
3737}
3838
39- impl < B , C , A > TxPool < B , C , A >
39+ impl < B , C , P > TxPool < B , C , P >
4040where
4141 C : ProvideRuntimeApi < B > ,
4242 C : HeaderMetadata < B , Error = BlockChainError > + HeaderBackend < B > + ' static ,
4343 C : Send + Sync + ' static ,
4444 B : BlockT < Hash = H256 > + Send + Sync + ' static ,
45- A : ChainApi < Block = B > + ' static ,
45+ P : sc_transaction_pool_api :: TransactionPool < Block = B > + ' static ,
4646 C :: Api : TxPoolRuntimeApi < B > ,
4747{
4848 /// Use the transaction graph interface to get the extrinsics currently in the ready and future
@@ -53,19 +53,17 @@ where
5353 {
5454 // Collect transactions in the ready validated pool.
5555 let txs_ready = self
56- . graph
57- . validated_pool ( )
56+ . pool
5857 . ready ( )
59- . map ( |in_pool_tx| in_pool_tx. data ( ) . clone ( ) )
58+ . map ( |in_pool_tx| ( * * in_pool_tx. data ( ) ) . clone ( ) )
6059 . collect ( ) ;
6160
6261 // Collect transactions in the future validated pool.
6362 let txs_future = self
64- . graph
65- . validated_pool ( )
63+ . pool
6664 . futures ( )
67- . iter ( )
68- . map ( |( _hash , extrinsic ) | extrinsic . clone ( ) )
65+ . into_iter ( )
66+ . map ( |in_pool_tx| ( * * in_pool_tx . data ( ) ) . clone ( ) )
6967 . collect ( ) ;
7068
7169 // Use the runtime to match the (here) opaque extrinsics against ethereum transactions.
@@ -131,19 +129,19 @@ where
131129 }
132130}
133131
134- impl < B : BlockT , C , A : ChainApi > TxPool < B , C , A > {
135- pub fn new ( client : Arc < C > , graph : Arc < Pool < A > > ) -> Self {
136- Self { client, graph , _marker : PhantomData }
132+ impl < B : BlockT , C , P > TxPool < B , C , P > {
133+ pub fn new ( client : Arc < C > , pool : Arc < P > ) -> Self {
134+ Self { client, pool , _marker : PhantomData }
137135 }
138136}
139137
140- impl < B , C , A > TxPoolServer for TxPool < B , C , A >
138+ impl < B , C , P > TxPoolServer for TxPool < B , C , P >
141139where
142140 C : ProvideRuntimeApi < B > ,
143141 C : HeaderMetadata < B , Error = BlockChainError > + HeaderBackend < B > ,
144142 C : Send + Sync + ' static ,
145143 B : BlockT < Hash = H256 > + Send + Sync + ' static ,
146- A : ChainApi < Block = B > + ' static ,
144+ P : sc_transaction_pool_api :: TransactionPool < Block = B > + ' static ,
147145 C :: Api : TxPoolRuntimeApi < B > ,
148146{
149147 fn content ( & self ) -> RpcResult < TxPoolResult < TransactionMap < Transaction > > > {
@@ -155,13 +153,13 @@ where
155153 }
156154
157155 fn status ( & self ) -> RpcResult < TxPoolResult < U256 > > {
158- let status = self . graph . validated_pool ( ) . status ( ) ;
156+ let status = self . pool . status ( ) ;
159157 Ok ( TxPoolResult { pending : U256 :: from ( status. ready ) , queued : U256 :: from ( status. future ) } )
160158 }
161159}
162160
163- impl < B : BlockT , C , A : ChainApi > Clone for TxPool < B , C , A > {
161+ impl < B : BlockT , C , P > Clone for TxPool < B , C , P > {
164162 fn clone ( & self ) -> Self {
165- Self :: new ( self . client . clone ( ) , self . graph . clone ( ) )
163+ Self :: new ( self . client . clone ( ) , self . pool . clone ( ) )
166164 }
167165}
0 commit comments