Data_encoding: add descriptions to encodings

This commit is contained in:
Milo Davis 2018-03-27 09:15:03 -04:00 committed by Grégoire Henry
parent f5cc599ae6
commit ebfdeea8d5
10 changed files with 206 additions and 123 deletions

View File

@ -131,114 +131,158 @@ module Pool_event = struct
(merge_objs
(obj1 (req "event" (constant name))) obj) in
union ~tag_size:`Uint8 [
case (Tag 0) (branch_encoding "too_few_connections" empty)
case (Tag 0)
~name:"too_few_connections"
(branch_encoding "too_few_connections" empty)
(function Too_few_connections -> Some () | _ -> None)
(fun () -> Too_few_connections) ;
case (Tag 1) (branch_encoding "too_many_connections" empty)
case (Tag 1)
~name:"too_many_connections"
(branch_encoding "too_many_connections" empty)
(function Too_many_connections -> Some () | _ -> None)
(fun () -> Too_many_connections) ;
case (Tag 2) (branch_encoding "new_point"
(obj1 (req "point" P2p_point.Id.encoding)))
case (Tag 2)
~name:"new_point"
(branch_encoding "new_point"
(obj1 (req "point" P2p_point.Id.encoding)))
(function New_point p -> Some p | _ -> None)
(fun p -> New_point p) ;
case (Tag 3) (branch_encoding "new_peer"
(obj1 (req "peer_id" P2p_peer_id.encoding)))
case (Tag 3)
~name:"new_peer"
(branch_encoding "new_peer"
(obj1 (req "peer_id" P2p_peer_id.encoding)))
(function New_peer p -> Some p | _ -> None)
(fun p -> New_peer p) ;
case (Tag 4) (branch_encoding "incoming_connection"
(obj1 (req "point" P2p_point.Id.encoding)))
case (Tag 4)
~name:"incoming_connection"
(branch_encoding "incoming_connection"
(obj1 (req "point" P2p_point.Id.encoding)))
(function Incoming_connection p -> Some p | _ -> None)
(fun p -> Incoming_connection p) ;
case (Tag 5) (branch_encoding "outgoing_connection"
(obj1 (req "point" P2p_point.Id.encoding)))
case (Tag 5)
~name:"outgoing_connection"
(branch_encoding "outgoing_connection"
(obj1 (req "point" P2p_point.Id.encoding)))
(function Outgoing_connection p -> Some p | _ -> None)
(fun p -> Outgoing_connection p) ;
case (Tag 6) (branch_encoding "authentication_failed"
(obj1 (req "point" P2p_point.Id.encoding)))
case (Tag 6)
~name:"authentication_failed"
(branch_encoding "authentication_failed"
(obj1 (req "point" P2p_point.Id.encoding)))
(function Authentication_failed p -> Some p | _ -> None)
(fun p -> Authentication_failed p) ;
case (Tag 7) (branch_encoding "accepting_request"
(obj3
(req "point" P2p_point.Id.encoding)
(req "id_point" Id.encoding)
(req "peer_id" P2p_peer_id.encoding)))
case (Tag 7)
~name:"accepting_request"
(branch_encoding "accepting_request"
(obj3
(req "point" P2p_point.Id.encoding)
(req "id_point" Id.encoding)
(req "peer_id" P2p_peer_id.encoding)))
(function Accepting_request (p, id_p, g) ->
Some (p, id_p, g) | _ -> None)
(fun (p, id_p, g) -> Accepting_request (p, id_p, g)) ;
case (Tag 8) (branch_encoding "rejecting_request"
(obj3
(req "point" P2p_point.Id.encoding)
(req "id_point" Id.encoding)
(req "peer_id" P2p_peer_id.encoding)))
case (Tag 8)
~name:"rejecting_request"
(branch_encoding "rejecting_request"
(obj3
(req "point" P2p_point.Id.encoding)
(req "id_point" Id.encoding)
(req "peer_id" P2p_peer_id.encoding)))
(function Rejecting_request (p, id_p, g) ->
Some (p, id_p, g) | _ -> None)
(fun (p, id_p, g) -> Rejecting_request (p, id_p, g)) ;
case (Tag 9) (branch_encoding "request_rejected"
(obj2
(req "point" P2p_point.Id.encoding)
(opt "identity"
(tup2 Id.encoding P2p_peer_id.encoding))))
case (Tag 9)
~name:"request_rejected"
(branch_encoding "request_rejected"
(obj2
(req "point" P2p_point.Id.encoding)
(opt "identity"
(tup2 Id.encoding P2p_peer_id.encoding))))
(function Request_rejected (p, id) -> Some (p, id) | _ -> None)
(fun (p, id) -> Request_rejected (p, id)) ;
case (Tag 10) (branch_encoding "connection_established"
(obj2
(req "id_point" Id.encoding)
(req "peer_id" P2p_peer_id.encoding)))
case (Tag 10)
~name:"connection_established"
(branch_encoding "connection_established"
(obj2
(req "id_point" Id.encoding)
(req "peer_id" P2p_peer_id.encoding)))
(function Connection_established (id_p, g) ->
Some (id_p, g) | _ -> None)
(fun (id_p, g) -> Connection_established (id_p, g)) ;
case (Tag 11) (branch_encoding "disconnection"
(obj1 (req "peer_id" P2p_peer_id.encoding)))
case (Tag 11)
~name:"disconnection"
(branch_encoding "disconnection"
(obj1 (req "peer_id" P2p_peer_id.encoding)))
(function Disconnection g -> Some g | _ -> None)
(fun g -> Disconnection g) ;
case (Tag 12) (branch_encoding "external_disconnection"
(obj1 (req "peer_id" P2p_peer_id.encoding)))
case (Tag 12)
~name:"external_disconnection"
(branch_encoding "external_disconnection"
(obj1 (req "peer_id" P2p_peer_id.encoding)))
(function External_disconnection g -> Some g | _ -> None)
(fun g -> External_disconnection g) ;
case (Tag 13) (branch_encoding "gc_points" empty)
case (Tag 13)
~name:"gc_points"
(branch_encoding "gc_points" empty)
(function Gc_points -> Some () | _ -> None)
(fun () -> Gc_points) ;
case (Tag 14) (branch_encoding "gc_peer_ids" empty)
case (Tag 14)
~name:"gc_peer_ids"
(branch_encoding "gc_peer_ids" empty)
(function Gc_peer_ids -> Some () | _ -> None)
(fun () -> Gc_peer_ids) ;
case (Tag 15) (branch_encoding "swap_request_received"
(obj1 (req "source" P2p_peer_id.encoding)))
case (Tag 15)
~name:"swap_request_received"
(branch_encoding "swap_request_received"
(obj1 (req "source" P2p_peer_id.encoding)))
(function
| Swap_request_received { source } -> Some source
| _ -> None)
(fun source -> Swap_request_received { source }) ;
case (Tag 16) (branch_encoding "swap_ack_received"
(obj1 (req "source" P2p_peer_id.encoding)))
case (Tag 16)
~name:"swap_ack_received"
(branch_encoding "swap_ack_received"
(obj1 (req "source" P2p_peer_id.encoding)))
(function
| Swap_ack_received { source } -> Some source
| _ -> None)
(fun source -> Swap_ack_received { source }) ;
case (Tag 17) (branch_encoding "swap_request_sent"
(obj1 (req "source" P2p_peer_id.encoding)))
case (Tag 17)
~name:"swap_request_sent"
(branch_encoding "swap_request_sent"
(obj1 (req "source" P2p_peer_id.encoding)))
(function
| Swap_request_sent { source } -> Some source
| _ -> None)
(fun source -> Swap_request_sent { source }) ;
case (Tag 18) (branch_encoding "swap_ack_sent"
(obj1 (req "source" P2p_peer_id.encoding)))
case (Tag 18)
~name:"swap_ack_sent"
(branch_encoding "swap_ack_sent"
(obj1 (req "source" P2p_peer_id.encoding)))
(function
| Swap_ack_sent { source } -> Some source
| _ -> None)
(fun source -> Swap_ack_sent { source }) ;
case (Tag 19) (branch_encoding "swap_request_ignored"
(obj1 (req "source" P2p_peer_id.encoding)))
case (Tag 19)
~name:"swap_request_ignored"
(branch_encoding "swap_request_ignored"
(obj1 (req "source" P2p_peer_id.encoding)))
(function
| Swap_request_ignored { source } -> Some source
| _ -> None)
(fun source -> Swap_request_ignored { source }) ;
case (Tag 20) (branch_encoding "swap_success"
(obj1 (req "source" P2p_peer_id.encoding)))
case (Tag 20)
~name:"swap_success"
(branch_encoding "swap_success"
(obj1 (req "source" P2p_peer_id.encoding)))
(function
| Swap_success { source } -> Some source
| _ -> None)
(fun source -> Swap_success { source }) ;
case (Tag 21) (branch_encoding "swap_failure"
(obj1 (req "source" P2p_peer_id.encoding)))
case (Tag 21)
~name:"swap_failure"
(branch_encoding "swap_failure"
(obj1 (req "source" P2p_peer_id.encoding)))
(function
| Swap_failure { source } -> Some source
| _ -> None)

View File

@ -142,18 +142,26 @@ module State = struct
(merge_objs
(obj1 (req "event_kind" (constant name))) obj) in
union ~tag_size:`Uint8 [
case (Tag 0) (branch_encoding "requested" empty)
case (Tag 0)
~name:"requested"
(branch_encoding "requested" empty)
(function Requested -> Some () | _ -> None)
(fun () -> Requested) ;
case (Tag 1) (branch_encoding "accepted"
(obj1 (req "p2p_peer_id" P2p_peer_id.encoding)))
case (Tag 1)
~name:"accepted"
(branch_encoding "accepted"
(obj1 (req "p2p_peer_id" P2p_peer_id.encoding)))
(function Accepted p2p_peer_id -> Some p2p_peer_id | _ -> None)
(fun p2p_peer_id -> Accepted p2p_peer_id) ;
case (Tag 2) (branch_encoding "running"
(obj1 (req "p2p_peer_id" P2p_peer_id.encoding)))
case (Tag 2)
~name:"running"
(branch_encoding "running"
(obj1 (req "p2p_peer_id" P2p_peer_id.encoding)))
(function Running p2p_peer_id -> Some p2p_peer_id | _ -> None)
(fun p2p_peer_id -> Running p2p_peer_id) ;
case (Tag 3) (branch_encoding "disconnected" empty)
case (Tag 3)
~name:"disconnected"
(branch_encoding "disconnected" empty)
(function Disconnected -> Some () | _ -> None)
(fun () -> Disconnected) ;
]

View File

@ -22,12 +22,13 @@ type t =
let encoding =
let open Data_encoding in
describe ~title:"Test chain status" @@
union [
case (Tag 0)
case (Tag 0) ~name:"Not_running"
(obj1 (req "status" (constant "not_running")))
(function Not_running -> Some () | _ -> None)
(fun () -> Not_running) ;
case (Tag 1)
case (Tag 1) ~name:"Forking"
(obj3
(req "status" (constant "forking"))
(req "protocol" Protocol_hash.encoding)
@ -38,7 +39,7 @@ let encoding =
| _ -> None)
(fun ((), protocol, expiration) ->
Forking { protocol ; expiration }) ;
case (Tag 2)
case (Tag 2) ~name:"Running"
(obj5
(req "status" (constant "running"))
(req "chain_id" Chain_id.encoding)

View File

@ -93,6 +93,7 @@ module T = struct
let encoding =
let open Data_encoding in
describe ~title:"timestamp" @@
splitted
~binary: int64
~json:

View File

@ -39,21 +39,24 @@ module Message = struct
let open Data_encoding in
dynamic_size @@
union ~tag_size:`Uint16
([ case (Tag 0x01) null
([ case (Tag 0x01) ~name:"Disconnect" null
(function Disconnect -> Some () | _ -> None)
(fun () -> Disconnect);
case (Tag 0x02) null
case (Tag 0x02) ~name:"Bootstrap" null
(function Bootstrap -> Some () | _ -> None)
(fun () -> Bootstrap);
case (Tag 0x03) (Variable.list P2p_point.Id.encoding)
case (Tag 0x03) ~name:"Advertise" (Variable.list P2p_point.Id.encoding)
(function Advertise points -> Some points | _ -> None)
(fun points -> Advertise points);
case (Tag 0x04) (tup2 P2p_point.Id.encoding P2p_peer.Id.encoding)
case (Tag 0x04) ~name:"Swap_request"
(tup2 P2p_point.Id.encoding P2p_peer.Id.encoding)
(function
| Swap_request (point, peer_id) -> Some (point, peer_id)
| _ -> None)
(fun (point, peer_id) -> Swap_request (point, peer_id)) ;
case (Tag 0x05) (tup2 P2p_point.Id.encoding P2p_peer.Id.encoding)
case (Tag 0x05)
~name:"Swap_ack"
(tup2 P2p_point.Id.encoding P2p_peer.Id.encoding)
(function
| Swap_ack (point, peer_id) -> Some (point, peer_id)
| _ -> None)

View File

@ -95,9 +95,11 @@ let pp_block_info ppf
let block_info_encoding =
let operation_encoding =
describe ~title:"Operation hash" @@
merge_objs
(obj1 (req "hash" Operation_hash.encoding))
Operation.encoding in
describe ~title:"Block info" @@
conv
(fun { hash ; chain_id ; level ; proto_level ; predecessor ;
fitness ; timestamp ; protocol ;
@ -136,6 +138,7 @@ type preapply_result = {
}
let preapply_result_encoding =
describe ~title:"Preapply result" @@
(conv
(fun { shell_header ; operations } ->
(shell_header, operations))
@ -188,7 +191,7 @@ module S = struct
RPC_service.post_service
~description:"All the information about a block."
~query: RPC_query.empty
~input: (obj1 (dft "operations" bool true))
~input: (describe ~title:"Operations" (obj1 (dft "operations" bool true)))
~output: block_info_encoding
block_path
@ -197,7 +200,7 @@ module S = struct
~description:"Returns the chain in which the block belongs."
~query: RPC_query.empty
~input: empty
~output: (obj1 (req "chain_id" Chain_id.encoding))
~output: (describe ~title:"Chain ID" (obj1 (req "chain_id" Chain_id.encoding)))
RPC_path.(block_path / "chain_id")
let level =
@ -205,7 +208,7 @@ module S = struct
~description:"Returns the block's level."
~query: RPC_query.empty
~input: empty
~output: (obj1 (req "level" int32))
~output: (describe ~title:"Level" (obj1 (req "level" int32)))
RPC_path.(block_path / "level")
let predecessor =
@ -213,7 +216,7 @@ module S = struct
~description:"Returns the previous block's id."
~query: RPC_query.empty
~input: empty
~output: (obj1 (req "predecessor" Block_hash.encoding))
~output: (describe ~title:"Predecessor" (obj1 (req "predecessor" Block_hash.encoding)))
RPC_path.(block_path / "predecessor")
let predecessors =
@ -221,9 +224,10 @@ module S = struct
~description:
"...."
~query: RPC_query.empty
~input: (obj1 (req "length" Data_encoding.uint16))
~output: (obj1
(req "blocks" (Data_encoding.list Block_hash.encoding)))
~input: (describe ~title:"Num predecessors" (obj1 (req "length" Data_encoding.uint16)))
~output:(describe ~title:"Block hash list"
(obj1
(req "blocks" (list Block_hash.encoding))))
RPC_path.(block_path / "predecessors")
let hash =
@ -239,7 +243,7 @@ module S = struct
~description:"Returns the block's fitness."
~query: RPC_query.empty
~input: empty
~output: (obj1 (req "fitness" Fitness.encoding))
~output: (describe ~title:"Fitness" (obj1 (req "fitness" Fitness.encoding)))
RPC_path.(block_path / "fitness")
let context =
@ -247,7 +251,7 @@ module S = struct
~description:"Returns the hash of the resulting context."
~query: RPC_query.empty
~input: empty
~output: (obj1 (req "context" Context_hash.encoding))
~output: (describe ~title:"Context hash" (obj1 (req "context" Context_hash.encoding)))
RPC_path.(block_path / "context")
let raw_context_args : string RPC_arg.t =
@ -259,16 +263,17 @@ module S = struct
let raw_context_result_encoding : raw_context_result Data_encoding.t =
let open Data_encoding in
describe ~title:"Raw Context" @@
obj1 (req "content"
(mu "context_tree" (fun raw_context_result_encoding ->
union [
case (Tag 0) bytes
case (Tag 0) ~name:"Key" bytes
(function Key k -> Some k | _ -> None)
(fun k -> Key k) ;
case (Tag 1) (assoc raw_context_result_encoding)
case (Tag 1) ~name:"Dir" (assoc raw_context_result_encoding)
(function Dir k -> Some k | _ -> None)
(fun k -> Dir k) ;
case (Tag 2) null
case (Tag 2) ~name:"Cut" null
(function Cut -> Some () | _ -> None)
(fun () -> Cut) ;
])))
@ -296,7 +301,7 @@ module S = struct
~description:"Returns the block's timestamp."
~query: RPC_query.empty
~input: empty
~output: (obj1 (req "timestamp" Time.encoding))
~output:(describe ~title:"Timestamp" (obj1 (req "timestamp" Time.encoding)))
RPC_path.(block_path / "timestamp")
type operations_param = {
@ -305,6 +310,7 @@ module S = struct
let operations_param_encoding =
let open Data_encoding in
describe ~title:"Operations param" @@
conv
(fun { contents } -> (contents))
(fun (contents) -> { contents })
@ -315,13 +321,18 @@ module S = struct
~description:"List the block operations."
~query: RPC_query.empty
~input: operations_param_encoding
~output: (obj1
(req "operations"
(list (list
(obj2
(req "hash" Operation_hash.encoding)
(opt "contents"
(dynamic_size Operation.encoding)))))))
~output:
(describe ~title:"Operations" @@
obj1
(req "operations"
(list
(describe ~title:"Operation/operation hash pair list"
(list
(describe ~title:"Operation, operation hash pairs"
(obj2
(req "hash" Operation_hash.encoding)
(opt "contents"
(dynamic_size Operation.encoding)))))))))
RPC_path.(block_path / "operations")
let protocol =
@ -329,7 +340,8 @@ module S = struct
~description:"List the block protocol."
~query: RPC_query.empty
~input: empty
~output: (obj1 (req "protocol" Protocol_hash.encoding))
~output: (describe ~title:"Block protocol"
(obj1 (req "protocol" Protocol_hash.encoding)))
RPC_path.(block_path / "protocol")
let test_chain =
@ -348,6 +360,7 @@ module S = struct
}
let preapply_param_encoding =
describe ~title:"Preapply param" @@
(conv
(fun { timestamp ; protocol_data ; operations ; sort_operations } ->
(timestamp, protocol_data, operations, sort_operations))
@ -380,7 +393,7 @@ module S = struct
block, operations, public_keys and contracts."
~query: RPC_query.empty
~input: empty
~output: (list string)
~output: (describe ~title:"String list" (list string))
RPC_path.(block_path / "complete" /: prefix_arg )
type list_param = {
@ -393,6 +406,7 @@ module S = struct
min_heads: int option;
}
let list_param_encoding =
describe ~title:"List blocks param" @@
conv
(fun { include_ops ; length ; heads ; monitor ;
delay ; min_date ; min_heads } ->
@ -467,10 +481,11 @@ module S = struct
~query: RPC_query.empty
~input:empty
~output:(Data_encoding.list
(obj3
(req "block" Block_hash.encoding)
(req "level" int32)
(req "errors" RPC_error.encoding)))
(describe ~title:"Invalid block"
(obj3
(req "block" Block_hash.encoding)
(req "level" int32)
(req "errors" RPC_error.encoding))))
RPC_path.(root / "invalid_blocks")
let unmark_invalid =

View File

@ -48,18 +48,19 @@ module Event = struct
let encoding =
let open Data_encoding in
describe ~title:"Event state" @@
union
[ case (Tag 0)
[ case (Tag 0) ~name:"Debug"
(obj1 (req "message" string))
(function Debug msg -> Some msg | _ -> None)
(fun msg -> Debug msg) ;
case (Tag 1)
case (Tag 1) ~name:"Validation_success"
(obj2
(req "successful_validation" Request.encoding)
(req "status" Worker_types.request_status_encoding))
(function Validation_success (r, s) -> Some (r, s) | _ -> None)
(fun (r, s) -> Validation_success (r, s)) ;
case (Tag 2)
case (Tag 2) ~name:"Validation_failure"
(obj3
(req "failed_validation" Request.encoding)
(req "status" Worker_types.request_status_encoding)

View File

@ -15,13 +15,13 @@ module Request = struct
let encoding =
let open Data_encoding in
union
[ case (Tag 0)
[ case (Tag 0) ~name:"New_head"
(obj2
(req "request" (constant "new_head"))
(req "block" Block_hash.encoding))
(function New_head h -> Some ((), h) | _ -> None)
(fun ((), h) -> New_head h) ;
case (Tag 1)
case (Tag 1) ~name:"New_branch"
(obj3
(req "request" (constant "new_branch"))
(req "block" Block_hash.encoding)

View File

@ -104,26 +104,28 @@ module Encoding = struct
open Data_encoding
let reveal_encoding =
describe ~title:"Reveal operation" @@
(obj2
(req "kind" (constant "reveal"))
(req "public_key" Signature.Public_key.encoding))
let reveal_case tag =
case tag reveal_encoding
case tag ~name:"Reveal" reveal_encoding
(function
| Reveal pkh -> Some ((), pkh)
| _ -> None)
(fun ((), pkh) -> Reveal pkh)
let transaction_encoding =
(obj4
(req "kind" (constant "transaction"))
(req "amount" Tez_repr.encoding)
(req "destination" Contract_repr.encoding)
(opt "parameters" Script_repr.expr_encoding))
describe ~title:"Transaction operation" @@
obj4
(req "kind" (constant "transaction"))
(req "amount" Tez_repr.encoding)
(req "destination" Contract_repr.encoding)
(opt "parameters" Script_repr.expr_encoding)
let transaction_case tag =
case tag transaction_encoding
case tag ~name:"Transaction" transaction_encoding
(function
| Transaction { amount ; destination ; parameters } ->
Some ((), amount, destination, parameters)
@ -132,6 +134,7 @@ module Encoding = struct
Transaction { amount ; destination ; parameters })
let origination_encoding =
describe ~title:"Origination operation" @@
(obj7
(req "kind" (constant "origination"))
(req "managerPubkey" Signature.Public_key_hash.encoding)
@ -142,7 +145,7 @@ module Encoding = struct
(opt "script" Script_repr.encoding))
let origination_case tag =
case tag origination_encoding
case tag ~name:"Origination" origination_encoding
(function
| Origination { manager ; credit ; spendable ;
delegatable ; delegate ; script } ->
@ -158,31 +161,33 @@ module Encoding = struct
{manager ; credit ; spendable ; delegatable ; delegate ; script })
let delegation_encoding =
describe ~title:"Delegation operation" @@
(obj2
(req "kind" (constant "delegation"))
(opt "delegate" Signature.Public_key_hash.encoding))
let delegation_case tag =
case tag delegation_encoding
case tag ~name:"Delegation" delegation_encoding
(function Delegation key -> Some ((), key) | _ -> None)
(fun ((), key) -> Delegation key)
let manager_kind_encoding =
(obj5
(req "kind" (constant "manager"))
(req "source" Contract_repr.encoding)
(req "fee" Tez_repr.encoding)
(req "counter" int32)
(req "operations"
(list (union ~tag_size:`Uint8 [
reveal_case (Tag 0) ;
transaction_case (Tag 1) ;
origination_case (Tag 2) ;
delegation_case (Tag 3) ;
]))))
obj5
(req "kind" (constant "manager"))
(req "source" Contract_repr.encoding)
(req "fee" Tez_repr.encoding)
(req "counter" int32)
(req "operations"
(list (union ~tag_size:`Uint8 [
reveal_case (Tag 0) ;
transaction_case (Tag 1) ;
origination_case (Tag 2) ;
delegation_case (Tag 3) ;
])))
let manager_kind_case tag =
case tag manager_kind_encoding
case tag ~name:"Manager operations" manager_kind_encoding
(function
| Manager_operations { source; fee ; counter ;operations } ->
Some ((), source, fee, counter, operations)
@ -191,11 +196,12 @@ module Encoding = struct
Manager_operations { source; fee ; counter ; operations })
let endorsement_encoding =
(obj4
(req "kind" (constant "endorsement"))
(req "block" Block_hash.encoding)
(req "level" Raw_level_repr.encoding)
(req "slots" (list int31)))
(* describe ~title:"Endorsement operation" @@ *)
obj4
(req "kind" (constant "endorsement"))
(req "block" Block_hash.encoding)
(req "level" Raw_level_repr.encoding)
(req "slots" (list int31))
let consensus_kind_encoding =
conv
@ -397,9 +403,11 @@ module Encoding = struct
mu_proto_operation_encoding operation_encoding
let signed_proto_operation_encoding =
describe ~title:"Signed alpha operation" @@
mu_signed_proto_operation_encoding operation_encoding
let unsigned_operation_encoding =
describe ~title:"Unsigned Alpha operation" @@
merge_objs
Operation.shell_header_encoding
proto_operation_encoding

View File

@ -36,6 +36,7 @@ module Command = struct
let open Data_encoding in
union ~tag_size:`Uint8 [
case (Tag 0)
~name:"activate"
(mk_case "activate"
(obj3
(req "hash" Protocol_hash.encoding)
@ -49,6 +50,7 @@ module Command = struct
(fun (protocol, fitness, protocol_parameters) ->
Activate { protocol ; fitness ; protocol_parameters }) ;
case (Tag 1)
~name:"activate_testchain"
(mk_case "activate_testchain"
(obj2
(req "hash" Protocol_hash.encoding)