1616
1717use std:: sync:: Arc ;
1818
19- use ccore:: { BlockChainClient , SignedTransaction } ;
19+ use ccore:: { BlockChainClient , MiningBlockChainClient , SignedTransaction } ;
2020use cjson:: bytes:: Bytes ;
21+ use ckey:: { Address , PlatformAddress } ;
2122use primitives:: H256 ;
2223use rlp:: UntrustedRlp ;
2324
@@ -41,7 +42,7 @@ impl<C> MempoolClient<C> {
4142
4243impl < C > Mempool for MempoolClient < C >
4344where
44- C : BlockChainClient + ' static ,
45+ C : BlockChainClient + MiningBlockChainClient + ' static ,
4546{
4647 fn send_signed_transaction ( & self , raw : Bytes ) -> Result < H256 > {
4748 UntrustedRlp :: new ( & raw . into_vec ( ) )
7879 fn get_pending_transactions_count ( & self , from : Option < u64 > , to : Option < u64 > ) -> Result < usize > {
7980 Ok ( self . client . count_pending_transactions ( from. unwrap_or ( 0 ) ..to. unwrap_or ( :: std:: u64:: MAX ) ) )
8081 }
82+
83+ fn get_banned_accounts ( & self ) -> Result < Vec < PlatformAddress > > {
84+ let malicious_user_vec = self . client . get_malicious_users ( ) ;
85+ let network_id = self . client . get_network_id ( ) ;
86+ Ok ( malicious_user_vec. into_iter ( ) . map ( |address| PlatformAddress :: new_v1 ( network_id, address) ) . collect ( ) )
87+ }
88+
89+ fn unban_accounts ( & self , prisoner_list : Vec < PlatformAddress > ) -> Result < ( ) > {
90+ let prisoner_vec: Vec < Address > = prisoner_list. into_iter ( ) . map ( PlatformAddress :: into_address) . collect ( ) ;
91+
92+ self . client . release_malicious_users ( prisoner_vec) ;
93+ Ok ( ( ) )
94+ }
95+
96+ fn ban_accounts ( & self , prisoner_list : Vec < PlatformAddress > ) -> Result < ( ) > {
97+ let prisoner_vec: Vec < Address > = prisoner_list. into_iter ( ) . map ( PlatformAddress :: into_address) . collect ( ) ;
98+
99+ self . client . imprison_malicious_users ( prisoner_vec) ;
100+ Ok ( ( ) )
101+ }
102+
103+ fn get_immune_accounts ( & self ) -> Result < Vec < PlatformAddress > > {
104+ let immune_user_vec = self . client . get_immune_users ( ) ;
105+ let network_id = self . client . get_network_id ( ) ;
106+ Ok ( immune_user_vec. into_iter ( ) . map ( |address| PlatformAddress :: new_v1 ( network_id, address) ) . collect ( ) )
107+ }
108+
109+ fn register_immune_accounts ( & self , immune_user_list : Vec < PlatformAddress > ) -> Result < ( ) > {
110+ let immune_user_vec: Vec < Address > = immune_user_list. into_iter ( ) . map ( PlatformAddress :: into_address) . collect ( ) ;
111+
112+ self . client . register_immune_users ( immune_user_vec) ;
113+ Ok ( ( ) )
114+ }
81115}
0 commit comments