16
16
17
17
use std:: { marker:: PhantomData , sync:: Arc } ;
18
18
19
+ use sc_consensus:: {
20
+ import_queue:: { BasicQueue , Verifier as VerifierT } ,
21
+ BlockImport , BlockImportParams ,
22
+ } ;
19
23
use sp_api:: ProvideRuntimeApi ;
20
24
use sp_block_builder:: BlockBuilder as BlockBuilderApi ;
21
25
use sp_blockchain:: Result as ClientResult ;
22
- use sp_consensus:: {
23
- error:: Error as ConsensusError ,
24
- import_queue:: { BasicQueue , CacheKeyId , Verifier as VerifierT } ,
25
- BlockImport , BlockImportParams , BlockOrigin ,
26
- } ;
26
+ use sp_consensus:: { error:: Error as ConsensusError , CacheKeyId } ;
27
27
use sp_inherents:: { CreateInherentDataProviders , InherentDataProvider } ;
28
28
use sp_runtime:: {
29
29
generic:: BlockId ,
30
30
traits:: { Block as BlockT , Header as HeaderT } ,
31
- Justifications ,
32
31
} ;
33
32
34
33
/// A verifier that just checks the inherents.
@@ -59,35 +58,32 @@ where
59
58
{
60
59
async fn verify (
61
60
& mut self ,
62
- origin : BlockOrigin ,
63
- header : Block :: Header ,
64
- justifications : Option < Justifications > ,
65
- mut body : Option < Vec < Block :: Extrinsic > > ,
61
+ mut block_params : BlockImportParams < Block , ( ) > ,
66
62
) -> Result <
67
63
(
68
64
BlockImportParams < Block , ( ) > ,
69
65
Option < Vec < ( CacheKeyId , Vec < u8 > ) > > ,
70
66
) ,
71
67
String ,
72
68
> {
73
- if let Some ( inner_body) = body. take ( ) {
69
+ if let Some ( inner_body) = block_params . body . take ( ) {
74
70
let inherent_data_providers = self
75
71
. create_inherent_data_providers
76
- . create_inherent_data_providers ( * header. parent_hash ( ) , ( ) )
72
+ . create_inherent_data_providers ( * block_params . header . parent_hash ( ) , ( ) )
77
73
. await
78
74
. map_err ( |e| e. to_string ( ) ) ?;
79
75
80
76
let inherent_data = inherent_data_providers
81
77
. create_inherent_data ( )
82
78
. map_err ( |e| format ! ( "{:?}" , e) ) ?;
83
79
84
- let block = Block :: new ( header. clone ( ) , inner_body) ;
80
+ let block = Block :: new ( block_params . header . clone ( ) , inner_body) ;
85
81
86
82
let inherent_res = self
87
83
. client
88
84
. runtime_api ( )
89
85
. check_inherents (
90
- & BlockId :: Hash ( * header. parent_hash ( ) ) ,
86
+ & BlockId :: Hash ( * block . header ( ) . parent_hash ( ) ) ,
91
87
block. clone ( ) ,
92
88
inherent_data,
93
89
)
@@ -106,17 +102,12 @@ where
106
102
}
107
103
108
104
let ( _, inner_body) = block. deconstruct ( ) ;
109
- body = Some ( inner_body) ;
105
+ block_params . body = Some ( inner_body) ;
110
106
}
111
107
112
- let post_hash = Some ( header. hash ( ) ) ;
113
- let mut block_import_params = BlockImportParams :: new ( origin, header) ;
114
- block_import_params. body = body;
115
- block_import_params. justifications = justifications;
116
-
117
- block_import_params. post_hash = post_hash;
108
+ block_params. post_hash = Some ( block_params. header . hash ( ) ) ;
118
109
119
- Ok ( ( block_import_params , None ) )
110
+ Ok ( ( block_params , None ) )
120
111
}
121
112
}
122
113
0 commit comments