package octez-protocol-019-PtParisB-libs
Octez protocol 019-PtParisB libraries
Install
Dune Dependency
Authors
Maintainers
Sources
tezos-octez-v20.1.tag.bz2
sha256=ddfb5076eeb0b32ac21c1eed44e8fc86a6743ef18ab23fff02d36e365bb73d61
sha512=d22a827df5146e0aa274df48bc2150b098177ff7e5eab52c6109e867eb0a1f0ec63e6bfbb0e3645a6c2112de3877c91a17df32ccbff301891ce4ba630c997a65
doc/src/octez-protocol-019-PtParisB-libs.layer2-utils/layer1_services.ml.html
Source file layer1_services.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
(*****************************************************************************) (* *) (* Open Source License *) (* Copyright (c) 2022 Nomadic Labs, <contact@nomadic-labs.com> *) (* *) (* Permission is hereby granted, free of charge, to any person obtaining a *) (* copy of this software and associated documentation files (the "Software"),*) (* to deal in the Software without restriction, including without limitation *) (* the rights to use, copy, modify, merge, publish, distribute, sublicense, *) (* and/or sell copies of the Software, and to permit persons to whom the *) (* Software is furnished to do so, subject to the following conditions: *) (* *) (* The above copyright notice and this permission notice shall be included *) (* in all copies or substantial portions of the Software. *) (* *) (* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR*) (* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, *) (* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL *) (* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER*) (* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING *) (* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER *) (* DEALINGS IN THE SOFTWARE. *) (* *) (*****************************************************************************) open Protocol open Alpha_context open Apply_results open Protocol_client_context open Alpha_block_services type error += Cannot_read_block_metadata of Block_hash.t let () = register_error_kind ~id:"cannot_read_receipt_of_block" ~title:"Cannot read receipt of block from L1" ~description:"The receipt of a block could not be read." ~pp:(fun ppf hash -> Format.fprintf ppf "Could not read block receipt for block with hash %a." Block_hash.pp hash) `Temporary Data_encoding.(obj1 (req "hash" Block_hash.encoding)) (function Cannot_read_block_metadata hash -> Some hash | _ -> None) (fun hash -> Cannot_read_block_metadata hash) type 'accu successful_operation_processor = { apply : 'kind. 'accu -> source:public_key_hash -> 'kind manager_operation -> 'kind Apply_results.successful_manager_operation_result -> 'accu; apply_internal : 'kind. 'accu -> source:public_key_hash -> 'kind Apply_internal_results.internal_operation -> 'kind Apply_internal_results.successful_internal_operation_result -> 'accu; } type 'accu operation_processor = { apply : 'kind. 'accu -> source:public_key_hash -> 'kind manager_operation -> 'kind Apply_results.manager_operation_result -> 'accu; apply_internal : 'kind. 'accu -> source:public_key_hash -> 'kind Apply_internal_results.internal_operation -> 'kind Apply_internal_results.internal_operation_result -> 'accu; } let process_manager_operations operations accu f = let rec on_operation_and_result : type kind. _ -> kind Apply_results.contents_and_result_list -> _ = fun accu -> function | Single_and_result ( Manager_operation {operation; source; _}, Manager_operation_result {operation_result; internal_operation_results; _} ) -> let accu = f.apply accu ~source operation operation_result in on_internal_operations accu source internal_operation_results | Single_and_result (_, _) -> accu | Cons_and_result ( Manager_operation {operation; source; _}, Manager_operation_result {operation_result; internal_operation_results; _}, rest ) -> let accu = f.apply accu ~source operation operation_result in let accu = on_internal_operations accu source internal_operation_results in on_operation_and_result accu rest and on_internal_operations accu source internal_operation_results = let open Apply_internal_results in List.fold_left (fun accu (Internal_operation_result (operation, result)) -> f.apply_internal accu ~source operation result) accu internal_operation_results in let process_contents accu ({protocol_data = Operation_data {contents; _}; receipt; _} : operation) = match receipt with | Empty | Too_large | Receipt No_operation_metadata -> (* This should case should not happen between [operations] is supposed to be retrieved with `force_metadata:true` and assuming that the tezos node is running in archive mode. *) assert false | Receipt (Operation_metadata {contents = results; _}) -> ( match Apply_results.kind_equal_list contents results with | Some Eq -> on_operation_and_result accu @@ Apply_results.pack_contents_list contents results | None -> (* Should not happen *) assert false) in let process_operations = List.fold_left process_contents in List.fold_left process_operations operations accu let process_applied_manager_operations operations accu (f : _ successful_operation_processor) = let apply (type kind) accu ~source (operation : kind manager_operation) (result : kind Apply_results.manager_operation_result) = match result with | Applied result -> f.apply accu ~source operation result | _ -> accu in let apply_internal (type kind) accu ~source (operation : kind Apply_internal_results.internal_operation) (result : kind Apply_internal_results.internal_operation_result) = match result with | Applied result -> f.apply_internal accu ~source operation result | _ -> accu in process_manager_operations operations accu {apply; apply_internal}
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>