123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384(*****************************************************************************)(* *)(* Open Source License *)(* Copyright (c) 2021 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. *)(* *)(*****************************************************************************)letparse_args()=letsocket_dir=refNoneinletreadonly_flag=reffalseinletargs=Arg.[("--socket-dir",String(funs->ifnot(Sys.file_existss&&Sys.is_directorys)thenraise(Arg.Bad(Format.sprintf"File '%s' is not a valid directory"s))elsesocket_dir:=Somes),{|<dir>
When provided, the validator will communicate through a socket located
at '<dir>/tezos-validation-socket-<pid>' where <pid> is the
tezos-validator's process identifier. By default, the validator will
communicate through its standard input and output.|});("--readonly",Unit(fun()->readonly_flag:=true),{|<flag>
When provided, the validator will start in readonly mode. It will not be
able to update the context.|});("--version",Unit(fun()->Format.printf"%s\n"Tezos_version_value.Bin_version.version_string;Stdlib.exit0)," Display version information");]inletusage_msg=Format.sprintf"tezos-validator [--version] [--socket-dir <dir>] [--readonly]"inArg.parseargs(funs->raise(Arg.Bad(Format.sprintf"Unexpected argument: %s"s)))usage_msg;(!socket_dir,!readonly_flag)letrun()=letsocket_dir,readonly=parse_args()inletmain_promise=External_validator.main?socket_dir~readonly()inStdlib.exit(letopenLwt_syntaxinLwt.Exception_filter.(sethandle_all_except_runtime);Lwt_main.run(let*r=Lwt_exit.wrap_and_exitmain_promiseinmatchrwith|Ok()->Lwt_exit.exit_and_wait0|Errorerr->Format.eprintf"%a\n%!"pp_print_traceerr;Lwt_exit.exit_and_wait1))