From 91d497fd4a2ade9cb886b2b4cea64621a78fd84b Mon Sep 17 00:00:00 2001 From: Marco Stronati Date: Tue, 26 Jun 2018 11:24:14 +0200 Subject: [PATCH] Alpha: rename apply_operation_result to apply_results --- src/proto_alpha/lib_client/client_proto_context.ml | 8 ++++---- src/proto_alpha/lib_client/injection.ml | 14 +++++++------- src/proto_alpha/lib_client/injection.mli | 2 +- src/proto_alpha/lib_client/operation_result.ml | 4 ++-- src/proto_alpha/lib_client/operation_result.mli | 2 +- .../lib_delegate/client_baking_denunciation.ml | 6 +++--- src/proto_alpha/lib_protocol/src/TEZOS_PROTOCOL | 2 +- src/proto_alpha/lib_protocol/src/apply.ml | 2 +- ...{apply_operation_result.ml => apply_results.ml} | 0 ...pply_operation_result.mli => apply_results.mli} | 0 .../lib_protocol/src/helpers_services.ml | 4 ++-- .../lib_protocol/src/helpers_services.mli | 2 +- src/proto_alpha/lib_protocol/src/main.ml | 8 ++++---- src/proto_alpha/lib_protocol/src/main.mli | 2 +- .../lib_protocol/test/helpers/incremental.ml | 10 +++++----- 15 files changed, 33 insertions(+), 33 deletions(-) rename src/proto_alpha/lib_protocol/src/{apply_operation_result.ml => apply_results.ml} (100%) rename src/proto_alpha/lib_protocol/src/{apply_operation_result.mli => apply_results.mli} (100%) diff --git a/src/proto_alpha/lib_client/client_proto_context.ml b/src/proto_alpha/lib_client/client_proto_context.ml index 2e4059259..5a3075284 100644 --- a/src/proto_alpha/lib_client/client_proto_context.ml +++ b/src/proto_alpha/lib_client/client_proto_context.ml @@ -70,8 +70,8 @@ let reveal cctxt Injection.inject_operation cctxt ~chain ~block ?confirmations ?dry_run ?branch ~src_sk contents >>=? fun (oph, op, result) -> - match Apply_operation_result.pack_contents_list op result with - | Apply_operation_result.Single_and_result + match Apply_results.pack_contents_list op result with + | Apply_results.Single_and_result (Manager_operation _ as op, result) -> return (oph, op, result) end @@ -320,8 +320,8 @@ let inject_activate_operation Tez.pp balance >>= fun () -> return_unit end >>=? fun () -> - match Apply_operation_result.pack_contents_list op result with - | Apply_operation_result.Single_and_result + match Apply_results.pack_contents_list op result with + | Apply_results.Single_and_result (Activate_account _ as op, result) -> return (oph, op, result) diff --git a/src/proto_alpha/lib_client/injection.ml b/src/proto_alpha/lib_client/injection.ml index 6589bd36b..b02bcb69a 100644 --- a/src/proto_alpha/lib_client/injection.ml +++ b/src/proto_alpha/lib_client/injection.ml @@ -9,7 +9,7 @@ open Proto_alpha open Alpha_context -open Apply_operation_result +open Apply_results let get_branch (rpc_config: #Proto_alpha.full) ~chain ~(block : Block_services.block) branch = @@ -64,8 +64,8 @@ let preapply (type t) | [(Operation_data op', Operation_metadata result)] -> begin match Operation.equal op { shell = { branch } ; protocol_data = op' }, - Apply_operation_result.kind_equal_list contents result.contents with - | Some Operation.Eq, Some Apply_operation_result.Eq -> + Apply_results.kind_equal_list contents result.contents with + | Some Operation.Eq, Some Apply_results.Eq -> return ((oph, op, result) : t preapply_result) | _ -> failwith "Unexpected result" end @@ -84,8 +84,8 @@ let simulate (type t) | (Operation_data op', Operation_metadata result) -> begin match Operation.equal op { shell = { branch } ; protocol_data = op' }, - Apply_operation_result.kind_equal_list contents result.contents with - | Some Operation.Eq, Some Apply_operation_result.Eq -> + Apply_results.kind_equal_list contents result.contents with + | Some Operation.Eq, Some Apply_results.Eq -> return ((oph, op, result) : t preapply_result) | _ -> failwith "Unexpected result" end @@ -388,9 +388,9 @@ let inject_operation | No_operation_metadata -> failwith "Internal error: unexpected receipt." | Operation_metadata receipt -> - match Apply_operation_result.kind_equal_list contents receipt.contents + match Apply_results.kind_equal_list contents receipt.contents with - | Some Apply_operation_result.Eq -> + | Some Apply_results.Eq -> return (receipt : kind operation_metadata) | None -> failwith "Internal error: unexpected receipt." end >>=? fun result -> diff --git a/src/proto_alpha/lib_client/injection.mli b/src/proto_alpha/lib_client/injection.mli index 08cfd6cf4..c67fdac71 100644 --- a/src/proto_alpha/lib_client/injection.mli +++ b/src/proto_alpha/lib_client/injection.mli @@ -9,7 +9,7 @@ open Proto_alpha open Alpha_context -open Apply_operation_result +open Apply_results type 'kind preapply_result = Operation_hash.t * 'kind operation * 'kind operation_metadata diff --git a/src/proto_alpha/lib_client/operation_result.ml b/src/proto_alpha/lib_client/operation_result.ml index b223c321c..c15b03b0a 100644 --- a/src/proto_alpha/lib_client/operation_result.ml +++ b/src/proto_alpha/lib_client/operation_result.ml @@ -9,7 +9,7 @@ open Proto_alpha open Alpha_context -open Apply_operation_result +open Apply_results let pp_manager_operation_content (type kind) source internal pp_result @@ -391,7 +391,7 @@ let pp_operation_result ppf (op, res : 'kind contents_list * 'kind contents_result_list) = Format.fprintf ppf "@[" ; let contents_and_result_list = - Apply_operation_result.pack_contents_list op res in + Apply_results.pack_contents_list op res in pp_contents_and_result_list ppf contents_and_result_list ; Format.fprintf ppf "@]@." diff --git a/src/proto_alpha/lib_client/operation_result.mli b/src/proto_alpha/lib_client/operation_result.mli index caed105bf..69316db62 100644 --- a/src/proto_alpha/lib_client/operation_result.mli +++ b/src/proto_alpha/lib_client/operation_result.mli @@ -15,4 +15,4 @@ val pp_internal_operation: val pp_operation_result: Format.formatter -> - ('kind contents_list * 'kind Apply_operation_result.contents_result_list) -> unit + ('kind contents_list * 'kind Apply_results.contents_result_list) -> unit diff --git a/src/proto_alpha/lib_delegate/client_baking_denunciation.ml b/src/proto_alpha/lib_delegate/client_baking_denunciation.ml index 5f983789e..aaeef8ee8 100644 --- a/src/proto_alpha/lib_delegate/client_baking_denunciation.ml +++ b/src/proto_alpha/lib_delegate/client_baking_denunciation.ml @@ -49,7 +49,7 @@ let fetch_baker (cctxt : #Proto_alpha.full) ~chain ~block = let get_block_offset level = match Alpha_environment.wrap_error (Raw_level.of_int32 5l) with | Ok min_level -> - Lwt.return + Lwt.return (if Raw_level.(level < min_level) then `Head 0 else @@ -63,7 +63,7 @@ let process_endorsements (cctxt : #Proto_alpha.full) state ~chain iter_s (fun { Alpha_block_services.shell ; receipt ; hash ; protocol_data ; _ } -> match protocol_data, receipt with | (Operation_data ({ contents = Single (Endorsement _) ; _ } as protocol_data)), - Apply_operation_result.( + Apply_results.( Operation_metadata { contents = Single_result (Endorsement_result { delegate ; _ }) }) -> let new_endorsement : Kind.endorsement Alpha_context.operation = { shell ; protocol_data } in let map = match HLevel.find_opt state.endorsements_table level with @@ -168,7 +168,7 @@ let process_new_block (cctxt : #Proto_alpha.full) state { hash ; chain_id ; leve if Protocol_hash.(protocol <> next_protocol) then lwt_log_error "Protocol changing detected. Skipping the block." >>= fun () -> return_unit - else + else lwt_debug "Block level : %a" Raw_level.pp level >>= fun () -> let chain = `Hash chain_id in let block = `Hash (hash, 0) in diff --git a/src/proto_alpha/lib_protocol/src/TEZOS_PROTOCOL b/src/proto_alpha/lib_protocol/src/TEZOS_PROTOCOL index f466d61a7..f096ccd80 100644 --- a/src/proto_alpha/lib_protocol/src/TEZOS_PROTOCOL +++ b/src/proto_alpha/lib_protocol/src/TEZOS_PROTOCOL @@ -65,7 +65,7 @@ "Baking", "Amendment", - "Apply_operation_result", + "Apply_results", "Apply", "Services_registration", diff --git a/src/proto_alpha/lib_protocol/src/apply.ml b/src/proto_alpha/lib_protocol/src/apply.ml index b87839a2c..1468ba359 100644 --- a/src/proto_alpha/lib_protocol/src/apply.ml +++ b/src/proto_alpha/lib_protocol/src/apply.ml @@ -320,7 +320,7 @@ let () = (function Multiple_revelation -> Some () | _ -> None) (fun () -> Multiple_revelation) -open Apply_operation_result +open Apply_results let apply_manager_operation_content : type kind. diff --git a/src/proto_alpha/lib_protocol/src/apply_operation_result.ml b/src/proto_alpha/lib_protocol/src/apply_results.ml similarity index 100% rename from src/proto_alpha/lib_protocol/src/apply_operation_result.ml rename to src/proto_alpha/lib_protocol/src/apply_results.ml diff --git a/src/proto_alpha/lib_protocol/src/apply_operation_result.mli b/src/proto_alpha/lib_protocol/src/apply_results.mli similarity index 100% rename from src/proto_alpha/lib_protocol/src/apply_operation_result.mli rename to src/proto_alpha/lib_protocol/src/apply_results.mli diff --git a/src/proto_alpha/lib_protocol/src/helpers_services.ml b/src/proto_alpha/lib_protocol/src/helpers_services.ml index 32d6e7dcb..d26a6702a 100644 --- a/src/proto_alpha/lib_protocol/src/helpers_services.ml +++ b/src/proto_alpha/lib_protocol/src/helpers_services.ml @@ -130,7 +130,7 @@ module Scripts = struct "Run an operation without signature checks" ~query: RPC_query.empty ~input: Operation.encoding - ~output: Apply_operation_result.operation_data_and_metadata_encoding + ~output: Apply_results.operation_data_and_metadata_encoding RPC_path.(path / "run_operation") end @@ -238,7 +238,7 @@ module Scripts = struct partial_precheck_manager_contents_list ctxt rest in let return contents = return (Operation_data protocol_data, - Apply_operation_result.Operation_metadata { contents }) in + Apply_results.Operation_metadata { contents }) in let operation : _ operation = { shell ; protocol_data } in let hash = Operation.hash { shell ; protocol_data } in let ctxt = Contract.init_origination_nonce ctxt hash in diff --git a/src/proto_alpha/lib_protocol/src/helpers_services.mli b/src/proto_alpha/lib_protocol/src/helpers_services.mli index cf321c179..12f1bb5a5 100644 --- a/src/proto_alpha/lib_protocol/src/helpers_services.mli +++ b/src/proto_alpha/lib_protocol/src/helpers_services.mli @@ -53,7 +53,7 @@ module Scripts : sig val run_operation: 'a #RPC_context.simple -> 'a -> packed_operation -> - (packed_protocol_data * Apply_operation_result.packed_operation_metadata) shell_tzresult Lwt.t + (packed_protocol_data * Apply_results.packed_operation_metadata) shell_tzresult Lwt.t end diff --git a/src/proto_alpha/lib_protocol/src/main.ml b/src/proto_alpha/lib_protocol/src/main.ml index 2d3d7069d..87950d5cb 100644 --- a/src/proto_alpha/lib_protocol/src/main.ml +++ b/src/proto_alpha/lib_protocol/src/main.ml @@ -24,14 +24,14 @@ type operation_data = Alpha_context.packed_protocol_data = | Operation_data : 'kind Alpha_context.Operation.protocol_data -> operation_data let operation_data_encoding = Alpha_context.Operation.protocol_data_encoding -type operation_receipt = Apply_operation_result.packed_operation_metadata = - | Operation_metadata : 'kind Apply_operation_result.operation_metadata -> operation_receipt +type operation_receipt = Apply_results.packed_operation_metadata = + | Operation_metadata : 'kind Apply_results.operation_metadata -> operation_receipt | No_operation_metadata: operation_receipt let operation_receipt_encoding = - Apply_operation_result.operation_metadata_encoding + Apply_results.operation_metadata_encoding let operation_data_and_receipt_encoding = - Apply_operation_result.operation_data_and_metadata_encoding + Apply_results.operation_data_and_metadata_encoding type operation = Alpha_context.packed_operation = { shell: Operation.shell_header ; diff --git a/src/proto_alpha/lib_protocol/src/main.mli b/src/proto_alpha/lib_protocol/src/main.mli index 9d8cd1299..a8be17c3d 100644 --- a/src/proto_alpha/lib_protocol/src/main.mli +++ b/src/proto_alpha/lib_protocol/src/main.mli @@ -46,6 +46,6 @@ include Updater.PROTOCOL and type block_header_metadata = Alpha_context.Block_header.metadata and type block_header = Alpha_context.Block_header.t and type operation_data := operation_data - and type operation_receipt = Apply_operation_result.packed_operation_metadata + and type operation_receipt = Apply_results.packed_operation_metadata and type operation := operation and type validation_state := validation_state diff --git a/src/proto_alpha/lib_protocol/test/helpers/incremental.ml b/src/proto_alpha/lib_protocol/test/helpers/incremental.ml index 11ef10aff..1d7e63f89 100644 --- a/src/proto_alpha/lib_protocol/test/helpers/incremental.ml +++ b/src/proto_alpha/lib_protocol/test/helpers/incremental.ml @@ -82,15 +82,15 @@ let begin_construction ?(priority=0) ?timestamp (predecessor : Block.t) = } let detect_script_failure : - type kind. kind Apply_operation_result.operation_metadata -> _ = + type kind. kind Apply_results.operation_metadata -> _ = let rec detect_script_failure : - type kind. kind Apply_operation_result.contents_result_list -> _ = - let open Apply_operation_result in + type kind. kind Apply_results.contents_result_list -> _ = + let open Apply_results in let detect_script_failure_single (type kind) (Manager_operation_result { operation_result ; internal_operation_results } - : kind Kind.manager Apply_operation_result.contents_result) = + : kind Kind.manager Apply_results.contents_result) = let detect_script_failure (type kind) (result : kind manager_operation_result) = match result with | Applied _ -> Ok () @@ -119,7 +119,7 @@ let detect_script_failure : fun { contents } -> detect_script_failure contents let add_operation ?expect_failure st op = - let open Apply_operation_result in + let open Apply_results in M.apply_operation st.state op >>=? function | state, Operation_metadata result -> Lwt.return @@ detect_script_failure result >>= fun result ->