Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file data.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162(*****************************************************************************)(* *)(* 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. *)(* *)(*****************************************************************************)moduleCommand=structtypet=(* Activate a protocol *)|Activateof{protocol:Protocol_hash.t;fitness:Fitness.t;protocol_parameters:MBytes.t;}(* Activate a protocol as a testchain *)|Activate_testchainof{protocol:Protocol_hash.t;fitness:Fitness.t;protocol_parameters:MBytes.t;delay:Int64.t;}letmk_casenameargs=letopenData_encodinginconv(funo->((),o))(fun((),o)->o)(merge_objs(obj1(req"command"(constantname)))args)letencoding=letopenData_encodinginunion~tag_size:`Uint8[case(Tag0)~title:"Activate"(mk_case"activate"(obj3(req"hash"Protocol_hash.encoding)(req"fitness"Fitness.encoding)(req"protocol_parameters"Variable.bytes)))(function|Activate{protocol;fitness;protocol_parameters}->Some(protocol,fitness,protocol_parameters)|_->None)(fun(protocol,fitness,protocol_parameters)->Activate{protocol;fitness;protocol_parameters});case(Tag1)~title:"Activate_testchain"(mk_case"activate_testchain"(obj4(req"hash"Protocol_hash.encoding)(req"fitness"Fitness.encoding)(req"protocol_parameters"Variable.bytes)(req"validity_time"int64)))(function|Activate_testchain{protocol;fitness;protocol_parameters;delay}->Some(protocol,fitness,protocol_parameters,delay)|_->None)(fun(protocol,fitness,protocol_parameters,delay)->Activate_testchain{protocol;fitness;protocol_parameters;delay});]letsigned_encoding=letopenData_encodinginobj2(req"content"encoding)(req"signature"Signature.encoding)letforgeshellcommand=Data_encoding.Binary.to_bytes_exn(Data_encoding.tup2Block_header.shell_header_encodingencoding)(shell,command)endmodulePubkey=structletpubkey_key=["genesis_key"]letdefault=Signature.Public_key.of_b58check_exn"edpkvVCdQtDJHPnkmfRZuuHWKzFetH9N9nGP8F7zkwM2BJpjbvAU1N"letget_pubkeyctxt=Context.getctxtpubkey_key>>=function|None->Lwt.returndefault|Someb->matchData_encoding.Binary.of_bytesSignature.Public_key.encodingbwith|None->Lwt.returndefault|Somepk->Lwt.returnpkletset_pubkeyctxtv=Context.setctxtpubkey_key@@Data_encoding.Binary.to_bytes_exnSignature.Public_key.encodingvletsandbox_encoding=letopenData_encodinginmerge_objs(obj1(req"genesis_pubkey"Signature.Public_key.encoding))Data_encoding.unitletmay_change_defaultctxtjson=matchData_encoding.Json.destructsandbox_encodingjsonwith|exception_->Lwt.returnctxt|(pubkey,())->set_pubkeyctxtpubkey>>=functxt->Lwt.returnctxtendmoduleInit=structtypeerror+=Incompatible_protocol_versionletversion_key=["version"](* This key should always be populated for every version of the
protocol. It's absence meaning that the context is empty. *)letversion_value="genesis"letcheck_initedctxt=Context.getctxtversion_key>>=function|None->failwith"Internal error: uninitialized context."|Someversion->ifCompare.String.(version_value<>MBytes.to_stringversion)thenfailwith"Internal error: incompatible protocol version";return_unitlettag_first_blockctxt=Context.getctxtversion_key>>=function|None->Context.setctxtversion_key(MBytes.of_stringversion_value)>>=functxt->returnctxt|Some_version->failwith"Internal error: previously initialized context.";end