From cebd237be684da3ff344ef947b07e2860b8eb89d Mon Sep 17 00:00:00 2001 From: "iguerNL@Functori" Date: Tue, 6 Sep 2022 11:34:11 +0200 Subject: [PATCH] Proto: register errors with parameterized name in bounded_history functor --- .../lib_protocol/bounded_history_repr.ml | 19 ++++++++++++++----- .../lib_protocol/bounded_history_repr.mli | 6 +++++- .../lib_protocol/sc_rollup_inbox_repr.ml | 3 +++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/proto_alpha/lib_protocol/bounded_history_repr.ml b/src/proto_alpha/lib_protocol/bounded_history_repr.ml index 16933102e3b5..74fbd8fd344b 100644 --- a/src/proto_alpha/lib_protocol/bounded_history_repr.ml +++ b/src/proto_alpha/lib_protocol/bounded_history_repr.ml @@ -23,6 +23,10 @@ (* *) (*****************************************************************************) +module type NAME = sig + val name : string +end + module type KEY = sig type t @@ -74,7 +78,7 @@ module type S = sig end end -module Make (Key : KEY) (Value : VALUE) : +module Make (Name : NAME) (Key : KEY) (Value : VALUE) : S with type key = Key.t and type value = Value.t = struct type key = Key.t @@ -176,13 +180,18 @@ module Make (Key : KEY) (Value : VALUE) : } let () = + assert (not (String.equal Name.name "")) ; register_error_kind `Temporary - ~id:"Bounded_history_repr.key_bound_to_different_value" - ~title:"Key already bound to a different value." + ~id: + (Format.sprintf + "Bounded_history_repr.%s.key_bound_to_different_value" + Name.name) + ~title:(Name.name ^ ": Key already bound to a different value.") ~description: - "Remember called with a key that is already bound to a different\n\ - \ value." + (Name.name + ^ ": Remember called with a key that is already bound to a different\n\ + \ value.") Data_encoding.( obj3 (req "key" Key.encoding) diff --git a/src/proto_alpha/lib_protocol/bounded_history_repr.mli b/src/proto_alpha/lib_protocol/bounded_history_repr.mli index e8d7bddd287f..7195bb86169c 100644 --- a/src/proto_alpha/lib_protocol/bounded_history_repr.mli +++ b/src/proto_alpha/lib_protocol/bounded_history_repr.mli @@ -34,6 +34,10 @@ This data structure is basically a bounded association table that stores } *) +module type NAME = sig + val name : string +end + (** The required interface for keys stored in the table. *) module type KEY = sig type t @@ -110,5 +114,5 @@ module type S = sig end end -module Make (Key : KEY) (Value : VALUE) : +module Make (Name : NAME) (Key : KEY) (Value : VALUE) : S with type key = Key.t and type value = Value.t 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 036624056bb2..909cec573063 100644 --- a/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml +++ b/src/proto_alpha/lib_protocol/sc_rollup_inbox_repr.ml @@ -165,6 +165,9 @@ module V1 = struct remember any levels for which you may need to produce proofs. *) module History = Bounded_history_repr.Make + (struct + let name = "inbox_history" + end) (Hash) (struct type t = history_proof -- GitLab