Skip to content

Commit

Permalink
Merge pull request #39 from erigontech/revert-35-tps
Browse files Browse the repository at this point in the history
Revert "Enabled peers connection"
  • Loading branch information
dvovk authored Dec 5, 2024
2 parents de18ee1 + 2c43b24 commit 105924a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
18 changes: 3 additions & 15 deletions torrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -1746,7 +1746,7 @@ func (t *Torrent) openNewConns(lock bool) (initiated int) {
receivedHolepunchConnect: false,
HeaderObfuscationPolicy: t.cl.config.HeaderObfuscationPolicy,
}
initiateConn(opts, false, false, false)
initiateConn(opts, false, false)
initiated++
}

Expand Down Expand Up @@ -2533,10 +2533,6 @@ func (t *Torrent) wantOutgoingConns(lock bool) bool {
conns := t.peerConnsAsSlice(lock)
defer conns.free()

if len(conns) < t.maxEstablishedConns {
return true
}

numOutgoingConns := conns.numOutgoingConns()
numIncomingConns := len(conns) - numOutgoingConns

Expand Down Expand Up @@ -3113,15 +3109,9 @@ func (t *Torrent) addHalfOpen(addrStr string, attemptKey *PeerInfo, lock bool) {

// Start the process of connecting to the given peer for the given torrent if appropriate. I'm not
// sure all the PeerInfo fields are being used.
func initiateConn(opts outgoingConnOpts, ignoreLimits bool, lock bool, lockCLient bool) {
func initiateConn(opts outgoingConnOpts, ignoreLimits bool, lock bool) {
t := opts.t
peer := opts.peerInfo

if lockCLient {
t.cl.rLock()
defer t.cl.rUnlock()
}

if peer.Id == t.cl.peerID {
return
}
Expand Down Expand Up @@ -3661,14 +3651,12 @@ func (t *Torrent) handleReceivedUtHolepunchMsg(msg utHolepunch.Msg, sender *Peer
case utHolepunch.Connect:
holepunchAddr := msg.AddrPort
t.logger.Printf("got holepunch connect request for %v from %p", holepunchAddr, sender)
t.cl.lock()
if g.MapContains(t.cl.undialableWithoutHolepunch, holepunchAddr) {
setAdd(&t.cl.undialableWithoutHolepunchDialedAfterHolepunchConnect, holepunchAddr)
if g.MapContains(t.cl.accepted, holepunchAddr) {
setAdd(&t.cl.probablyOnlyConnectedDueToHolepunch, holepunchAddr)
}
}
t.cl.unlock()
opts := outgoingConnOpts{
peerInfo: PeerInfo{
Addr: msg.AddrPort,
Expand All @@ -3683,7 +3671,7 @@ func (t *Torrent) handleReceivedUtHolepunchMsg(msg utHolepunch.Msg, sender *Peer
// encryption. So we will act normally.
HeaderObfuscationPolicy: t.cl.config.HeaderObfuscationPolicy,
}
initiateConn(opts, true, true, true)
initiateConn(opts, true, true)
return nil
case utHolepunch.Error:
torrent.Add("holepunch error messages received", 1)
Expand Down
2 changes: 1 addition & 1 deletion ut-holepunching_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestHolepunchConnect(t *testing.T) {
requireRendezvous: true,
skipHolepunchRendezvous: false,
HeaderObfuscationPolicy: llg.cl.config.HeaderObfuscationPolicy,
}, true, true, true)
}, true, true)
llg.cl.unlock()
wg.Wait()

Expand Down

0 comments on commit 105924a

Please sign in to comment.