2018-06-29 16:08:08 +04:00
|
|
|
(*****************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* 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. *)
|
|
|
|
(* *)
|
|
|
|
(*****************************************************************************)
|
2018-02-08 13:51:01 +04:00
|
|
|
|
2018-02-08 13:51:01 +04:00
|
|
|
open Error_monad
|
|
|
|
|
2018-02-08 13:51:01 +04:00
|
|
|
val read_bytes:
|
|
|
|
?pos:int -> ?len:int -> Lwt_unix.file_descr -> bytes -> unit Lwt.t
|
|
|
|
|
|
|
|
val read_mbytes:
|
|
|
|
?pos:int -> ?len:int -> Lwt_unix.file_descr -> MBytes.t -> unit Lwt.t
|
|
|
|
|
|
|
|
val write_bytes:
|
|
|
|
?pos:int -> ?len:int -> Lwt_unix.file_descr -> bytes -> unit Lwt.t
|
|
|
|
val write_mbytes:
|
|
|
|
?pos:int -> ?len:int -> Lwt_unix.file_descr -> MBytes.t -> unit Lwt.t
|
|
|
|
|
|
|
|
val remove_dir: string -> unit Lwt.t
|
|
|
|
val create_dir: ?perm:int -> string -> unit Lwt.t
|
2018-02-08 13:51:02 +04:00
|
|
|
val read_file: string -> string Lwt.t
|
2018-02-08 13:51:01 +04:00
|
|
|
val create_file: ?perm:int -> string -> string -> unit Lwt.t
|
|
|
|
|
2018-02-12 01:36:49 +04:00
|
|
|
val with_tempdir: string -> (string -> 'a Lwt.t) -> 'a Lwt.t
|
|
|
|
|
2018-02-08 13:51:01 +04:00
|
|
|
val safe_close: Lwt_unix.file_descr -> unit Lwt.t
|
|
|
|
|
|
|
|
val getaddrinfo:
|
|
|
|
passive:bool ->
|
|
|
|
node:string -> service:string ->
|
|
|
|
(Ipaddr.V6.t * int) list Lwt.t
|
2018-02-08 13:51:01 +04:00
|
|
|
|
2018-02-06 22:16:01 +04:00
|
|
|
(** [getpass ()] reads a password from stdio while setting-up the
|
|
|
|
terminal to not display the password being typed. *)
|
|
|
|
val getpass : unit -> string
|
|
|
|
|
2018-02-08 13:51:01 +04:00
|
|
|
module Json : sig
|
|
|
|
|
|
|
|
(** Loads a JSON file in memory *)
|
|
|
|
val read_file : string -> Data_encoding.json tzresult Lwt.t
|
|
|
|
|
|
|
|
(** (Over)write a JSON file from in memory data *)
|
|
|
|
val write_file : string -> Data_encoding.json -> unit tzresult Lwt.t
|
|
|
|
|
|
|
|
end
|
2018-02-08 13:51:01 +04:00
|
|
|
|
|
|
|
module Protocol : sig
|
|
|
|
|
2018-07-21 02:00:05 +04:00
|
|
|
val read_dir: string -> (Protocol_hash.t option * Protocol.t) tzresult Lwt.t
|
2018-02-08 13:51:01 +04:00
|
|
|
|
|
|
|
val write_dir: string -> ?hash:Protocol_hash.t -> Protocol.t -> unit tzresult Lwt.t
|
|
|
|
|
|
|
|
end
|
2018-05-26 13:16:51 +04:00
|
|
|
|
|
|
|
module Socket : sig
|
|
|
|
|
|
|
|
type addr =
|
|
|
|
| Unix of string
|
2018-07-15 23:49:02 +04:00
|
|
|
| Tcp of string * string * Unix.getaddrinfo_option list
|
2018-05-26 13:16:51 +04:00
|
|
|
|
|
|
|
val connect: addr -> Lwt_unix.file_descr tzresult Lwt.t
|
2018-07-15 23:49:02 +04:00
|
|
|
val bind:
|
|
|
|
?backlog:int -> addr -> Lwt_unix.file_descr list tzresult Lwt.t
|
2018-05-26 13:16:51 +04:00
|
|
|
|
|
|
|
type error +=
|
|
|
|
| Encoding_error
|
|
|
|
| Decoding_error
|
|
|
|
|
|
|
|
val send:
|
|
|
|
Lwt_unix.file_descr -> 'a Data_encoding.t -> 'a -> unit tzresult Lwt.t
|
|
|
|
val recv:
|
|
|
|
Lwt_unix.file_descr -> 'a Data_encoding.t -> 'a tzresult Lwt.t
|
|
|
|
|
|
|
|
end
|
2018-06-19 12:43:47 +04:00
|
|
|
|
|
|
|
val retry:
|
|
|
|
?log:('error -> unit Lwt.t) ->
|
|
|
|
?n:int ->
|
|
|
|
?sleep:float ->
|
|
|
|
(unit -> ('a, 'error) result Lwt.t) -> ('a, 'error) result Lwt.t
|
|
|
|
|