mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-24 15:02:32 +00:00
Merge remote-tracking branch 'origin/v0.4.1-dev' into v0.5.0-dev
This commit is contained in:
commit
e09ce32146
16
kaspad.go
16
kaspad.go
@ -13,6 +13,7 @@ import (
|
|||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/kaspanet/kaspad/dbaccess"
|
"github.com/kaspanet/kaspad/dbaccess"
|
||||||
|
|
||||||
@ -145,7 +146,20 @@ func kaspadMain(serverChan chan<- *server.Server) error {
|
|||||||
defer func() {
|
defer func() {
|
||||||
kasdLog.Infof("Gracefully shutting down the server...")
|
kasdLog.Infof("Gracefully shutting down the server...")
|
||||||
server.Stop()
|
server.Stop()
|
||||||
server.WaitForShutdown()
|
|
||||||
|
shutdownDone := make(chan struct{})
|
||||||
|
go func() {
|
||||||
|
server.WaitForShutdown()
|
||||||
|
shutdownDone <- struct{}{}
|
||||||
|
}()
|
||||||
|
|
||||||
|
const shutdownTimeout = 2 * time.Minute
|
||||||
|
|
||||||
|
select {
|
||||||
|
case <-shutdownDone:
|
||||||
|
case <-time.After(shutdownTimeout):
|
||||||
|
kasdLog.Criticalf("Graceful shutdown timed out %s. Terminating...", shutdownTimeout)
|
||||||
|
}
|
||||||
srvrLog.Infof("Server shutdown complete")
|
srvrLog.Infof("Server shutdown complete")
|
||||||
}()
|
}()
|
||||||
server.Start()
|
server.Start()
|
||||||
|
@ -529,8 +529,17 @@ func (sm *SyncManager) handleBlockMsg(bmsg *blockMsg) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Request the parents for the orphan block from the peer that sent it.
|
|
||||||
if isOrphan {
|
if isOrphan {
|
||||||
|
// If we received an orphan block from the sync peer, it is
|
||||||
|
// misbehaving and must be disconnected from.
|
||||||
|
if peer == sm.syncPeer {
|
||||||
|
log.Errorf("Received an orphan block %s from sync peer %s. Disconnecting...",
|
||||||
|
blockHash, peer)
|
||||||
|
peer.Disconnect()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request the parents for the orphan block from the peer that sent it.
|
||||||
missingAncestors, err := sm.dag.GetOrphanMissingAncestorHashes(blockHash)
|
missingAncestors, err := sm.dag.GetOrphanMissingAncestorHashes(blockHash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Failed to find missing ancestors for block %s: %s",
|
log.Errorf("Failed to find missing ancestors for block %s: %s",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user