Alpha: rename apply_operation_result to apply_results

This commit is contained in:
Marco Stronati 2018-06-26 11:24:14 +02:00 committed by Benjamin Canou
parent 3d88707eb8
commit 91d497fd4a
15 changed files with 33 additions and 33 deletions

View File

@ -70,8 +70,8 @@ let reveal cctxt
Injection.inject_operation cctxt ~chain ~block ?confirmations Injection.inject_operation cctxt ~chain ~block ?confirmations
?dry_run ?dry_run
?branch ~src_sk contents >>=? fun (oph, op, result) -> ?branch ~src_sk contents >>=? fun (oph, op, result) ->
match Apply_operation_result.pack_contents_list op result with match Apply_results.pack_contents_list op result with
| Apply_operation_result.Single_and_result | Apply_results.Single_and_result
(Manager_operation _ as op, result) -> (Manager_operation _ as op, result) ->
return (oph, op, result) return (oph, op, result)
end end
@ -320,8 +320,8 @@ let inject_activate_operation
Tez.pp balance >>= fun () -> Tez.pp balance >>= fun () ->
return_unit return_unit
end >>=? fun () -> end >>=? fun () ->
match Apply_operation_result.pack_contents_list op result with match Apply_results.pack_contents_list op result with
| Apply_operation_result.Single_and_result | Apply_results.Single_and_result
(Activate_account _ as op, result) -> (Activate_account _ as op, result) ->
return (oph, op, result) return (oph, op, result)

View File

@ -9,7 +9,7 @@
open Proto_alpha open Proto_alpha
open Alpha_context open Alpha_context
open Apply_operation_result open Apply_results
let get_branch (rpc_config: #Proto_alpha.full) let get_branch (rpc_config: #Proto_alpha.full)
~chain ~(block : Block_services.block) branch = ~chain ~(block : Block_services.block) branch =
@ -64,8 +64,8 @@ let preapply (type t)
| [(Operation_data op', Operation_metadata result)] -> begin | [(Operation_data op', Operation_metadata result)] -> begin
match Operation.equal match Operation.equal
op { shell = { branch } ; protocol_data = op' }, op { shell = { branch } ; protocol_data = op' },
Apply_operation_result.kind_equal_list contents result.contents with Apply_results.kind_equal_list contents result.contents with
| Some Operation.Eq, Some Apply_operation_result.Eq -> | Some Operation.Eq, Some Apply_results.Eq ->
return ((oph, op, result) : t preapply_result) return ((oph, op, result) : t preapply_result)
| _ -> failwith "Unexpected result" | _ -> failwith "Unexpected result"
end end
@ -84,8 +84,8 @@ let simulate (type t)
| (Operation_data op', Operation_metadata result) -> begin | (Operation_data op', Operation_metadata result) -> begin
match Operation.equal match Operation.equal
op { shell = { branch } ; protocol_data = op' }, op { shell = { branch } ; protocol_data = op' },
Apply_operation_result.kind_equal_list contents result.contents with Apply_results.kind_equal_list contents result.contents with
| Some Operation.Eq, Some Apply_operation_result.Eq -> | Some Operation.Eq, Some Apply_results.Eq ->
return ((oph, op, result) : t preapply_result) return ((oph, op, result) : t preapply_result)
| _ -> failwith "Unexpected result" | _ -> failwith "Unexpected result"
end end
@ -388,9 +388,9 @@ let inject_operation
| No_operation_metadata -> | No_operation_metadata ->
failwith "Internal error: unexpected receipt." failwith "Internal error: unexpected receipt."
| Operation_metadata receipt -> | Operation_metadata receipt ->
match Apply_operation_result.kind_equal_list contents receipt.contents match Apply_results.kind_equal_list contents receipt.contents
with with
| Some Apply_operation_result.Eq -> | Some Apply_results.Eq ->
return (receipt : kind operation_metadata) return (receipt : kind operation_metadata)
| None -> failwith "Internal error: unexpected receipt." | None -> failwith "Internal error: unexpected receipt."
end >>=? fun result -> end >>=? fun result ->

View File

@ -9,7 +9,7 @@
open Proto_alpha open Proto_alpha
open Alpha_context open Alpha_context
open Apply_operation_result open Apply_results
type 'kind preapply_result = type 'kind preapply_result =
Operation_hash.t * 'kind operation * 'kind operation_metadata Operation_hash.t * 'kind operation * 'kind operation_metadata

View File

@ -9,7 +9,7 @@
open Proto_alpha open Proto_alpha
open Alpha_context open Alpha_context
open Apply_operation_result open Apply_results
let pp_manager_operation_content let pp_manager_operation_content
(type kind) source internal pp_result (type kind) source internal pp_result
@ -391,7 +391,7 @@ let pp_operation_result ppf
(op, res : 'kind contents_list * 'kind contents_result_list) = (op, res : 'kind contents_list * 'kind contents_result_list) =
Format.fprintf ppf "@[<v 0>" ; Format.fprintf ppf "@[<v 0>" ;
let contents_and_result_list = 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 ; pp_contents_and_result_list ppf contents_and_result_list ;
Format.fprintf ppf "@]@." Format.fprintf ppf "@]@."

View File

@ -15,4 +15,4 @@ val pp_internal_operation:
val pp_operation_result: val pp_operation_result:
Format.formatter -> Format.formatter ->
('kind contents_list * 'kind Apply_operation_result.contents_result_list) -> unit ('kind contents_list * 'kind Apply_results.contents_result_list) -> unit

View File

@ -49,7 +49,7 @@ let fetch_baker (cctxt : #Proto_alpha.full) ~chain ~block =
let get_block_offset level = let get_block_offset level =
match Alpha_environment.wrap_error (Raw_level.of_int32 5l) with match Alpha_environment.wrap_error (Raw_level.of_int32 5l) with
| Ok min_level -> | Ok min_level ->
Lwt.return Lwt.return
(if Raw_level.(level < min_level) then (if Raw_level.(level < min_level) then
`Head 0 `Head 0
else 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 ; _ } -> iter_s (fun { Alpha_block_services.shell ; receipt ; hash ; protocol_data ; _ } ->
match protocol_data, receipt with match protocol_data, receipt with
| (Operation_data ({ contents = Single (Endorsement _) ; _ } as protocol_data)), | (Operation_data ({ contents = Single (Endorsement _) ; _ } as protocol_data)),
Apply_operation_result.( Apply_results.(
Operation_metadata { contents = Single_result (Endorsement_result { delegate ; _ }) }) -> Operation_metadata { contents = Single_result (Endorsement_result { delegate ; _ }) }) ->
let new_endorsement : Kind.endorsement Alpha_context.operation = { shell ; protocol_data } in let new_endorsement : Kind.endorsement Alpha_context.operation = { shell ; protocol_data } in
let map = match HLevel.find_opt state.endorsements_table level with 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 if Protocol_hash.(protocol <> next_protocol) then
lwt_log_error "Protocol changing detected. Skipping the block." >>= fun () -> lwt_log_error "Protocol changing detected. Skipping the block." >>= fun () ->
return_unit return_unit
else else
lwt_debug "Block level : %a" Raw_level.pp level >>= fun () -> lwt_debug "Block level : %a" Raw_level.pp level >>= fun () ->
let chain = `Hash chain_id in let chain = `Hash chain_id in
let block = `Hash (hash, 0) in let block = `Hash (hash, 0) in

View File

@ -65,7 +65,7 @@
"Baking", "Baking",
"Amendment", "Amendment",
"Apply_operation_result", "Apply_results",
"Apply", "Apply",
"Services_registration", "Services_registration",

View File

@ -320,7 +320,7 @@ let () =
(function Multiple_revelation -> Some () | _ -> None) (function Multiple_revelation -> Some () | _ -> None)
(fun () -> Multiple_revelation) (fun () -> Multiple_revelation)
open Apply_operation_result open Apply_results
let apply_manager_operation_content : let apply_manager_operation_content :
type kind. type kind.

View File

@ -130,7 +130,7 @@ module Scripts = struct
"Run an operation without signature checks" "Run an operation without signature checks"
~query: RPC_query.empty ~query: RPC_query.empty
~input: Operation.encoding ~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") RPC_path.(path / "run_operation")
end end
@ -238,7 +238,7 @@ module Scripts = struct
partial_precheck_manager_contents_list ctxt rest in partial_precheck_manager_contents_list ctxt rest in
let return contents = let return contents =
return (Operation_data protocol_data, 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 operation : _ operation = { shell ; protocol_data } in
let hash = Operation.hash { shell ; protocol_data } in let hash = Operation.hash { shell ; protocol_data } in
let ctxt = Contract.init_origination_nonce ctxt hash in let ctxt = Contract.init_origination_nonce ctxt hash in

View File

@ -53,7 +53,7 @@ module Scripts : sig
val run_operation: val run_operation:
'a #RPC_context.simple -> 'a #RPC_context.simple ->
'a -> packed_operation -> '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 end

View File

@ -24,14 +24,14 @@ type operation_data = Alpha_context.packed_protocol_data =
| Operation_data : 'kind Alpha_context.Operation.protocol_data -> operation_data | Operation_data : 'kind Alpha_context.Operation.protocol_data -> operation_data
let operation_data_encoding = Alpha_context.Operation.protocol_data_encoding let operation_data_encoding = Alpha_context.Operation.protocol_data_encoding
type operation_receipt = Apply_operation_result.packed_operation_metadata = type operation_receipt = Apply_results.packed_operation_metadata =
| Operation_metadata : 'kind Apply_operation_result.operation_metadata -> operation_receipt | Operation_metadata : 'kind Apply_results.operation_metadata -> operation_receipt
| No_operation_metadata: operation_receipt | No_operation_metadata: operation_receipt
let operation_receipt_encoding = let operation_receipt_encoding =
Apply_operation_result.operation_metadata_encoding Apply_results.operation_metadata_encoding
let operation_data_and_receipt_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 = { type operation = Alpha_context.packed_operation = {
shell: Operation.shell_header ; shell: Operation.shell_header ;

View File

@ -46,6 +46,6 @@ include Updater.PROTOCOL
and type block_header_metadata = Alpha_context.Block_header.metadata and type block_header_metadata = Alpha_context.Block_header.metadata
and type block_header = Alpha_context.Block_header.t and type block_header = Alpha_context.Block_header.t
and type operation_data := operation_data 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 operation := operation
and type validation_state := validation_state and type validation_state := validation_state

View File

@ -82,15 +82,15 @@ let begin_construction ?(priority=0) ?timestamp (predecessor : Block.t) =
} }
let detect_script_failure : let detect_script_failure :
type kind. kind Apply_operation_result.operation_metadata -> _ = type kind. kind Apply_results.operation_metadata -> _ =
let rec detect_script_failure : let rec detect_script_failure :
type kind. kind Apply_operation_result.contents_result_list -> _ = type kind. kind Apply_results.contents_result_list -> _ =
let open Apply_operation_result in let open Apply_results in
let detect_script_failure_single let detect_script_failure_single
(type kind) (type kind)
(Manager_operation_result { operation_result ; (Manager_operation_result { operation_result ;
internal_operation_results } 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) = let detect_script_failure (type kind) (result : kind manager_operation_result) =
match result with match result with
| Applied _ -> Ok () | Applied _ -> Ok ()
@ -119,7 +119,7 @@ let detect_script_failure :
fun { contents } -> detect_script_failure contents fun { contents } -> detect_script_failure contents
let add_operation ?expect_failure st op = 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 M.apply_operation st.state op >>=? function
| state, Operation_metadata result -> | state, Operation_metadata result ->
Lwt.return @@ detect_script_failure result >>= fun result -> Lwt.return @@ detect_script_failure result >>= fun result ->