mirror of https://github.com/poanetwork/gecko.git
Don't refresh peers from peerlists if already attempting to connect
This commit is contained in:
parent
a3e3e5f21e
commit
f592ecfb7b
|
@ -77,7 +77,7 @@ const (
|
|||
|
||||
// ConnectTimeout is the amount of time to wait before attempt to connect to
|
||||
// an unknown peer
|
||||
ConnectTimeout = time.Second
|
||||
ConnectTimeout = 6 * time.Second
|
||||
// GetVersionTimeout is the amount of time to wait before sending a
|
||||
// getVersion message to a partially connected peer
|
||||
GetVersionTimeout = 2 * time.Second
|
||||
|
@ -222,22 +222,32 @@ func (nm *Handshake) Connect(addr salticidae.NetAddr) {
|
|||
return
|
||||
}
|
||||
|
||||
nm.log.Info("Adding peer %s", ip)
|
||||
|
||||
if !nm.enableStaking {
|
||||
nm.log.Info("Adding peer %s", ip)
|
||||
|
||||
peer := salticidae.NewPeerIDFromNetAddr(addr, true)
|
||||
nm.ConnectTo(peer, toShortID(ip), addr)
|
||||
return
|
||||
}
|
||||
|
||||
nm.requestedLock.Lock()
|
||||
_, exists := nm.requested[ipStr]
|
||||
nm.requestedLock.Unlock()
|
||||
|
||||
if exists {
|
||||
return
|
||||
}
|
||||
|
||||
nm.log.Info("Adding peer %s", ip)
|
||||
|
||||
count := new(int)
|
||||
*count = 600
|
||||
*count = 100
|
||||
handler := new(func())
|
||||
*handler = func() {
|
||||
nm.requestedLock.Lock()
|
||||
defer nm.requestedLock.Unlock()
|
||||
|
||||
if *count == 600 {
|
||||
if *count == 100 {
|
||||
nm.requested[ipStr] = struct{}{}
|
||||
}
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ func errorHandler(_err *C.struct_SalticidaeCError, fatal C.bool, asyncID C.int32
|
|||
MainNode.EC.Stop()
|
||||
return
|
||||
}
|
||||
MainNode.Log.Error("Error during async with ID %d call: %s", asyncID, salticidae.StrError(err.GetCode()))
|
||||
MainNode.Log.Debug("Error during async with ID %d call: %s", asyncID, salticidae.StrError(err.GetCode()))
|
||||
}
|
||||
|
||||
func (n *Node) initNetlib() error {
|
||||
|
|
Loading…
Reference in New Issue