mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-24 15:02:32 +00:00

* Modify DefaultTimeout to 120 seconds A temporary workaround for nodes having trouble to sync (currently the download of pruning point related data during IBD takes more than 30 seconds) * Cache existence in reachability store * Cache block level in the header * Fix IBD indication on submit block * Add hardForkOmitGenesisFromParentsDAAScore logic * Fix NumThreads bug in the wallet * Get rid of ParentsAtLevel header method * Fix a bug in BuildPruningPointProof * Increase race detector timeout * Add cache to BuildPruningPointProof * Add comments and temp comment out go vet * Fix ParentsAtLevel * Dont fill empty parents * Change HardForkOmitGenesisFromParentsDAAScore in fast netsync test * Add --allow-submit-block-when-not-synced in stability tests * Fix TestPruning * Return fast tests * Fix off by one error on kaspawallet * Fetch only one block with trusted data at a time * Update fork DAA score * Don't ban for unexpected message type * Fix tests Co-authored-by: Michael Sutton <mikisiton2@gmail.com> Co-authored-by: Ori Newman <>
53 lines
1.7 KiB
Go
53 lines
1.7 KiB
Go
package connmanager
|
|
|
|
import "github.com/kaspanet/kaspad/app/appmessage"
|
|
|
|
// checkOutgoingConnections goes over all activeOutgoing and makes sure they are still active.
|
|
// Then it opens connections so that we have targetOutgoing active connections
|
|
func (c *ConnectionManager) checkOutgoingConnections(connSet connectionSet) {
|
|
for address := range c.activeOutgoing {
|
|
connection, ok := connSet.get(address)
|
|
if ok { // connection is still connected
|
|
connSet.remove(connection)
|
|
continue
|
|
}
|
|
|
|
// if connection is dead - remove from list of active ones
|
|
delete(c.activeOutgoing, address)
|
|
}
|
|
|
|
connections := c.netAdapter.P2PConnections()
|
|
connectedAddresses := make([]*appmessage.NetAddress, len(connections))
|
|
for i, connection := range connections {
|
|
connectedAddresses[i] = connection.NetAddress()
|
|
}
|
|
|
|
liveConnections := len(c.activeOutgoing)
|
|
if c.targetOutgoing == liveConnections {
|
|
return
|
|
}
|
|
|
|
log.Debugf("Have got %d outgoing connections out of target %d, adding %d more",
|
|
liveConnections, c.targetOutgoing, c.targetOutgoing-liveConnections)
|
|
|
|
connectionsNeededCount := c.targetOutgoing - len(c.activeOutgoing)
|
|
netAddresses := c.addressManager.RandomAddresses(connectionsNeededCount, connectedAddresses)
|
|
|
|
for _, netAddress := range netAddresses {
|
|
addressString := netAddress.TCPAddress().String()
|
|
|
|
log.Debugf("Connecting to %s because we have %d outgoing connections and the target is "+
|
|
"%d", addressString, len(c.activeOutgoing), c.targetOutgoing)
|
|
|
|
err := c.initiateConnection(addressString)
|
|
if err != nil {
|
|
log.Debugf("Couldn't connect to %s: %s", addressString, err)
|
|
c.addressManager.MarkConnectionFailure(netAddress)
|
|
continue
|
|
}
|
|
c.addressManager.MarkConnectionSuccess(netAddress)
|
|
|
|
c.activeOutgoing[addressString] = struct{}{}
|
|
}
|
|
}
|