@@ -631,28 +631,38 @@ where
631631 }
632632
633633 // If the user chooses an object mapping start block we don't have data or state for, we can't
634- // create mappings for it, so the node must exit with an error.
635- let best_block_to_archive_hash = client
636- . hash ( best_block_to_archive. into ( ) ) ?
637- . expect ( "just checked above; qed" ) ;
638- let Some ( best_block_data) = client. block ( best_block_to_archive_hash) ? else {
639- let error = format ! (
640- "Missing data for mapping block {best_block_to_archive} hash {best_block_to_archive_hash}, \
641- try a higher block number, or wipe your node and restart with `--sync full`"
634+ // create mappings for it, so the node must exit with an error
635+ if create_object_mappings. is_enabled ( ) {
636+ let best_block_to_archive_hash = client
637+ . hash ( best_block_to_archive. into ( ) ) ?
638+ . expect ( "just checked above; qed" ) ;
639+ let Some ( best_block_data) = client. block ( best_block_to_archive_hash) ? else {
640+ let error = format ! (
641+ "Missing data for mapping block {best_block_to_archive} hash \
642+ {best_block_to_archive_hash}, try a higher block number, or wipe your node and \
643+ restart with `--sync full`"
642644 ) ;
643- return Err ( sp_blockchain:: Error :: Application ( error. into ( ) ) ) ;
644- } ;
645+ return Err ( sp_blockchain:: Error :: Application ( error. into ( ) ) ) ;
646+ } ;
645647
646- // Similarly, state can be pruned, even if the data is present.
647- client
648- . runtime_api ( )
649- . extract_block_object_mapping ( * best_block_data. block . header ( ) . parent_hash ( ) , best_block_data. block . clone ( ) )
648+ // Similarly, state can be pruned, even if the data is present
649+ client
650+ . runtime_api ( )
651+ . extract_block_object_mapping (
652+ * best_block_data. block . header ( ) . parent_hash ( ) ,
653+ best_block_data. block . clone ( ) ,
654+ )
650655 . map_err ( |error| {
651656 sp_blockchain:: Error :: Application (
652- format ! ( "Missing state for mapping block {best_block_to_archive} hash {best_block_to_archive_hash}: {error}, \
653- try a higher block number, or wipe your node and restart with `--sync full`") . into ( ) ,
657+ format ! (
658+ "Missing state for mapping block {best_block_to_archive} hash \
659+ {best_block_to_archive_hash}: {error}, try a higher block number, or wipe \
660+ your node and restart with `--sync full`"
661+ )
662+ . into ( ) ,
654663 )
655664 } ) ?;
665+ }
656666
657667 let maybe_last_archived_block = find_last_archived_block (
658668 client,
0 commit comments