Skip to content

Commit

Permalink
last type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
emberian committed Oct 1, 2020
1 parent c8ff968 commit a83341d
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/app/cli/src/coda.ml
Expand Up @@ -755,7 +755,7 @@ let daemon logger =
; initial_peers
; addrs_and_ports
; trust_system
; isolate
; isolate= Option.value ~default:false isolate
; gossip_type= `Gossipsub
; keypair= libp2p_keypair }
in
Expand Down
1 change: 1 addition & 0 deletions src/app/cli/src/tests/coda_worker.ml
Expand Up @@ -516,6 +516,7 @@ module T = struct
; chain_id
; logger
; unsafe_no_trust_ip= true
; isolate= false
; gossip_type= `Gossipsub
; trust_system
; keypair= Some libp2p_keypair }
Expand Down
1 change: 1 addition & 0 deletions src/app/cli/src/tests/full_test.ml
Expand Up @@ -151,6 +151,7 @@ let run_test () : unit Deferred.t =
; logger
; initial_peers= []
; unsafe_no_trust_ip= true
; isolate= false
; gossip_type= `Gossipsub
; conf_dir= temp_conf_dir
; chain_id
Expand Down
11 changes: 11 additions & 0 deletions src/lib/coda_net2/coda_net2.ml
Expand Up @@ -962,6 +962,17 @@ module Multiaddr = struct
let to_string t = t

let of_string t = t

let to_peer t =
match String.split ~on:'/' t with
| [""; "ip4"; ip4_str; "tcp"; tcp_str; "p2p"; peer_id] -> (
try
let host = Unix.Inet_addr.of_string ip4_str in
let libp2p_port = Int.of_string tcp_str in
Some (Network_peer.Peer.create host ~libp2p_port ~peer_id)
with _ -> None )
| _ ->
None
end

type discovered_peer = {id: Peer.Id.t; maddrs: Multiaddr.t list}
Expand Down
2 changes: 2 additions & 0 deletions src/lib/coda_net2/coda_net2.mli
Expand Up @@ -94,6 +94,8 @@ module Multiaddr : sig
val to_string : t -> string

val of_string : string -> t

val to_peer : t -> Network_peer.Peer.t option
end

type discovered_peer = {id: Peer.Id.t; maddrs: Multiaddr.t list}
Expand Down
23 changes: 13 additions & 10 deletions src/lib/gossip_net/libp2p.ml
Expand Up @@ -148,16 +148,19 @@ module Make (Rpc_intf : Coda_base.Rpc_intf.Rpc_interface_intf) :
~unsafe_no_trust_ip:config.unsafe_no_trust_ip
~seed_peers:config.initial_peers
~initial_gating_config:
{ trusted_peers= config.initial_peers
; banned_peers=
Trust_system.peer_statuses config.trust_system
|> List.filter_map ~f:(fun (peer, status) ->
match status.banned with
| Banned_until _ ->
Some peer
| _ ->
None )
; isolate= config.isolate }
Coda_net2.
{ banned_peers=
Trust_system.peer_statuses config.trust_system
|> List.filter_map ~f:(fun (peer, status) ->
match status.banned with
| Banned_until _ ->
Some peer
| _ ->
None )
; trusted_peers=
List.filter_map ~f:Coda_net2.Multiaddr.to_peer
config.initial_peers
; isolate= config.isolate }
~on_new_peer:(fun _ ->
Ivar.fill_if_empty first_peer_ivar () ;
if !ctr < 4 then incr ctr
Expand Down

0 comments on commit a83341d

Please sign in to comment.