Commit 8dc3754 2 people authored and committed
1 parent dbd25db commit 8dc3754 Copy full SHA for 8dc3754
File tree 3 files changed +6
-8
lines changed
client/service/src/client
3 files changed +6
-8
lines changed Original file line number Diff line number Diff line change @@ -481,8 +481,7 @@ where
481
481
}
482
482
483
483
/// Get the code at a given block.
484
- pub fn code_at ( & self , id : & BlockId < Block > ) -> sp_blockchain:: Result < Vec < u8 > > {
485
- let hash = self . backend . blockchain ( ) . expect_block_hash_from_id ( id) ?;
484
+ pub fn code_at ( & self , hash : Block :: Hash ) -> sp_blockchain:: Result < Vec < u8 > > {
486
485
Ok ( StorageProvider :: storage ( self , hash, & StorageKey ( well_known_keys:: CODE . to_vec ( ) ) ) ?
487
486
. expect (
488
487
"None is returned if there's no value stored for the given key;\
@@ -1746,9 +1745,8 @@ where
1746
1745
CallExecutor :: runtime_version ( & self . executor , hash) . map_err ( Into :: into)
1747
1746
}
1748
1747
1749
- fn state_at ( & self , at : & BlockId < Block > ) -> Result < Self :: StateBackend , sp_api:: ApiError > {
1750
- let hash = self . backend . blockchain ( ) . expect_block_hash_from_id ( at) ?;
1751
- self . state_at ( hash) . map_err ( Into :: into)
1748
+ fn state_at ( & self , at : Block :: Hash ) -> Result < Self :: StateBackend , sp_api:: ApiError > {
1749
+ self . state_at ( at) . map_err ( Into :: into)
1752
1750
}
1753
1751
}
1754
1752
Original file line number Diff line number Diff line change @@ -622,7 +622,7 @@ pub trait CallApiAt<Block: BlockT> {
622
622
fn runtime_version_at ( & self , at : & BlockId < Block > ) -> Result < RuntimeVersion , ApiError > ;
623
623
624
624
/// Get the state `at` the given block.
625
- fn state_at ( & self , at : & BlockId < Block > ) -> Result < Self :: StateBackend , ApiError > ;
625
+ fn state_at ( & self , at : Block :: Hash ) -> Result < Self :: StateBackend , ApiError > ;
626
626
}
627
627
628
628
/// Auxiliary wrapper that holds an api instance and binds it to the given lifetime.
Original file line number Diff line number Diff line change @@ -147,13 +147,12 @@ fn record_proof_works() {
147
147
. set_execution_strategy ( ExecutionStrategy :: Both )
148
148
. build_with_longest_chain ( ) ;
149
149
150
- let block_id = BlockId :: Number ( client. chain_info ( ) . best_number ) ;
151
150
let storage_root =
152
151
* futures:: executor:: block_on ( longest_chain. best_chain ( ) ) . unwrap ( ) . state_root ( ) ;
153
152
154
153
let runtime_code = sp_core:: traits:: RuntimeCode {
155
154
code_fetcher : & sp_core:: traits:: WrappedRuntimeCode (
156
- client. code_at ( & block_id ) . unwrap ( ) . into ( ) ,
155
+ client. code_at ( client . chain_info ( ) . best_hash ) . unwrap ( ) . into ( ) ,
157
156
) ,
158
157
hash : vec ! [ 1 ] ,
159
158
heap_pages : None ,
@@ -167,6 +166,7 @@ fn record_proof_works() {
167
166
}
168
167
. into_signed_tx ( ) ;
169
168
169
+ let block_id = BlockId :: Hash ( client. chain_info ( ) . best_hash ) ;
170
170
// Build the block and record proof
171
171
let mut builder = client
172
172
. new_block_at ( & block_id, Default :: default ( ) , true )
You can’t perform that action at this time.
0 commit comments