Skip to content

Commit

Permalink
remove prints
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Jun 24, 2024
1 parent b733982 commit 9a954c6
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 11 deletions.
1 change: 0 additions & 1 deletion p2p/pex/pex_reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ func (r *Reactor) ensurePeers(regionAware bool) {

numToDialInOtherRegion := maxOutboundPeersInOtherRegion - currentOutboundInOtherRegion
numToDialInSameRegion := numToDial - numToDialInOtherRegion
fmt.Println("numToDialInSameRegion", numToDialInSameRegion, "numToDialInOtherRegion", numToDialInOtherRegion)

reserveSizeInRegion := cmtmath.MaxInt((numToDialInSameRegion+1)/2, 5)
reserveSizeOutOfRegion := cmtmath.MaxInt((numToDialInOtherRegion+1)/2, 5)
Expand Down
10 changes: 0 additions & 10 deletions p2p/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,21 +774,18 @@ func (sw *Switch) acceptRoutine() {

if sw.config.RegionAware {
// Note if the new peer is in the same region as us
fmt.Println("Checking if peer is same region. My region: ", sw.MyRegion, " Peer region: ", sw.addrBook.GetAddressRegion(p.SocketAddr()))
isSameRegion := sw.addrBook.GetAddressRegion(p.SocketAddr()) == sw.MyRegion

if !isSameRegion {
// If this peer is not in our same region and we have no room to dial peers outside of our region, return error
// TODO check this formula
if p.IsOutbound() {
fmt.Println("peer is outbound acceptRoutine")
maxOutboundPeersInOtherRegion := sw.config.MaxNumOutboundPeers - int(sw.config.MaxPercentPeersInSameRegion*float64(sw.config.MaxNumOutboundPeers))
if sw.CurrentNumOutboundPeersInOtherRegion+1 > maxOutboundPeersInOtherRegion {
sw.Logger.Error("exceeds max percent peers in same region")
continue
}
} else {
fmt.Println("peer is inbound acceptRoutine")
maxInboundPeersInOtherRegion := sw.config.MaxNumInboundPeers - int(sw.config.MaxPercentPeersInSameRegion*float64(sw.config.MaxNumInboundPeers))
if sw.CurrentNumInboundPeersInOtherRegion+1 > maxInboundPeersInOtherRegion {
sw.Logger.Error("exceeds max percent peers in same region")
Expand Down Expand Up @@ -901,7 +898,6 @@ func (sw *Switch) filterPeer(p Peer) error {
// addPeer starts up the Peer and adds it to the Switch. Error is returned if
// the peer is filtered out or failed to start or can't be added.
func (sw *Switch) addPeer(p Peer) error {
fmt.Println("calling addPeer", p.ID())
if err := sw.filterPeer(p); err != nil {
return err
}
Expand Down Expand Up @@ -934,25 +930,20 @@ func (sw *Switch) addPeer(p Peer) error {
// Add the peer to PeerSet. Do this before starting the reactors
// so that if Receive errors, we will find the peer and remove it.
// Add should not err since we already checked peers.Has().
fmt.Println("adding peer", p.ID())
if err := sw.peers.Add(p); err != nil {
switch err.(type) {
case ErrPeerRemoval:
fmt.Println("Error starting peer, Peer has already errored and removal was attempted.")
sw.Logger.Error("Error starting peer ",
" err ", "Peer has already errored and removal was attempted.",
"peer", p.ID())
}
fmt.Println("adding peer error", err)
return err
}
sw.metrics.Peers.Add(float64(1))
if sw.config.RegionAware {
if p.IsOutbound() && sw.addrBook.GetAddressRegion(p.SocketAddr()) != sw.MyRegion {
fmt.Println("adding peer outbound not in region: ", p.SocketAddr().IP.String())
sw.CurrentNumOutboundPeersInOtherRegion++
} else if !p.IsOutbound() && sw.addrBook.GetAddressRegion(p.SocketAddr()) != sw.MyRegion {
fmt.Println("adding peer inbound not in region: ", p.SocketAddr().IP.String())
sw.CurrentNumInboundPeersInOtherRegion++
}
}
Expand All @@ -962,7 +953,6 @@ func (sw *Switch) addPeer(p Peer) error {
reactor.AddPeer(p)
}

fmt.Println("added peer", p.ID())
sw.Logger.Debug("Added peer", "peer", p)

return nil
Expand Down

0 comments on commit 9a954c6

Please sign in to comment.