@@ -495,7 +495,7 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {
495
495
let post_ratifications = reward_ratifications. iter( ) . chain( post_ratifications) ;
496
496
497
497
// Process the post-ratifications.
498
- match Self :: atomic_post_ratify( & self . puzzle, store, state, post_ratifications, solutions) {
498
+ match Self :: atomic_post_ratify:: < false > ( & self . puzzle, store, state, post_ratifications, solutions) {
499
499
// Store the finalize operations from the post-ratify.
500
500
Ok ( operations) => ratified_finalize_operations. extend( operations) ,
501
501
// Note: This will abort the entire atomic batch.
@@ -739,7 +739,7 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {
739
739
740
740
/* Perform the ratifications after finalize. */
741
741
742
- match Self :: atomic_post_ratify( & self . puzzle, store, state, post_ratifications, solutions) {
742
+ match Self :: atomic_post_ratify:: < true > ( & self . puzzle, store, state, post_ratifications, solutions) {
743
743
// Store the finalize operations from the post-ratify.
744
744
Ok ( operations) => ratified_finalize_operations. extend( operations) ,
745
745
// Note: This will abort the entire atomic batch.
@@ -1191,7 +1191,7 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {
1191
1191
1192
1192
/// Performs the post-ratifications after finalizing transactions.
1193
1193
#[ inline]
1194
- fn atomic_post_ratify < ' a > (
1194
+ fn atomic_post_ratify < ' a , const IS_FINALIZE : bool > (
1195
1195
puzzle : & Puzzle < N > ,
1196
1196
store : & FinalizeStore < N , C :: FinalizeStorage > ,
1197
1197
state : FinalizeGlobalState ,
@@ -1258,6 +1258,37 @@ impl<N: Network, C: ConsensusStorage<N>> VM<N, C> {
1258
1258
1259
1259
// Insert the next committee into storage.
1260
1260
store. committee_store ( ) . insert ( state. block_height ( ) , next_committee) ?;
1261
+
1262
+ #[ cfg( all( feature = "history" , feature = "rocks" ) ) ]
1263
+ {
1264
+ // When finalizing in `FinalizeMode::RealRun`, store the delegated and bonded mappings in history.
1265
+ if IS_FINALIZE {
1266
+ // Load a `History` object.
1267
+ let history = History :: new ( N :: ID , store. storage_mode ( ) ) ;
1268
+
1269
+ // Write the delegated mapping as JSON.
1270
+ history. store_mapping ( state. block_height ( ) , MappingName :: Delegated , & next_delegated_map) ?;
1271
+
1272
+ // Write the bonded mapping as JSON.
1273
+ history. store_mapping ( state. block_height ( ) , MappingName :: Bonded , & next_bonded_map) ?;
1274
+
1275
+ // Write the metadata mapping as JSON.
1276
+ let metadata_mapping = Identifier :: from_str ( "metadata" ) ?;
1277
+ let metadata_map = store. get_mapping_speculative ( program_id, metadata_mapping) ?;
1278
+ history. store_mapping ( state. block_height ( ) , MappingName :: Metadata , & metadata_map) ?;
1279
+
1280
+ // Write the unbonding mapping as JSON.
1281
+ let unbonding_mapping = Identifier :: from_str ( "unbonding" ) ?;
1282
+ let unbonding_map = store. get_mapping_speculative ( program_id, unbonding_mapping) ?;
1283
+ history. store_mapping ( state. block_height ( ) , MappingName :: Unbonding , & unbonding_map) ?;
1284
+
1285
+ // Write the withdraw mapping as JSON.
1286
+ let withdraw_mapping = Identifier :: from_str ( "withdraw" ) ?;
1287
+ let withdraw_map = store. get_mapping_speculative ( program_id, withdraw_mapping) ?;
1288
+ history. store_mapping ( state. block_height ( ) , MappingName :: Withdraw , & withdraw_map) ?;
1289
+ }
1290
+ }
1291
+
1261
1292
// Store the finalize operations for updating the committee and bonded mapping.
1262
1293
finalize_operations. extend ( & [
1263
1294
// Replace the committee mapping in storage.
0 commit comments