123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2018 Dynamic Ledger Solutions, Inc. <contact@tezos.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. *)(* *)(*****************************************************************************)typeError_monad.error+=Injection_operations_errortypeError_monad.error+=Injection_operation_succeed_caseofOperation_hash.ttypeError_monad.error+=Injection_operation_error_caseofOperation_hash.tlet()=letopenData_encodinginregister_error_kind`Permanent~id:"injection_operations_error"~title:"Injection operations error"~description:"While injecting several operations at once, one or several injections \
failed."~pp:(funppf()->Format.fprintfppf"While injecting several operations, one or several injections failed. \
Errors are the one below in the trace.")unit(functionInjection_operations_error->Some()|_->None)(function()->Injection_operations_error);register_error_kind`Permanent~id:"injection_operation_succeed_case"~title:"Injection operation succeed"~description:"The injection of this operation succeed among a list of injections \
containing at least one error."~pp:(funppfoph->Format.fprintfppf"Injection of %a succeeded."Operation_hash.ppoph)(obj1(req"oph"Operation_hash.encoding))(functionInjection_operation_succeed_caseoph->Someoph|_->None)(functionoph->Injection_operation_succeed_caseoph);register_error_kind`Permanent~id:"injection_operation_error_case"~title:"Injection operation error"~description:"The injection of this operation failed. The error trace are the \
following errors in this list."~pp:(funppfoph->Format.fprintfppf"Injection of %a failed. Error is next."Operation_hash.ppoph)(obj1(req"oph"Operation_hash.encoding))(functionInjection_operation_error_caseoph->Someoph|_->None)(functionoph->Injection_operation_error_caseoph)moduleS=structopenData_encodingletpath=Tezos_rpc.Path.(root/"injection")letblock_query=letopenTezos_rpc.Queryinquery(funasyncforcechain->objectmethodasync=asyncmethodforce=forcemethodchain=chainend)|+flag"async"(funt->t#async)|+flag"force"(funt->t#force)|+opt_field"chain"Chain_services.chain_arg(funt->t#chain)|>sealletblock_param=obj2(req"data"bytes)(req"operations"(list(dynamic_size(list(dynamic_sizeOperation.encoding)))))letblock=Tezos_rpc.Service.post_service~description:"Inject a block in the node and broadcast it. The `operations` \
embedded in `blockHeader` might be pre-validated using a contextual \
RPCs from the latest block (e.g. '/blocks/head/context/preapply'). \
Returns the ID of the block. By default, the RPC will wait for the \
block to be validated before answering. If ?async is true, the \
function returns immediately. Otherwise, the block will be validated \
before the result is returned. If ?force is true, it will be injected \
even on non strictly increasing fitness. An optional ?chain parameter \
can be used to specify whether to inject on the test chain or the \
main chain."~query:block_query~input:block_param~output:Block_hash.encodingTezos_rpc.Path.(path/"block")letoperation_query=letopenTezos_rpc.Queryinquery(funasyncchain->objectmethodasync=asyncmethodchain=chainend)|+flag"async"(funt->t#async)|+opt_field"chain"Chain_services.chain_arg(funt->t#chain)|>sealletoperations_query=letopenTezos_rpc.Queryinquery(funasyncforcechain->objectmethodasync=asyncmethodforce=forcemethodchain=chainend)|+flag"async"(funt->t#async)|+flag"force"(funt->t#force)|+opt_field"chain"Chain_services.chain_arg(funt->t#chain)|>seal(* If [private_] is set, the [private/injection/operation] path is used,
* otherwise, it is [/injection/operation].
This RPC does less checks than [injection/operation] and should be used for
test or internal use only. The [private/] prefix is used to forbid the use
of such RPC on a public node *)letoperation~private_=Tezos_rpc.Service.post_service~description:"Inject an operation in node and broadcast it. Returns the ID of the \
operation. The `signedOperationContents` should be constructed using \
contextual RPCs from the latest block and signed by the client. The \
injection of the operation will apply it on the current mempool \
context. This context may change at each operation injection or \
operation reception from peers. By default, the RPC will wait for the \
operation to be (pre-)validated before returning. However, if ?async \
is true, the function returns immediately. The optional ?chain \
parameter can be used to specify whether to inject on the test chain \
or the main chain."~query:operation_query~input:bytes~output:Operation_hash.encoding(ifprivate_thenTezos_rpc.Path.(root/"private"/"injection"/"operation")elseTezos_rpc.Path.(path/"operation"))letprivate_operations=Tezos_rpc.Service.post_service~description:"Inject a list of operations in a node. If [force] is [true] then the \
operations are immediatly injected. The injection will succeed, but \
it does not mean the operations are (all) valid. In any case, the \
injection will be quick, hence [async] will be taken into account but \
should have almost no impact. If [async] is [true], all the promises \
returned by injecting an operation will be dropped. Each injection is \
done independently, and does not depend on the other injected \
operations result. Otherwise ([async]=[force]=[false]), for each \
operation, we record a list of promises. If all the injections \
succeed, the result is the list of operation hashes injected, \
otherwise an error (\"injection_operations_error\") is returned. This \
error is followed by markers for each operation: \
\"injection_operation_succeed\" for success and \
\"injection_operation_error\" for failure (followed by the errors \
specific to this injection)."~query:operations_query~input:(list(dynamic_sizebytes))~output:(listOperation_hash.encoding)Tezos_rpc.Path.(root/"private"/"injection"/"operations")letprivate_operation=operation~private_:trueletoperation=operation~private_:falseletprotocol_query=letopenTezos_rpc.Queryinquery(funasync->objectmethodasync=asyncend)|+flag"async"(funt->t#async)|>sealletprotocol=Tezos_rpc.Service.post_service~description:"Inject a protocol in node. Returns the ID of the protocol. If ?async \
is true, the function returns immediately. Otherwise, the protocol \
will be validated before the result is returned."~query:protocol_query~input:Protocol.encoding~output:Protocol_hash.encodingTezos_rpc.Path.(path/"protocol")endopenTezos_rpc.Contextletblockctxt?(async=false)?(force=false)?chainrawoperations=make_callS.blockctxt()(objectmethodasync=asyncmethodforce=forcemethodchain=chainend)(raw,operations)letoperation_rpcctxt~private_rpc?(async=false)?chainoperation=make_call(ifprivate_rpcthenS.private_operationelseS.operation)ctxt()(objectmethodasync=asyncmethodchain=chainend)operationletprivate_operationctxt?async?chainoperation=operation_rpcctxt~private_rpc:true?async?chainoperationletprivate_operationsctxt?(async=false)?(force=false)?chainoperations=make_callS.private_operationsctxt()(objectmethodasync=asyncmethodchain=chainmethodforce=forceend)operationsletoperationctxt?async?chainoperation=operation_rpcctxt~private_rpc:false?async?chainoperationletprotocolctxt?(async=false)protocol=make_callS.protocolctxt()(objectmethodasync=asyncend)protocol