Alpha: add utility list conversion to operation application results

This commit is contained in:
Vincent Botbol 2018-08-03 15:37:45 +02:00 committed by Benjamin Canou
parent 6a4c4f83b4
commit ac7f4da1ab
No known key found for this signature in database
GPG Key ID: 73607948459DC5F8
2 changed files with 25 additions and 0 deletions

View File

@ -890,6 +890,25 @@ let rec unpack_contents_list :
let ops, ress = unpack_contents_list rest in
Cons (op, ops), Cons_result (res, ress)
let rec to_list = function
| Contents_result_list (Single_result o) -> [Contents_result o]
| Contents_result_list (Cons_result (o, os)) ->
Contents_result o :: to_list (Contents_result_list os)
let rec of_list = function
| [] -> assert false
| [Contents_result o] -> Contents_result_list (Single_result o)
| (Contents_result o) :: os ->
let Contents_result_list os = of_list os in
match o, os with
| Manager_operation_result _, Single_result (Manager_operation_result _) ->
Contents_result_list (Cons_result (o, os))
| Manager_operation_result _, Cons_result _ ->
Contents_result_list (Cons_result (o, os))
| _ ->
Pervasives.failwith "Operation result list of length > 1 \
should only contains manager operations result."
let operation_data_and_metadata_encoding =
def "operation.alpha.operation_with_metadata" @@
union [

View File

@ -140,6 +140,12 @@ val unpack_contents_list :
'kind contents_and_result_list ->
'kind contents_list * 'kind contents_result_list
val to_list :
packed_contents_result_list -> packed_contents_result list
val of_list :
packed_contents_result list -> packed_contents_result_list
type ('a, 'b) eq = Eq : ('a, 'a) eq
val kind_equal_list :
'kind contents_list -> 'kind2 contents_result_list -> ('kind, 'kind2) eq option