diff --git a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml index b34df886f28708d56ef311183546b378c777ed30..84f1461cd79b93b2afe272da162551eb42c96af0 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml @@ -135,19 +135,7 @@ let equal_history_proof = Skip_list.equal Hash.equal Hash.equal let history_proof_encoding : history_proof Data_encoding.t = Skip_list.encoding Hash.encoding Hash.encoding -let pp_history_proof fmt cell = - Format.fprintf - fmt - {| - content = %a - index = %d - back_pointers = %a - |} - Hash.pp - (Skip_list.content cell) - (Skip_list.index cell) - (Format.pp_print_list Hash.pp) - (Skip_list.back_pointers cell) +let pp_history_proof = Skip_list.pp ~pp_content:Hash.pp ~pp_ptr:Hash.pp module V1 = struct (* diff --git a/src/proto_alpha/lib_protocol/skip_list_repr.ml b/src/proto_alpha/lib_protocol/skip_list_repr.ml index cc65a1d5e6e674a7475343a5238d8f779e4ab340..fc7c0077bd9cf96102e509dc5394061ed55ba9c4 100644 --- a/src/proto_alpha/lib_protocol/skip_list_repr.ml +++ b/src/proto_alpha/lib_protocol/skip_list_repr.ml @@ -26,6 +26,13 @@ module type S = sig type ('content, 'ptr) cell + val pp : + pp_content:(Format.formatter -> 'content -> unit) -> + pp_ptr:(Format.formatter -> 'ptr -> unit) -> + Format.formatter -> + ('content, 'ptr) cell -> + unit + val equal : ('content -> 'content -> bool) -> ('ptr -> 'ptr -> bool) -> @@ -136,6 +143,20 @@ end) : S = struct [] |> List.rev + let pp ~pp_content ~pp_ptr fmt {content; back_pointers; index} = + Format.fprintf + fmt + {| + content = %a + index = %d + back_pointers = %a + |} + pp_content + content + index + (Format.pp_print_list pp_ptr) + (back_pointers_to_list back_pointers) + let encoding ptr_encoding content_encoding = let of_list = FallbackArray.of_list ~fallback:None ~proj:(fun c -> Some c) diff --git a/src/proto_alpha/lib_protocol/skip_list_repr.mli b/src/proto_alpha/lib_protocol/skip_list_repr.mli index 843003e18a151fd318ad5b23e4ad2bfcbe10ac07..74d18e7dff3ab467b421bf26ba01309376446708 100644 --- a/src/proto_alpha/lib_protocol/skip_list_repr.mli +++ b/src/proto_alpha/lib_protocol/skip_list_repr.mli @@ -51,6 +51,13 @@ module type S = sig pointers of type ['ptr]. *) type ('content, 'ptr) cell + val pp : + pp_content:(Format.formatter -> 'content -> unit) -> + pp_ptr:(Format.formatter -> 'ptr -> unit) -> + Format.formatter -> + ('content, 'ptr) cell -> + unit + val equal : ('content -> 'content -> bool) -> ('ptr -> 'ptr -> bool) -> @@ -82,7 +89,7 @@ module type S = sig val genesis : 'content -> ('content, 'ptr) cell (** [next ~prev_cell ~prev_cell_ptr content] creates a new cell - that carries some [content], that follows [prev_cell]. *) + that carries some [content], that follows [prev_cell]. *) val next : prev_cell:('content, 'ptr) cell -> prev_cell_ptr:'ptr ->