Indent: reindent with ocp-indent and fix the script
This commit is contained in:
parent
bd8eaddc8c
commit
df746e606d
@ -203,11 +203,11 @@ let init_rpc (rpc_config: Node_config_file.rpc) node =
|
|||||||
(if rpc_config.tls = None then "" else " (TLS enabled)") >>= fun () ->
|
(if rpc_config.tls = None then "" else " (TLS enabled)") >>= fun () ->
|
||||||
Lwt.catch
|
Lwt.catch
|
||||||
(fun () ->
|
(fun () ->
|
||||||
RPC_server.launch ~host mode dir
|
RPC_server.launch ~host mode dir
|
||||||
~media_types:Media_type.all_media_types
|
~media_types:Media_type.all_media_types
|
||||||
~cors:{ allowed_origins = rpc_config.cors_origins ;
|
~cors:{ allowed_origins = rpc_config.cors_origins ;
|
||||||
allowed_headers = rpc_config.cors_headers } >>= fun server ->
|
allowed_headers = rpc_config.cors_headers } >>= fun server ->
|
||||||
return (Some server))
|
return (Some server))
|
||||||
(function
|
(function
|
||||||
|Unix.Unix_error(Unix.EADDRINUSE, "bind","") ->
|
|Unix.Unix_error(Unix.EADDRINUSE, "bind","") ->
|
||||||
fail (RPC_Port_already_in_use addr)
|
fail (RPC_Port_already_in_use addr)
|
||||||
|
@ -459,7 +459,7 @@ module Bson : sig
|
|||||||
|
|
||||||
type t = Json_repr_bson.bson
|
type t = Json_repr_bson.bson
|
||||||
|
|
||||||
(** Construct a BSON object from an encoding. *)
|
(** Construct a BSON object from an encoding. *)
|
||||||
val construct : 't encoding -> 't -> bson
|
val construct : 't encoding -> 't -> bson
|
||||||
|
|
||||||
(** Destruct a BSON object into a value.
|
(** Destruct a BSON object into a value.
|
||||||
|
@ -386,11 +386,11 @@ module Point_state = struct
|
|||||||
(function Requested -> Some () | _ -> None)
|
(function Requested -> Some () | _ -> None)
|
||||||
(fun () -> Requested) ;
|
(fun () -> Requested) ;
|
||||||
case (Tag 1) (branch_encoding "accepted"
|
case (Tag 1) (branch_encoding "accepted"
|
||||||
(obj1 (req "peer_id" Peer_id.encoding)))
|
(obj1 (req "peer_id" Peer_id.encoding)))
|
||||||
(function Accepted peer_id -> Some peer_id | _ -> None)
|
(function Accepted peer_id -> Some peer_id | _ -> None)
|
||||||
(fun peer_id -> Accepted peer_id) ;
|
(fun peer_id -> Accepted peer_id) ;
|
||||||
case (Tag 2) (branch_encoding "running"
|
case (Tag 2) (branch_encoding "running"
|
||||||
(obj1 (req "peer_id" Peer_id.encoding)))
|
(obj1 (req "peer_id" Peer_id.encoding)))
|
||||||
(function Running peer_id -> Some peer_id | _ -> None)
|
(function Running peer_id -> Some peer_id | _ -> None)
|
||||||
(fun peer_id -> Running peer_id) ;
|
(fun peer_id -> Running peer_id) ;
|
||||||
case (Tag 3) (branch_encoding "disconnected" empty)
|
case (Tag 3) (branch_encoding "disconnected" empty)
|
||||||
@ -607,61 +607,61 @@ module Connection_pool_log_event = struct
|
|||||||
(function Too_many_connections -> Some () | _ -> None)
|
(function Too_many_connections -> Some () | _ -> None)
|
||||||
(fun () -> Too_many_connections) ;
|
(fun () -> Too_many_connections) ;
|
||||||
case (Tag 2) (branch_encoding "new_point"
|
case (Tag 2) (branch_encoding "new_point"
|
||||||
(obj1 (req "point" Point.encoding)))
|
(obj1 (req "point" Point.encoding)))
|
||||||
(function New_point p -> Some p | _ -> None)
|
(function New_point p -> Some p | _ -> None)
|
||||||
(fun p -> New_point p) ;
|
(fun p -> New_point p) ;
|
||||||
case (Tag 3) (branch_encoding "new_peer"
|
case (Tag 3) (branch_encoding "new_peer"
|
||||||
(obj1 (req "peer_id" Peer_id.encoding)))
|
(obj1 (req "peer_id" Peer_id.encoding)))
|
||||||
(function New_peer p -> Some p | _ -> None)
|
(function New_peer p -> Some p | _ -> None)
|
||||||
(fun p -> New_peer p) ;
|
(fun p -> New_peer p) ;
|
||||||
case (Tag 4) (branch_encoding "incoming_connection"
|
case (Tag 4) (branch_encoding "incoming_connection"
|
||||||
(obj1 (req "point" Point.encoding)))
|
(obj1 (req "point" Point.encoding)))
|
||||||
(function Incoming_connection p -> Some p | _ -> None)
|
(function Incoming_connection p -> Some p | _ -> None)
|
||||||
(fun p -> Incoming_connection p) ;
|
(fun p -> Incoming_connection p) ;
|
||||||
case (Tag 5) (branch_encoding "outgoing_connection"
|
case (Tag 5) (branch_encoding "outgoing_connection"
|
||||||
(obj1 (req "point" Point.encoding)))
|
(obj1 (req "point" Point.encoding)))
|
||||||
(function Outgoing_connection p -> Some p | _ -> None)
|
(function Outgoing_connection p -> Some p | _ -> None)
|
||||||
(fun p -> Outgoing_connection p) ;
|
(fun p -> Outgoing_connection p) ;
|
||||||
case (Tag 6) (branch_encoding "authentication_failed"
|
case (Tag 6) (branch_encoding "authentication_failed"
|
||||||
(obj1 (req "point" Point.encoding)))
|
(obj1 (req "point" Point.encoding)))
|
||||||
(function Authentication_failed p -> Some p | _ -> None)
|
(function Authentication_failed p -> Some p | _ -> None)
|
||||||
(fun p -> Authentication_failed p) ;
|
(fun p -> Authentication_failed p) ;
|
||||||
case (Tag 7) (branch_encoding "accepting_request"
|
case (Tag 7) (branch_encoding "accepting_request"
|
||||||
(obj3
|
(obj3
|
||||||
(req "point" Point.encoding)
|
(req "point" Point.encoding)
|
||||||
(req "id_point" Id_point.encoding)
|
(req "id_point" Id_point.encoding)
|
||||||
(req "peer_id" Peer_id.encoding)))
|
(req "peer_id" Peer_id.encoding)))
|
||||||
(function Accepting_request (p, id_p, g) ->
|
(function Accepting_request (p, id_p, g) ->
|
||||||
Some (p, id_p, g) | _ -> None)
|
Some (p, id_p, g) | _ -> None)
|
||||||
(fun (p, id_p, g) -> Accepting_request (p, id_p, g)) ;
|
(fun (p, id_p, g) -> Accepting_request (p, id_p, g)) ;
|
||||||
case (Tag 8) (branch_encoding "rejecting_request"
|
case (Tag 8) (branch_encoding "rejecting_request"
|
||||||
(obj3
|
(obj3
|
||||||
(req "point" Point.encoding)
|
(req "point" Point.encoding)
|
||||||
(req "id_point" Id_point.encoding)
|
(req "id_point" Id_point.encoding)
|
||||||
(req "peer_id" Peer_id.encoding)))
|
(req "peer_id" Peer_id.encoding)))
|
||||||
(function Rejecting_request (p, id_p, g) ->
|
(function Rejecting_request (p, id_p, g) ->
|
||||||
Some (p, id_p, g) | _ -> None)
|
Some (p, id_p, g) | _ -> None)
|
||||||
(fun (p, id_p, g) -> Rejecting_request (p, id_p, g)) ;
|
(fun (p, id_p, g) -> Rejecting_request (p, id_p, g)) ;
|
||||||
case (Tag 9) (branch_encoding "request_rejected"
|
case (Tag 9) (branch_encoding "request_rejected"
|
||||||
(obj2
|
(obj2
|
||||||
(req "point" Point.encoding)
|
(req "point" Point.encoding)
|
||||||
(opt "identity"
|
(opt "identity"
|
||||||
(tup2 Id_point.encoding Peer_id.encoding))))
|
(tup2 Id_point.encoding Peer_id.encoding))))
|
||||||
(function Request_rejected (p, id) -> Some (p, id) | _ -> None)
|
(function Request_rejected (p, id) -> Some (p, id) | _ -> None)
|
||||||
(fun (p, id) -> Request_rejected (p, id)) ;
|
(fun (p, id) -> Request_rejected (p, id)) ;
|
||||||
case (Tag 10) (branch_encoding "connection_established"
|
case (Tag 10) (branch_encoding "connection_established"
|
||||||
(obj2
|
(obj2
|
||||||
(req "id_point" Id_point.encoding)
|
(req "id_point" Id_point.encoding)
|
||||||
(req "peer_id" Peer_id.encoding)))
|
(req "peer_id" Peer_id.encoding)))
|
||||||
(function Connection_established (id_p, g) ->
|
(function Connection_established (id_p, g) ->
|
||||||
Some (id_p, g) | _ -> None)
|
Some (id_p, g) | _ -> None)
|
||||||
(fun (id_p, g) -> Connection_established (id_p, g)) ;
|
(fun (id_p, g) -> Connection_established (id_p, g)) ;
|
||||||
case (Tag 11) (branch_encoding "disconnection"
|
case (Tag 11) (branch_encoding "disconnection"
|
||||||
(obj1 (req "peer_id" Peer_id.encoding)))
|
(obj1 (req "peer_id" Peer_id.encoding)))
|
||||||
(function Disconnection g -> Some g | _ -> None)
|
(function Disconnection g -> Some g | _ -> None)
|
||||||
(fun g -> Disconnection g) ;
|
(fun g -> Disconnection g) ;
|
||||||
case (Tag 12) (branch_encoding "external_disconnection"
|
case (Tag 12) (branch_encoding "external_disconnection"
|
||||||
(obj1 (req "peer_id" Peer_id.encoding)))
|
(obj1 (req "peer_id" Peer_id.encoding)))
|
||||||
(function External_disconnection g -> Some g | _ -> None)
|
(function External_disconnection g -> Some g | _ -> None)
|
||||||
(fun g -> External_disconnection g) ;
|
(fun g -> External_disconnection g) ;
|
||||||
case (Tag 13) (branch_encoding "gc_points" empty)
|
case (Tag 13) (branch_encoding "gc_points" empty)
|
||||||
@ -671,43 +671,43 @@ module Connection_pool_log_event = struct
|
|||||||
(function Gc_peer_ids -> Some () | _ -> None)
|
(function Gc_peer_ids -> Some () | _ -> None)
|
||||||
(fun () -> Gc_peer_ids) ;
|
(fun () -> Gc_peer_ids) ;
|
||||||
case (Tag 15) (branch_encoding "swap_request_received"
|
case (Tag 15) (branch_encoding "swap_request_received"
|
||||||
(obj1 (req "source" Peer_id.encoding)))
|
(obj1 (req "source" Peer_id.encoding)))
|
||||||
(function
|
(function
|
||||||
| Swap_request_received { source } -> Some source
|
| Swap_request_received { source } -> Some source
|
||||||
| _ -> None)
|
| _ -> None)
|
||||||
(fun source -> Swap_request_received { source }) ;
|
(fun source -> Swap_request_received { source }) ;
|
||||||
case (Tag 16) (branch_encoding "swap_ack_received"
|
case (Tag 16) (branch_encoding "swap_ack_received"
|
||||||
(obj1 (req "source" Peer_id.encoding)))
|
(obj1 (req "source" Peer_id.encoding)))
|
||||||
(function
|
(function
|
||||||
| Swap_ack_received { source } -> Some source
|
| Swap_ack_received { source } -> Some source
|
||||||
| _ -> None)
|
| _ -> None)
|
||||||
(fun source -> Swap_ack_received { source }) ;
|
(fun source -> Swap_ack_received { source }) ;
|
||||||
case (Tag 17) (branch_encoding "swap_request_sent"
|
case (Tag 17) (branch_encoding "swap_request_sent"
|
||||||
(obj1 (req "source" Peer_id.encoding)))
|
(obj1 (req "source" Peer_id.encoding)))
|
||||||
(function
|
(function
|
||||||
| Swap_request_sent { source } -> Some source
|
| Swap_request_sent { source } -> Some source
|
||||||
| _ -> None)
|
| _ -> None)
|
||||||
(fun source -> Swap_request_sent { source }) ;
|
(fun source -> Swap_request_sent { source }) ;
|
||||||
case (Tag 18) (branch_encoding "swap_ack_sent"
|
case (Tag 18) (branch_encoding "swap_ack_sent"
|
||||||
(obj1 (req "source" Peer_id.encoding)))
|
(obj1 (req "source" Peer_id.encoding)))
|
||||||
(function
|
(function
|
||||||
| Swap_ack_sent { source } -> Some source
|
| Swap_ack_sent { source } -> Some source
|
||||||
| _ -> None)
|
| _ -> None)
|
||||||
(fun source -> Swap_ack_sent { source }) ;
|
(fun source -> Swap_ack_sent { source }) ;
|
||||||
case (Tag 19) (branch_encoding "swap_request_ignored"
|
case (Tag 19) (branch_encoding "swap_request_ignored"
|
||||||
(obj1 (req "source" Peer_id.encoding)))
|
(obj1 (req "source" Peer_id.encoding)))
|
||||||
(function
|
(function
|
||||||
| Swap_request_ignored { source } -> Some source
|
| Swap_request_ignored { source } -> Some source
|
||||||
| _ -> None)
|
| _ -> None)
|
||||||
(fun source -> Swap_request_ignored { source }) ;
|
(fun source -> Swap_request_ignored { source }) ;
|
||||||
case (Tag 20) (branch_encoding "swap_success"
|
case (Tag 20) (branch_encoding "swap_success"
|
||||||
(obj1 (req "source" Peer_id.encoding)))
|
(obj1 (req "source" Peer_id.encoding)))
|
||||||
(function
|
(function
|
||||||
| Swap_success { source } -> Some source
|
| Swap_success { source } -> Some source
|
||||||
| _ -> None)
|
| _ -> None)
|
||||||
(fun source -> Swap_success { source }) ;
|
(fun source -> Swap_success { source }) ;
|
||||||
case (Tag 21) (branch_encoding "swap_failure"
|
case (Tag 21) (branch_encoding "swap_failure"
|
||||||
(obj1 (req "source" Peer_id.encoding)))
|
(obj1 (req "source" Peer_id.encoding)))
|
||||||
(function
|
(function
|
||||||
| Swap_failure { source } -> Some source
|
| Swap_failure { source } -> Some source
|
||||||
| _ -> None)
|
| _ -> None)
|
||||||
|
@ -192,8 +192,8 @@ let rec worker_loop pv =
|
|||||||
| Ok () ->
|
| Ok () ->
|
||||||
worker_loop pv
|
worker_loop pv
|
||||||
| Error ((( Unknown_ancestor
|
| Error ((( Unknown_ancestor
|
||||||
| Bootstrap_pipeline.Invalid_locator _
|
| Bootstrap_pipeline.Invalid_locator _
|
||||||
| Block_validator.Invalid_block _ ) :: _) as errors ) ->
|
| Block_validator.Invalid_block _ ) :: _) as errors ) ->
|
||||||
(* TODO ban the peer_id... *)
|
(* TODO ban the peer_id... *)
|
||||||
lwt_log_info "Terminating the validation worker for peer %a (kickban)."
|
lwt_log_info "Terminating the validation worker for peer %a (kickban)."
|
||||||
P2p.Peer_id.pp_short pv.peer_id >>= fun () ->
|
P2p.Peer_id.pp_short pv.peer_id >>= fun () ->
|
||||||
|
@ -97,17 +97,17 @@ let directory_descr_encoding =
|
|||||||
let static_subdirectories_descr_encoding =
|
let static_subdirectories_descr_encoding =
|
||||||
union [
|
union [
|
||||||
case (Tag 0) (obj1 (req "suffixes"
|
case (Tag 0) (obj1 (req "suffixes"
|
||||||
(list (obj2 (req "name" string)
|
(list (obj2 (req "name" string)
|
||||||
(req "tree" directory_descr_encoding)))))
|
(req "tree" directory_descr_encoding)))))
|
||||||
(function Suffixes map ->
|
(function Suffixes map ->
|
||||||
Some (StringMap.bindings map) | _ -> None)
|
Some (StringMap.bindings map) | _ -> None)
|
||||||
(fun m ->
|
(fun m ->
|
||||||
let add acc (n,t) = StringMap.add n t acc in
|
let add acc (n,t) = StringMap.add n t acc in
|
||||||
Suffixes (List.fold_left add StringMap.empty m)) ;
|
Suffixes (List.fold_left add StringMap.empty m)) ;
|
||||||
case (Tag 1) (obj1 (req "dynamic_dispatch"
|
case (Tag 1) (obj1 (req "dynamic_dispatch"
|
||||||
(obj2
|
(obj2
|
||||||
(req "arg" arg_encoding)
|
(req "arg" arg_encoding)
|
||||||
(req "tree" directory_descr_encoding))))
|
(req "tree" directory_descr_encoding))))
|
||||||
(function Arg (ty, tree) -> Some (ty, tree) | _ -> None)
|
(function Arg (ty, tree) -> Some (ty, tree) | _ -> None)
|
||||||
(fun (ty, tree) -> Arg (ty, tree))
|
(fun (ty, tree) -> Arg (ty, tree))
|
||||||
] in
|
] in
|
||||||
|
@ -345,7 +345,7 @@ let handle accept (meth, uri, ans) =
|
|||||||
| `Unexpected_status_code (code, (content, _, media_type)) ->
|
| `Unexpected_status_code (code, (content, _, media_type)) ->
|
||||||
let media_type = Option.map media_type ~f:Media_type.name in
|
let media_type = Option.map media_type ~f:Media_type.name in
|
||||||
Cohttp_lwt.Body.to_string content >>= fun content ->
|
Cohttp_lwt.Body.to_string content >>= fun content ->
|
||||||
request_failed meth uri (Unexpected_status_code { code ; content ; media_type })
|
request_failed meth uri (Unexpected_status_code { code ; content ; media_type })
|
||||||
| `Method_not_allowed allowed ->
|
| `Method_not_allowed allowed ->
|
||||||
let allowed = List.filter_map RPC_service.meth_of_string allowed in
|
let allowed = List.filter_map RPC_service.meth_of_string allowed in
|
||||||
request_failed meth uri (Method_not_allowed allowed)
|
request_failed meth uri (Method_not_allowed allowed)
|
||||||
|
@ -21,7 +21,7 @@ for f in $files ; do
|
|||||||
ocp-indent $f > $tmp_dir/$ff
|
ocp-indent $f > $tmp_dir/$ff
|
||||||
diff -U 3 $f $tmp_dir/$ff
|
diff -U 3 $f $tmp_dir/$ff
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
if [ "$fix" = "fix" ]; then
|
if [ "$fix" = "yes" ]; then
|
||||||
echo "Fix indentation $f"
|
echo "Fix indentation $f"
|
||||||
cp $tmp_dir/$ff $f
|
cp $tmp_dir/$ff $f
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user