Skip to content

Commit

Permalink
Merge pull request #6721 from MinaProtocol/removes-get-initial-peers
Browse files Browse the repository at this point in the history
  • Loading branch information
bkase authored Nov 23, 2020
2 parents a615193 + c6df1a7 commit b78b0ac
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/app/libp2p_helper/src/codanet.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func newCodaConnectionManager() *CodaConnectionManager {
}
}

// proxy p2pconnmgr.ConnManager interface to p2pconnmgr.BasicConnMgr
// proxy connmgr.ConnManager interface to p2pconnmgr.BasicConnMgr
func (cm *CodaConnectionManager) TagPeer(p peer.ID, tag string, weight int) {
cm.p2pManager.TagPeer(p, tag, weight)
}
Expand All @@ -68,6 +68,14 @@ func (cm *CodaConnectionManager) IsProtected(p peer.ID, tag string) bool {
}
func (cm *CodaConnectionManager) Close() error { return cm.p2pManager.Close() }

// proxy connmgr.Decayer interface to p2pconnmgr.BasicConnMgr (which implements connmgr.Decayer via struct inheritance)
func (cm *CodaConnectionManager) RegisterDecayingTag(name string, interval time.Duration, decayFn connmgr.DecayFn, bumpFn connmgr.BumpFn) (connmgr.DecayingTag, error) {
// casting to Decayer here should always succeed
decayer, _ := interface{}(cm.p2pManager).(connmgr.Decayer)
tag, err := decayer.RegisterDecayingTag(name, interval, decayFn, bumpFn)
return tag, err
}

// redirect Notifee() to self for notification interception
func (cm *CodaConnectionManager) Notifee() network.Notifiee { return cm }

Expand Down
9 changes: 6 additions & 3 deletions src/lib/coda_networking/coda_networking.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1046,10 +1046,12 @@ let create (config : Config.t)
(Gossip_net.Any.on_first_connect gossip_net ~f:(fun () ->
(* After first_connect this list will only be empty if we filtered out all the peers due to mismatched chain id. *)
don't_wait_for
(let%bind initial_peers = Gossip_net.Any.peers gossip_net in
(let%map initial_peers = Gossip_net.Any.peers gossip_net in
if List.is_empty initial_peers && not config.is_seed then (
[%log fatal] "Failed to connect to any initial peers" ;
raise No_initial_peers )
raise No_initial_peers ))
(* Temporarily disabling the extra RPC call until we switch to the proper: dht.Bootstrap and resolve why "failed when refreshing routing table" is occurring. *)
(*
else (
[%log info] "Getting some extra initial peers to start" ;
(* 1. Get some peers
Expand Down Expand Up @@ -1084,7 +1086,8 @@ let create (config : Config.t)
()
| Error e ->
[%log warn] ~metadata:(metadata p e)
"failed to add peer $peer with $error" ) )) )) ;
"failed to add peer $peer with $error" ) ) *)
)) ;
(* TODO: Think about buffering:
I.e., what do we do when too many messages are coming in, or going out.
For example, some things you really want to not drop (like your outgoing
Expand Down

0 comments on commit b78b0ac

Please sign in to comment.