TMP precheck manager operation
This commit is contained in:
parent
ceddb09ea7
commit
5d8c73dacb
@ -487,11 +487,10 @@ let apply_internal_manager_operations ctxt mode ~payer ops =
|
|||||||
(rest @ emitted) in
|
(rest @ emitted) in
|
||||||
apply ctxt [] ops
|
apply ctxt [] ops
|
||||||
|
|
||||||
let apply_manager_contents
|
let precheck_manager_contents
|
||||||
(type kind) ctxt mode raw_operation (op : kind Kind.manager contents)
|
(type kind) ctxt raw_operation (op : kind Kind.manager contents)
|
||||||
: (context * kind Kind.manager contents_result) tzresult Lwt.t =
|
: context tzresult Lwt.t =
|
||||||
let Manager_operation
|
let Manager_operation { source ; fee ; counter ; operation } = op in
|
||||||
{ source ; fee ; counter ; operation ; gas_limit ; storage_limit } = op in
|
|
||||||
Contract.must_be_allocated ctxt source >>=? fun () ->
|
Contract.must_be_allocated ctxt source >>=? fun () ->
|
||||||
Contract.check_counter_increment ctxt source counter >>=? fun () ->
|
Contract.check_counter_increment ctxt source counter >>=? fun () ->
|
||||||
begin
|
begin
|
||||||
@ -505,6 +504,13 @@ let apply_manager_contents
|
|||||||
Contract.increment_counter ctxt source >>=? fun ctxt ->
|
Contract.increment_counter ctxt source >>=? fun ctxt ->
|
||||||
Contract.spend ctxt source fee >>=? fun ctxt ->
|
Contract.spend ctxt source fee >>=? fun ctxt ->
|
||||||
add_fees ctxt fee >>=? fun ctxt ->
|
add_fees ctxt fee >>=? fun ctxt ->
|
||||||
|
return ctxt
|
||||||
|
|
||||||
|
let apply_manager_contents
|
||||||
|
(type kind) ctxt mode (op : kind Kind.manager contents)
|
||||||
|
: (context * kind Kind.manager contents_result) tzresult Lwt.t =
|
||||||
|
let Manager_operation
|
||||||
|
{ source ; fee ; operation ; gas_limit ; storage_limit } = op in
|
||||||
Lwt.return (Gas.set_limit ctxt gas_limit) >>=? fun ctxt ->
|
Lwt.return (Gas.set_limit ctxt gas_limit) >>=? fun ctxt ->
|
||||||
Lwt.return (Contract.set_storage_limit ctxt storage_limit) >>=? fun ctxt ->
|
Lwt.return (Contract.set_storage_limit ctxt storage_limit) >>=? fun ctxt ->
|
||||||
apply_manager_operation_content ctxt mode
|
apply_manager_operation_content ctxt mode
|
||||||
@ -550,14 +556,26 @@ let rec mark_skipped
|
|||||||
internal_operation_results = [] },
|
internal_operation_results = [] },
|
||||||
mark_skipped rest)
|
mark_skipped rest)
|
||||||
|
|
||||||
|
let rec precheck_manager_contents_list
|
||||||
|
: type kind.
|
||||||
|
Alpha_context.t -> _ Operation.t -> kind Kind.manager contents_list ->
|
||||||
|
context tzresult Lwt.t =
|
||||||
|
fun ctxt raw_operation contents_list ->
|
||||||
|
match contents_list with
|
||||||
|
| Single (Manager_operation _ as op) ->
|
||||||
|
precheck_manager_contents ctxt raw_operation op
|
||||||
|
| Cons (Manager_operation _ as op, rest) ->
|
||||||
|
precheck_manager_contents ctxt raw_operation op >>=? fun ctxt ->
|
||||||
|
precheck_manager_contents_list ctxt raw_operation rest
|
||||||
|
|
||||||
let rec apply_manager_contents_list
|
let rec apply_manager_contents_list
|
||||||
: type kind.
|
: type kind.
|
||||||
Alpha_context.t -> _ -> _ Operation.t -> kind Kind.manager contents_list ->
|
Alpha_context.t -> _ -> kind Kind.manager contents_list ->
|
||||||
(context * kind Kind.manager contents_result_list) Lwt.t =
|
(context * kind Kind.manager contents_result_list) Lwt.t =
|
||||||
fun ctxt mode raw_operation contents_list ->
|
fun ctxt mode contents_list ->
|
||||||
match contents_list with
|
match contents_list with
|
||||||
| Single (Manager_operation { operation ; _ } as op) -> begin
|
| Single (Manager_operation { operation ; _ } as op) -> begin
|
||||||
apply_manager_contents ctxt mode raw_operation op >>= function
|
apply_manager_contents ctxt mode op >>= function
|
||||||
| Error errors ->
|
| Error errors ->
|
||||||
let result =
|
let result =
|
||||||
Manager_operation_result {
|
Manager_operation_result {
|
||||||
@ -575,7 +593,7 @@ let rec apply_manager_contents_list
|
|||||||
Lwt.return (ctxt, Single_result (result))
|
Lwt.return (ctxt, Single_result (result))
|
||||||
end
|
end
|
||||||
| Cons (Manager_operation { operation ; _ } as op, rest) ->
|
| Cons (Manager_operation { operation ; _ } as op, rest) ->
|
||||||
apply_manager_contents ctxt mode raw_operation op >>= function
|
apply_manager_contents ctxt mode op >>= function
|
||||||
| Error errors ->
|
| Error errors ->
|
||||||
let result =
|
let result =
|
||||||
Manager_operation_result {
|
Manager_operation_result {
|
||||||
@ -586,8 +604,7 @@ let rec apply_manager_contents_list
|
|||||||
Lwt.return (ctxt, Cons_result (result, mark_skipped rest))
|
Lwt.return (ctxt, Cons_result (result, mark_skipped rest))
|
||||||
| Ok (ctxt, (Manager_operation_result
|
| Ok (ctxt, (Manager_operation_result
|
||||||
{ operation_result = Applied _ ; _ } as result)) ->
|
{ operation_result = Applied _ ; _ } as result)) ->
|
||||||
apply_manager_contents_list
|
apply_manager_contents_list ctxt mode rest >>= fun (ctxt, results) ->
|
||||||
ctxt mode raw_operation rest >>= fun (ctxt, results) ->
|
|
||||||
Lwt.return (ctxt, Cons_result (result, results))
|
Lwt.return (ctxt, Cons_result (result, results))
|
||||||
| Ok (ctxt,
|
| Ok (ctxt,
|
||||||
(Manager_operation_result
|
(Manager_operation_result
|
||||||
@ -738,10 +755,12 @@ let apply_contents_list
|
|||||||
Amendment.record_ballot ctxt source proposal ballot >>=? fun ctxt ->
|
Amendment.record_ballot ctxt source proposal ballot >>=? fun ctxt ->
|
||||||
return (ctxt, Single_result Ballot_result)
|
return (ctxt, Single_result Ballot_result)
|
||||||
| Single (Manager_operation _) as op ->
|
| Single (Manager_operation _) as op ->
|
||||||
apply_manager_contents_list ctxt mode operation op >>= fun (ctxt, result) ->
|
precheck_manager_contents_list ctxt operation op >>=? fun ctxt ->
|
||||||
|
apply_manager_contents_list ctxt mode op >>= fun (ctxt, result) ->
|
||||||
return (ctxt, result)
|
return (ctxt, result)
|
||||||
| Cons (Manager_operation _, _) as op ->
|
| Cons (Manager_operation _, _) as op ->
|
||||||
apply_manager_contents_list ctxt mode operation op >>= fun (ctxt, result) ->
|
precheck_manager_contents_list ctxt operation op >>=? fun ctxt ->
|
||||||
|
apply_manager_contents_list ctxt mode op >>= fun (ctxt, result) ->
|
||||||
return (ctxt, result)
|
return (ctxt, result)
|
||||||
|
|
||||||
let apply_operation ctxt mode pred_block hash operation =
|
let apply_operation ctxt mode pred_block hash operation =
|
||||||
|
Loading…
Reference in New Issue
Block a user