@@ -19,13 +19,12 @@ use std::pin::Pin;
19
19
use cumulus_relay_chain_interface:: { RelayChainError , RelayChainResult } ;
20
20
use cumulus_relay_chain_rpc_interface:: RelayChainRpcClient ;
21
21
use futures:: { Future , Stream , StreamExt } ;
22
- use polkadot_core_primitives:: { Block , Hash , Header } ;
22
+ use polkadot_core_primitives:: { Block , BlockNumber , Hash , Header } ;
23
23
use polkadot_overseer:: RuntimeApiSubsystemClient ;
24
- use polkadot_service:: { AuxStore , HeaderBackend } ;
25
24
use sc_authority_discovery:: AuthorityDiscovery ;
26
-
27
25
use sp_api:: { ApiError , RuntimeApiInfo } ;
28
- use sp_blockchain:: Info ;
26
+ use sp_blockchain:: { HeaderBackend , Info } ;
27
+ use sp_runtime:: traits:: { Block as BlockT , Header as HeaderT , NumberFor } ;
29
28
30
29
#[ derive( Clone ) ]
31
30
pub struct BlockChainRpcClient {
@@ -46,34 +45,12 @@ impl BlockChainRpcClient {
46
45
47
46
pub async fn block_get_hash (
48
47
& self ,
49
- number : Option < polkadot_service :: BlockNumber > ,
48
+ number : Option < BlockNumber > ,
50
49
) -> Result < Option < Hash > , RelayChainError > {
51
50
self . rpc_client . chain_get_block_hash ( number) . await
52
51
}
53
52
}
54
53
55
- // Implementation required by Availability-Distribution subsystem
56
- // but never called in our case.
57
- impl AuxStore for BlockChainRpcClient {
58
- fn insert_aux <
59
- ' a ,
60
- ' b : ' a ,
61
- ' c : ' a ,
62
- I : IntoIterator < Item = & ' a ( & ' c [ u8 ] , & ' c [ u8 ] ) > ,
63
- D : IntoIterator < Item = & ' a & ' b [ u8 ] > ,
64
- > (
65
- & self ,
66
- _insert : I ,
67
- _delete : D ,
68
- ) -> sp_blockchain:: Result < ( ) > {
69
- unimplemented ! ( "Not supported on the RPC collator" )
70
- }
71
-
72
- fn get_aux ( & self , _key : & [ u8 ] ) -> sp_blockchain:: Result < Option < Vec < u8 > > > {
73
- unimplemented ! ( "Not supported on the RPC collator" )
74
- }
75
- }
76
-
77
54
#[ async_trait:: async_trait]
78
55
impl RuntimeApiSubsystemClient for BlockChainRpcClient {
79
56
async fn validators (
@@ -359,8 +336,8 @@ fn block_local<T>(fut: impl Future<Output = T>) -> T {
359
336
impl HeaderBackend < Block > for BlockChainRpcClient {
360
337
fn header (
361
338
& self ,
362
- hash : <Block as polkadot_service :: BlockT >:: Hash ,
363
- ) -> sp_blockchain:: Result < Option < <Block as polkadot_service :: BlockT >:: Header > > {
339
+ hash : <Block as BlockT >:: Hash ,
340
+ ) -> sp_blockchain:: Result < Option < <Block as BlockT >:: Header > > {
364
341
Ok ( block_local ( self . rpc_client . chain_get_header ( Some ( hash) ) ) ?)
365
342
}
366
343
@@ -389,7 +366,7 @@ impl HeaderBackend<Block> for BlockChainRpcClient {
389
366
390
367
fn status (
391
368
& self ,
392
- hash : <Block as polkadot_service :: BlockT >:: Hash ,
369
+ hash : <Block as BlockT >:: Hash ,
393
370
) -> sp_blockchain:: Result < sp_blockchain:: BlockStatus > {
394
371
if self . header ( hash) ?. is_some ( ) {
395
372
Ok ( sc_client_api:: blockchain:: BlockStatus :: InChain )
@@ -400,19 +377,17 @@ impl HeaderBackend<Block> for BlockChainRpcClient {
400
377
401
378
fn number (
402
379
& self ,
403
- hash : <Block as polkadot_service:: BlockT >:: Hash ,
404
- ) -> sp_blockchain:: Result <
405
- Option < <<Block as polkadot_service:: BlockT >:: Header as polkadot_service:: HeaderT >:: Number > ,
406
- > {
380
+ hash : <Block as BlockT >:: Hash ,
381
+ ) -> sp_blockchain:: Result < Option < <<Block as BlockT >:: Header as HeaderT >:: Number > > {
407
382
let result = block_local ( self . rpc_client . chain_get_header ( Some ( hash) ) ) ?
408
383
. map ( |maybe_header| maybe_header. number ) ;
409
384
Ok ( result)
410
385
}
411
386
412
387
fn hash (
413
388
& self ,
414
- number : polkadot_service :: NumberFor < Block > ,
415
- ) -> sp_blockchain:: Result < Option < <Block as polkadot_service :: BlockT >:: Hash > > {
389
+ number : NumberFor < Block > ,
390
+ ) -> sp_blockchain:: Result < Option < <Block as BlockT >:: Hash > > {
416
391
Ok ( block_local ( self . rpc_client . chain_get_block_hash ( number. into ( ) ) ) ?)
417
392
}
418
393
}
0 commit comments