From 6510869b738d367c2bb3a3b952d4b52fc5b07804 Mon Sep 17 00:00:00 2001 From: Benjamin Canou Date: Thu, 9 Aug 2018 14:56:03 +0200 Subject: [PATCH] Updater: registration or a protocol now returns the registered module --- .../jbuild_embedded_protocol_template | 4 --- .../main_embedded_packer.ml | 7 ++-- .../registered_protocol.ml | 35 ++++++++++--------- .../registered_protocol.mli | 6 +++- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/src/lib_protocol_compiler/jbuild_embedded_protocol_template b/src/lib_protocol_compiler/jbuild_embedded_protocol_template index 9398a0f2c..7d5eebb82 100644 --- a/src/lib_protocol_compiler/jbuild_embedded_protocol_template +++ b/src/lib_protocol_compiler/jbuild_embedded_protocol_template @@ -27,10 +27,6 @@ let () = Format.kasprintf Jbuild_plugin.V1.send {| module CamlinternalFormatBasics = struct include CamlinternalFormatBasics end "))) -(rule - (targets registerer.mli) - (action (write-file %%{targets} "(* empty *)"))) - (rule (targets registerer.ml) (deps tezos_embedded_protocol_environment_%s.cmxa diff --git a/src/lib_protocol_compiler/main_embedded_packer.ml b/src/lib_protocol_compiler/main_embedded_packer.ml index 7ba951f01..7cdc23082 100644 --- a/src/lib_protocol_compiler/main_embedded_packer.ml +++ b/src/lib_protocol_compiler/main_embedded_packer.ml @@ -55,11 +55,10 @@ end let () = Format.printf {| -let () = - let module Ignored = Tezos_protocol_updater.Registered_protocol.Register_embedded +module Registered = + Tezos_protocol_updater.Registered_protocol.Register_embedded (Tezos_embedded_protocol_environment_%s.Environment) (Tezos_embedded_raw_protocol_%s.Main) - (Source) in - () + (Source) @.|} version version diff --git a/src/lib_protocol_updater/registered_protocol.ml b/src/lib_protocol_updater/registered_protocol.ml index 5d18ea970..9e33edecd 100644 --- a/src/lib_protocol_updater/registered_protocol.ml +++ b/src/lib_protocol_updater/registered_protocol.ml @@ -97,26 +97,27 @@ module Register_embedded val sources: Protocol.t end) = struct + let hash = + match Source.hash with + | None -> Protocol.hash Source.sources + | Some hash -> hash + module Name = struct + let name = Protocol_hash.to_b58check hash + end + module Self = struct + module P = struct + let hash = hash + include Env.Lift(Proto) + end + include P + module Block_services = Block_services.Make(P)(P) + let complete_b58prefix = Env.Context.complete + end let () = - let hash = - match Source.hash with - | None -> Protocol.hash Source.sources - | Some hash -> hash in - let module Name = struct - let name = Protocol_hash.to_b58check hash - end in VersionTable.add sources hash Source.sources ; VersionTable.add - versions hash - (module struct - module P = struct - let hash = hash - include Env.Lift(Proto) - end - include P - module Block_services = Block_services.Make(P)(P) - let complete_b58prefix = Env.Context.complete - end : T) + versions hash (module Self : T) + include Self end diff --git a/src/lib_protocol_updater/registered_protocol.mli b/src/lib_protocol_updater/registered_protocol.mli index d2109c87b..040dd6aae 100644 --- a/src/lib_protocol_updater/registered_protocol.mli +++ b/src/lib_protocol_updater/registered_protocol.mli @@ -54,4 +54,8 @@ module Register_embedded (Source : sig val hash: Protocol_hash.t option val sources: Protocol.t - end) : sig end + end) : + T with type P.block_header_data = Proto.block_header_data + and type P.operation_data = Proto.operation_data + and type P.operation_receipt = Proto.operation_receipt + and type P.validation_state = Proto.validation_state