Skip to content

Commit 23e121f

Browse files
glyhgeorgeee
authored andcommitted
fix_persistent_frontier: report final state hash after all pending transitions are applied
1 parent c1dcb88 commit 23e121f

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

src/app/cli/src/init/fix_persistent_frontier.ml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,10 @@ let apply_root_transitions ~logger ~db diffs =
5252
.message err ) ) )
5353
|> Result.ok_exn
5454
in
55-
Transition_frontier.Persistent_frontier.Database.with_batch db
56-
~f:(fun batch ->
57-
( List.fold diffs ~init:initial_root_hash ~f:(fun old_root_hash diff ->
55+
let final_state_hash =
56+
Transition_frontier.Persistent_frontier.Database.with_batch db
57+
~f:(fun batch ->
58+
List.fold diffs ~init:initial_root_hash ~f:(fun old_root_hash diff ->
5859
match diff with
5960
| Diff.Lite.E.E
6061
(Diff.Root_transitioned
@@ -71,11 +72,13 @@ let apply_root_transitions ~logger ~db diffs =
7172
(* Return new root hash for next iteration *)
7273
(Root_data.Limited.Stable.Latest.hashes new_root).state_hash
7374
| _ ->
74-
failwith "Expected Root_transitioned diff" )
75-
: State_hash.t )
76-
|> ignore ) ;
75+
failwith "Expected Root_transitioned diff" ) )
76+
in
7777
[%log' info logger] "Successfully applied $count diffs"
78-
~metadata:[ ("count", `Int (List.length diffs)) ] ;
78+
~metadata:
79+
[ ("count", `Int (List.length diffs))
80+
; ("final_state_hash", Frozen_ledger_hash.to_yojson final_state_hash)
81+
] ;
7982
Ok ()
8083
with exn ->
8184
[%log' error logger] "Failed to apply root transitions: $error"

0 commit comments

Comments
 (0)