Skip to content

Commit 73957e6

Browse files
committed
Implement ledger iteri with iteri_untrusted
1 parent d48e21a commit 73957e6

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/lib/merkle_ledger/database.ml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -583,12 +583,8 @@ module Make (Inputs : Intf.Inputs.DATABASE) = struct
583583
|> Sequence.iter ~f:(fun i -> f i (get_at_index t i))
584584

585585
let iteri t ~f =
586-
match Account_location.last_location_address t with
587-
| None ->
588-
()
589-
| Some last_addr ->
590-
Sequence.range ~stop:`inclusive 0 (Addr.to_int last_addr)
591-
|> Sequence.iter ~f:(fun i -> f i (get_at_index_exn t i))
586+
iteri_untrusted t ~f:(fun index account_opt ->
587+
f index (Option.value_exn account_opt) )
592588

593589
(* TODO : if key-value store supports iteration mechanism, like RocksDB,
594590
maybe use that here, instead of loading all accounts into memory See Issue

src/lib/merkle_mask/masking_merkle_tree.ml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -917,10 +917,8 @@ module Make (Inputs : Inputs_intf.S) = struct
917917
|> Sequence.iter ~f:(fun i -> f i (get_at_index t i))
918918

919919
let iteri t ~f =
920-
assert_is_attached t ;
921-
let num_accounts = num_accounts t in
922-
Sequence.range ~stop:`exclusive 0 num_accounts
923-
|> Sequence.iter ~f:(fun i -> f i (get_at_index_exn t i))
920+
iteri_untrusted t ~f:(fun index account_opt ->
921+
f index (Option.value_exn account_opt) )
924922

925923
let foldi_with_ignored_accounts t ignored_accounts ~init ~f =
926924
assert_is_attached t ;

0 commit comments

Comments
 (0)