Alpha/Tests: add operation tickets to the incremental context

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

View File

@ -30,14 +30,15 @@ type t = {
predecessor: Block.t ; predecessor: Block.t ;
state: M.validation_state ; state: M.validation_state ;
rev_operations: Operation.packed list ; rev_operations: Operation.packed list ;
rev_tickets: operation_receipt list ;
header: Block_header.t ; header: Block_header.t ;
delegate: Account.t ; delegate: Account.t ;
} }
type incremental = t type incremental = t
let predecessor { predecessor ; _ } = predecessor let predecessor { predecessor ; _ } = predecessor
let header st = st.header let header { header ; _ } = header
let rev_tickets { rev_tickets ; _ } = rev_tickets
let level st = st.header.shell.level let level st = st.header.shell.level
let rpc_context st = let rpc_context st =
@ -69,7 +70,6 @@ let begin_construction ?(priority=0) ?timestamp (predecessor : Block.t) =
validation_passes = predecessor.header.shell.validation_passes ; validation_passes = predecessor.header.shell.validation_passes ;
fitness = predecessor.header.shell.fitness ; fitness = predecessor.header.shell.fitness ;
timestamp ; timestamp ;
(* TODO : CHECK THAT OUT -- incoherent level *)
level = predecessor.header.shell.level ; level = predecessor.header.shell.level ;
context = Context_hash.zero ; context = Context_hash.zero ;
operations_hash = Operation_list_list_hash.zero ; operations_hash = Operation_list_list_hash.zero ;
@ -93,6 +93,7 @@ let begin_construction ?(priority=0) ?timestamp (predecessor : Block.t) =
predecessor ; predecessor ;
state ; state ;
rev_operations = [] ; rev_operations = [] ;
rev_tickets = [] ;
header ; header ;
delegate ; delegate ;
} }
@ -137,7 +138,7 @@ let detect_script_failure :
let add_operation ?expect_failure st op = let add_operation ?expect_failure st op =
let open Apply_results 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 as metadata) ->
Lwt.return @@ detect_script_failure result >>= fun result -> Lwt.return @@ detect_script_failure result >>= fun result ->
begin match expect_failure with begin match expect_failure with
| None -> | None ->
@ -149,9 +150,11 @@ let add_operation ?expect_failure st op =
| Error e -> | Error e ->
f e f e
end >>=? fun () -> end >>=? fun () ->
return { st with state ; rev_operations = op :: st.rev_operations } return { st with state ; rev_operations = op :: st.rev_operations ;
| state, No_operation_metadata -> rev_tickets = metadata :: st.rev_tickets }
return { st with state ; rev_operations = op :: st.rev_operations } | state, (No_operation_metadata as metadata) ->
return { st with state ; rev_operations = op :: st.rev_operations ;
rev_tickets = metadata :: st.rev_tickets }
let finalize_block st = let finalize_block st =
M.finalize_block st.state >>=? fun (result, _) -> M.finalize_block st.state >>=? fun (result, _) ->

View File

@ -31,7 +31,7 @@ type incremental = t
val predecessor: incremental -> Block.t val predecessor: incremental -> Block.t
val header: incremental -> Block_header.t val header: incremental -> Block_header.t
val rev_tickets: incremental -> operation_receipt list
val level: incremental -> int32 val level: incremental -> int32
val begin_construction: val begin_construction: