2018-05-22 20:04:37 +04:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Copyright (c) 2014 - 2018. *)
|
|
|
|
(* Dynamic Ledger Solutions, Inc. <contact@tezos.com> *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. No warranty, explicit or implicit, provided. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
|
|
|
|
|
|
|
type error +=
|
|
|
|
| Encoding_error
|
|
|
|
| Decoding_error
|
|
|
|
| Unkwnon_alias_key of string
|
|
|
|
| Unkwnon_request_kind
|
|
|
|
|
2018-05-24 01:26:18 +04:00
|
|
|
type path =
|
|
|
|
| Unix of string
|
|
|
|
| Tcp of string * string
|
2018-05-22 20:04:37 +04:00
|
|
|
type key = string
|
|
|
|
|
|
|
|
module Connection : sig
|
|
|
|
type t = Lwt_unix.file_descr
|
2018-05-24 01:26:18 +04:00
|
|
|
val bind : path -> (t * string) tzresult Lwt.t
|
|
|
|
val connect : path -> t tzresult Lwt.t
|
2018-05-22 20:04:37 +04:00
|
|
|
val read : len:int -> t -> MBytes.t -> unit tzresult Lwt.t
|
|
|
|
val write : t -> MBytes.t -> unit tzresult Lwt.t
|
|
|
|
end
|
|
|
|
|
|
|
|
module Sign : sig
|
|
|
|
module Request : sig
|
|
|
|
type t = {
|
|
|
|
key : string ;
|
|
|
|
data: MBytes.t ;
|
|
|
|
}
|
|
|
|
val encoding : t Data_encoding.t
|
|
|
|
end
|
|
|
|
module Response : sig
|
|
|
|
type t = {
|
|
|
|
signature : Signature.t ;
|
|
|
|
}
|
|
|
|
val encoding : t tzresult Data_encoding.t
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module Public_key : sig
|
|
|
|
module Request : sig
|
|
|
|
type t = {
|
|
|
|
key : string
|
|
|
|
}
|
|
|
|
val encoding : t Data_encoding.t
|
|
|
|
end
|
|
|
|
module Response : sig
|
|
|
|
type t = {
|
|
|
|
public_key : Signature.Public_key.t
|
|
|
|
}
|
|
|
|
val encoding : t tzresult Data_encoding.t
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
module Request : sig
|
|
|
|
type t =
|
|
|
|
| Sign of Sign.Request.t
|
|
|
|
| Public_key of Public_key.Request.t
|
|
|
|
val encoding : t Data_encoding.t
|
|
|
|
end
|
|
|
|
|
|
|
|
val send : Connection.t -> 'a Data_encoding.t -> 'a -> unit tzresult Lwt.t
|
|
|
|
val recv : Connection.t -> 'a Data_encoding.t -> 'a tzresult Lwt.t
|