1717use std:: sync:: Arc ;
1818
1919use ccore:: {
20- AssetClient , BlockId , EngineInfo , ExecuteClient , MinerService , MiningBlockChainClient , RegularKey , RegularKeyOwner ,
21- Shard , SignedTransaction , TextClient ,
20+ AssetClient , BlockId , EngineInfo , ExecuteClient , MiningBlockChainClient , RegularKey , RegularKeyOwner , Shard ,
21+ TextClient ,
2222} ;
2323use ccrypto:: Blake ;
24- use cjson:: bytes:: Bytes ;
2524use cjson:: uint:: Uint ;
2625use ckey:: { public_to_address, NetworkId , PlatformAddress , Public } ;
2726use cstate:: FindActionHandler ;
2827use ctypes:: transaction:: { Action , ShardTransaction as ShardTransactionType } ;
2928use ctypes:: { BlockNumber , ShardId } ;
3029use primitives:: { Bytes as BytesArray , H160 , H256 } ;
31- use rlp:: UntrustedRlp ;
3230
3331use jsonrpc_core:: Result ;
3432
3533use super :: super :: errors;
3634use super :: super :: traits:: Chain ;
37- use super :: super :: types:: {
38- AssetScheme , Block , BlockNumberAndHash , OwnedAsset , PendingTransactions , Text , Transaction , UnsignedTransaction ,
39- } ;
35+ use super :: super :: types:: { AssetScheme , Block , BlockNumberAndHash , OwnedAsset , Text , Transaction , UnsignedTransaction } ;
4036
41- pub struct ChainClient < C , M >
37+ pub struct ChainClient < C >
4238where
43- C : AssetClient + MiningBlockChainClient + Shard + RegularKey + RegularKeyOwner + ExecuteClient + EngineInfo ,
44- M : MinerService , {
39+ C : AssetClient + MiningBlockChainClient + Shard + RegularKey + RegularKeyOwner + ExecuteClient + EngineInfo , {
4540 client : Arc < C > ,
46- miner : Arc < M > ,
4741}
4842
49- impl < C , M > ChainClient < C , M >
43+ impl < C > ChainClient < C >
5044where
5145 C : AssetClient
5246 + MiningBlockChainClient
@@ -56,17 +50,15 @@ where
5650 + ExecuteClient
5751 + EngineInfo
5852 + TextClient ,
59- M : MinerService ,
6053{
61- pub fn new ( client : Arc < C > , miner : Arc < M > ) -> Self {
54+ pub fn new ( client : Arc < C > ) -> Self {
6255 ChainClient {
6356 client,
64- miner,
6557 }
6658 }
6759}
6860
69- impl < C , M > Chain for ChainClient < C , M >
61+ impl < C > Chain for ChainClient < C >
7062where
7163 C : AssetClient
7264 + MiningBlockChainClient
7870 + FindActionHandler
7971 + TextClient
8072 + ' static ,
81- M : MinerService + ' static ,
8273{
83- fn send_signed_transaction ( & self , raw : Bytes ) -> Result < H256 > {
84- UntrustedRlp :: new ( & raw . into_vec ( ) )
85- . as_val ( )
86- . map_err ( |e| errors:: rlp ( & e) )
87- . and_then ( |tx| SignedTransaction :: try_new ( tx) . map_err ( errors:: transaction_core) )
88- . and_then ( |signed| {
89- let hash = signed. hash ( ) ;
90- self . miner . import_own_transaction ( & * self . client , signed) . map_err ( errors:: transaction_core) . map ( |_| hash)
91- } )
92- . map ( Into :: into)
93- }
94-
9574 fn get_transaction ( & self , transaction_hash : H256 ) -> Result < Option < Transaction > > {
9675 let id = transaction_hash. into ( ) ;
9776 Ok ( self . client . transaction ( & id) . map ( From :: from) )
@@ -105,15 +84,6 @@ where
10584 Ok ( self . client . transaction_by_tracker ( & tracker) . map ( From :: from) )
10685 }
10786
108- fn get_transaction_results_by_tracker ( & self , tracker : H256 ) -> Result < Vec < bool > > {
109- Ok ( self
110- . client
111- . error_hints_by_tracker ( & tracker)
112- . into_iter ( )
113- . map ( |( _hash, error_hint) | error_hint. is_none ( ) )
114- . collect ( ) )
115- }
116-
11787 fn get_asset_scheme_by_tracker (
11888 & self ,
11989 tracker : H256 ,
@@ -183,10 +153,6 @@ where
183153 Ok ( self . client . balance ( address, block_id. into ( ) ) . map ( Into :: into) )
184154 }
185155
186- fn get_error_hint ( & self , transaction_hash : H256 ) -> Result < Option < String > > {
187- Ok ( self . client . error_hint ( & transaction_hash) )
188- }
189-
190156 fn get_regular_key ( & self , address : PlatformAddress , block_number : Option < u64 > ) -> Result < Option < Public > > {
191157 let block_id = block_number. map ( BlockId :: Number ) . unwrap_or ( BlockId :: Latest ) ;
192158 let address = address. try_address ( ) . map_err ( errors:: core) ?;
@@ -269,14 +235,6 @@ where
269235 Ok ( self . client . block ( & BlockId :: Hash ( block_hash) ) . map ( |block| block. transactions_count ( ) ) )
270236 }
271237
272- fn get_pending_transactions ( & self , from : Option < u64 > , to : Option < u64 > ) -> Result < PendingTransactions > {
273- Ok ( self . client . ready_transactions ( from. unwrap_or ( 0 ) ..to. unwrap_or ( :: std:: u64:: MAX ) ) . into ( ) )
274- }
275-
276- fn get_pending_transactions_count ( & self , from : Option < u64 > , to : Option < u64 > ) -> Result < usize > {
277- Ok ( self . client . count_pending_transactions ( from. unwrap_or ( 0 ) ..to. unwrap_or ( :: std:: u64:: MAX ) ) )
278- }
279-
280238 fn get_mining_reward ( & self , block_number : u64 ) -> Result < Option < u64 > > {
281239 Ok ( self . client . mining_reward ( block_number) )
282240 }
0 commit comments