Revert "Comment multi-peer connect while code is under dev."
This reverts commit 7609ff396a
.
This commit is contained in:
parent
65725189db
commit
030c610211
1 changed files with 59 additions and 59 deletions
118
server.go
118
server.go
|
@ -6,7 +6,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"container/list"
|
"container/list"
|
||||||
//"fmt"
|
"fmt"
|
||||||
"github.com/conformal/btcdb"
|
"github.com/conformal/btcdb"
|
||||||
"github.com/conformal/btcwire"
|
"github.com/conformal/btcwire"
|
||||||
"net"
|
"net"
|
||||||
|
@ -357,73 +357,73 @@ func (s *server) peerHandler() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//tries := 0
|
tries := 0
|
||||||
//for outboundPeers < maxOutbound &&
|
for outboundPeers < maxOutbound &&
|
||||||
// peers.Len() < cfg.MaxPeers && !s.shutdown {
|
peers.Len() < cfg.MaxPeers && !s.shutdown {
|
||||||
// // We bias like bitcoind does, 10 for no outgoing
|
// We bias like bitcoind does, 10 for no outgoing
|
||||||
// // up to 90 (8) for the selection of new vs tried
|
// up to 90 (8) for the selection of new vs tried
|
||||||
// //addresses.
|
//addresses.
|
||||||
|
|
||||||
// nPeers := outboundPeers
|
nPeers := outboundPeers
|
||||||
// if nPeers > 8 {
|
if nPeers > 8 {
|
||||||
// nPeers = 8
|
nPeers = 8
|
||||||
// }
|
}
|
||||||
// addr := s.addrManager.GetAddress("any", 10+nPeers*10)
|
addr := s.addrManager.GetAddress("any", 10+nPeers*10)
|
||||||
// if addr == nil {
|
if addr == nil {
|
||||||
// break
|
break
|
||||||
// }
|
}
|
||||||
// key := GroupKey(addr.na)
|
key := GroupKey(addr.na)
|
||||||
// // Address will not be invalid, local or unroutable
|
// Address will not be invalid, local or unroutable
|
||||||
// // because addrmanager rejects those on addition.
|
// because addrmanager rejects those on addition.
|
||||||
// // Just check that we don't already have an address
|
// Just check that we don't already have an address
|
||||||
// // in the same group so that we are not connecting
|
// in the same group so that we are not connecting
|
||||||
// // to the same network segment at the expense of
|
// to the same network segment at the expense of
|
||||||
// // others. bitcoind breaks out of the loop here, but
|
// others. bitcoind breaks out of the loop here, but
|
||||||
// // we continue to try other addresses.
|
// we continue to try other addresses.
|
||||||
// if groups[key] != 0 {
|
if groups[key] != 0 {
|
||||||
// continue
|
continue
|
||||||
// }
|
}
|
||||||
|
|
||||||
// tries++
|
tries++
|
||||||
// // After 100 bad tries exit the loop and we'll try again
|
// After 100 bad tries exit the loop and we'll try again
|
||||||
// // later.
|
// later.
|
||||||
// if tries > 100 {
|
if tries > 100 {
|
||||||
// break
|
break
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // XXX if we have limited that address skip
|
// XXX if we have limited that address skip
|
||||||
|
|
||||||
// // only allow recent nodes (10mins) after we failed 30
|
// only allow recent nodes (10mins) after we failed 30
|
||||||
// // times
|
// times
|
||||||
// if time.Now().After(addr.lastattempt.Add(10*time.Minute)) &&
|
if time.Now().After(addr.lastattempt.Add(10*time.Minute)) &&
|
||||||
// tries < 30 {
|
tries < 30 {
|
||||||
// continue
|
continue
|
||||||
// }
|
}
|
||||||
|
|
||||||
// // allow nondefault ports after 50 failed tries.
|
// allow nondefault ports after 50 failed tries.
|
||||||
// if fmt.Sprintf("%d", addr.na.Port) !=
|
if fmt.Sprintf("%d", addr.na.Port) !=
|
||||||
// activeNetParams.peerPort && tries < 50 {
|
activeNetParams.peerPort && tries < 50 {
|
||||||
// continue
|
continue
|
||||||
// }
|
}
|
||||||
|
|
||||||
// addrStr := NetAddressKey(addr.na)
|
addrStr := NetAddressKey(addr.na)
|
||||||
|
|
||||||
// tries = 0
|
tries = 0
|
||||||
// // any failure will be due to banned peers etc. we have
|
// any failure will be due to banned peers etc. we have
|
||||||
// // already checked that we have room for more peers.
|
// already checked that we have room for more peers.
|
||||||
// if s.handleAddPeerMsg(peers, bannedPeers,
|
if s.handleAddPeerMsg(peers, bannedPeers,
|
||||||
// newOutboundPeer(s, addrStr, false)) {
|
newOutboundPeer(s, addrStr, false)) {
|
||||||
// outboundPeers++
|
outboundPeers++
|
||||||
// groups[key]++
|
groups[key]++
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
// We we need more peers, wake up in ten seconds and try again.
|
// We we need more peers, wake up in ten seconds and try again.
|
||||||
//if outboundPeers < maxOutbound && peers.Len() < cfg.MaxPeers {
|
if outboundPeers < maxOutbound && peers.Len() < cfg.MaxPeers {
|
||||||
// time.AfterFunc(10*time.Second, func() {
|
time.AfterFunc(10*time.Second, func() {
|
||||||
// s.wakeup <- true
|
s.wakeup <- true
|
||||||
// })
|
})
|
||||||
//}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if wakeupTimer != nil {
|
if wakeupTimer != nil {
|
||||||
|
|
Loading…
Reference in a new issue