RPC: simplify Worker.EVENT

This commit is contained in:
Grégoire Henry 2018-01-25 11:32:51 +01:00
parent e664179927
commit 0c2acd2d48
11 changed files with 18 additions and 20 deletions

View File

@ -18,7 +18,7 @@ module type EVENT = sig
type t
val level : t -> Logging.level
val encoding : error list Data_encoding.t -> t Data_encoding.t
val encoding : t Data_encoding.t
val pp : Format.formatter -> t -> unit
end

View File

@ -44,7 +44,7 @@ module type EVENT = sig
val level : t -> Logging.level
(** Serializer for the introspection RPCs *)
val encoding : error list Data_encoding.t -> t Data_encoding.t
val encoding : t Data_encoding.t
(** Pretty printer, also used for logging *)
val pp : Format.formatter -> t -> unit

View File

@ -46,7 +46,7 @@ module Event = struct
| Validation_success _
| Validation_failure _ -> Logging.Notice
let encoding error_encoding =
let encoding =
let open Data_encoding in
union
[ case (Tag 0)
@ -63,7 +63,7 @@ module Event = struct
(obj3
(req "failed_validation" Request.encoding)
(req "status" Worker_types.request_status_encoding)
(dft "errors" error_encoding []))
(dft "errors" RPC_error.encoding []))
(function Validation_failure (r, s, err) -> Some (r, s, err) | _ -> None)
(fun (r, s, err) -> Validation_failure (r, s, err)) ]

View File

@ -23,7 +23,7 @@ module Event : sig
| Validation_failure of Request.view * Worker_types.request_status * error list
| Debug of string
val level : t -> Logging.level
val encoding : error list Data_encoding.encoding -> t Data_encoding.encoding
val encoding : t Data_encoding.encoding
val pp : Format.formatter -> t -> unit
end

View File

@ -35,7 +35,7 @@ module Event = struct
end
| Could_not_switch_testnet _ -> Logging.Error
let encoding error_encoding =
let encoding =
let open Data_encoding in
union
[ case (Tag 0)
@ -54,7 +54,7 @@ module Event = struct
(fun (request, request_status, update, fitness) ->
Processed_block { request ; request_status ; update ; fitness }) ;
case (Tag 1)
error_encoding
RPC_error.encoding
(function
| Could_not_switch_testnet err -> Some err
| _ -> None)

View File

@ -26,7 +26,7 @@ module Event : sig
fitness : Fitness.t }
| Could_not_switch_testnet of error list
val level : t -> Logging.level
val encoding : error list Data_encoding.encoding -> t Data_encoding.encoding
val encoding : t Data_encoding.encoding
val pp : Format.formatter -> t -> unit
end

View File

@ -47,7 +47,7 @@ module Event = struct
| Debug _ -> Logging.Info
| Request _ -> Logging.Notice
let encoding error_encoding =
let encoding =
let open Data_encoding in
union
[ case (Tag 0)
@ -62,7 +62,7 @@ module Event = struct
(fun (req, t) -> Request (req, t, None)) ;
case (Tag 2)
(obj3
(req "error" error_encoding)
(req "error" RPC_error.encoding)
(req "failed_request" Request.encoding)
(req "status" Worker_types.request_status_encoding))
(function Request (req, t, Some errs) -> Some (errs, req, t) | _ -> None)

View File

@ -20,7 +20,7 @@ module Event : sig
| Request of (Request.view * Worker_types.request_status * error list option)
| Debug of string
val level : t -> Logging.level
val encoding : error list Data_encoding.encoding -> t Data_encoding.encoding
val encoding : t Data_encoding.encoding
val pp : Format.formatter -> t -> unit
end

View File

@ -95,7 +95,7 @@ module Event = struct
| Request (View (Arrived _), _, _) -> Logging.Debug
| Request (View Advertise, _, _) -> Logging.Debug
let encoding error_encoding =
let encoding =
let open Data_encoding in
union
[ case (Tag 0)
@ -110,7 +110,7 @@ module Event = struct
(fun (req, t) -> Request (req, t, None)) ;
case (Tag 2)
(obj3
(req "error" error_encoding)
(req "error" RPC_error.encoding)
(req "failed_request" Request.encoding)
(req "status" Worker_types.request_status_encoding))
(function Request (req, t, Some errs) -> Some (errs, req, t) | _ -> None)

View File

@ -25,7 +25,7 @@ module Event : sig
| Request of (Request.view * Worker_types.request_status * error list option)
| Debug of string
val level : t -> Logging.level
val encoding : error list Data_encoding.t -> t Data_encoding.t
val encoding : t Data_encoding.t
val pp : Format.formatter -> t -> unit
end

View File

@ -44,7 +44,7 @@ module Prevalidators = struct
~output:
(Worker_types.full_status_encoding
Prevalidator_worker_state.Request.encoding
(Prevalidator_worker_state.Event.encoding RPC_error.encoding)
Prevalidator_worker_state.Event.encoding
RPC_error.encoding)
RPC_path.(root / "workers" / "prevalidators" /: net_id_arg )
@ -62,7 +62,7 @@ module Block_validator = struct
~output:
(Worker_types.full_status_encoding
Block_validator_worker_state.Request.encoding
(Block_validator_worker_state.Event.encoding RPC_error.encoding)
Block_validator_worker_state.Event.encoding
RPC_error.encoding)
RPC_path.(root / "workers" / "block_validator")
@ -113,7 +113,7 @@ module Peer_validators = struct
~output:
(Worker_types.full_status_encoding
Peer_validator_worker_state.Request.encoding
(Peer_validator_worker_state.Event.encoding RPC_error.encoding)
Peer_validator_worker_state.Event.encoding
RPC_error.encoding)
RPC_path.(root / "workers" / "peer_validators" /: net_id_arg /: peer_id_arg)
@ -154,10 +154,8 @@ module Net_validators = struct
~output:
(Worker_types.full_status_encoding
Net_validator_worker_state.Request.encoding
(Net_validator_worker_state.Event.encoding RPC_error.encoding)
Net_validator_worker_state.Event.encoding
RPC_error.encoding)
RPC_path.(root / "workers" / "net_validators" /: net_id_arg )
end
end