Skip to content

Commit

Permalink
prints
Browse files Browse the repository at this point in the history
  • Loading branch information
czarcas7ic committed Jun 24, 2024
1 parent 7babec3 commit bbdee67
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions p2p/pex/addrbook.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,10 @@ func (a *addrBook) GetAddressRegion(addr *p2p.NetAddress) (string, error) {
ka = newKnownAddress(addr, nil)
ka.Region = region
a.addrLookup[addr.ID] = ka
fmt.Println("Region: ", region)
return region, nil
}
fmt.Println("Region: ", ka.Region)
return ka.Region, nil
}

Expand Down
3 changes: 3 additions & 0 deletions p2p/pex/pex_reactor.go
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,9 @@ func (r *Reactor) ensurePeers(regionAware bool) {
numToDialInOtherRegion := maxOutboundPeersInOtherRegion - currentOutboundInOtherRegion
numToDialInSameRegion := numToDial - numToDialInOtherRegion

fmt.Println("numToDialInOtherRegion", numToDialInOtherRegion)
fmt.Println("numToDialInSameRegion", numToDialInSameRegion)

reserveSizeInRegion := cmtmath.MaxInt((numToDialInSameRegion+1)/2, 5)
reserveSizeOutOfRegion := cmtmath.MaxInt((numToDialInOtherRegion+1)/2, 5)
if numToDialInSameRegion == 0 {
Expand Down
5 changes: 5 additions & 0 deletions p2p/switch.go
Original file line number Diff line number Diff line change
Expand Up @@ -801,6 +801,7 @@ func (sw *Switch) acceptRoutine() {
region, err := sw.addrBook.GetAddressRegion(p.SocketAddr())
if err != nil {
sw.Logger.Error("error getting region of peer", "err", err)
sw.transport.Cleanup(p)
continue
}
isSameRegion := region == sw.MyRegion
Expand All @@ -817,6 +818,7 @@ func (sw *Switch) acceptRoutine() {
if p.IsOutbound() {
if (out-sw.CurrentNumOutboundPeersInOtherRegion)+1 > maxOutboundPeersInSameRegion {
sw.Logger.Error("exceeds max percent peers in same region")
sw.transport.Cleanup(p)
continue
}
} else {
Expand All @@ -825,20 +827,23 @@ func (sw *Switch) acceptRoutine() {
fmt.Println("isSameRegion maxInboundPeersInSameRegion", maxInboundPeersInSameRegion)
if (in-sw.CurrentNumInboundPeersInOtherRegion)+1 > maxInboundPeersInSameRegion {
sw.Logger.Error("exceeds max percent peers in same region")
sw.transport.Cleanup(p)
continue
}
}
} else {
if p.IsOutbound() {
if sw.CurrentNumOutboundPeersInOtherRegion+1 > maxOutboundPeersInOtherRegion {
sw.Logger.Error("exceeds max percent peers in other regions")
sw.transport.Cleanup(p)
continue
}
} else {
fmt.Println("sw.CurrentNumInboundPeersInOtherRegion", sw.CurrentNumInboundPeersInOtherRegion)
fmt.Println("!isSameRegion maxInboundPeersInOtherRegion", maxInboundPeersInOtherRegion)
if sw.CurrentNumInboundPeersInOtherRegion+1 > maxInboundPeersInOtherRegion {
sw.Logger.Error("exceeds max percent peers in other regions")
sw.transport.Cleanup(p)
continue
}
}
Expand Down

0 comments on commit bbdee67

Please sign in to comment.