mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-07-04 20:02:30 +00:00
[NOD-1578] Fix areHeaderTipsSyncedMaxTimeDifference (#1157)
* [NOD-1578] Fix areHeaderTipsSyncedMaxTimeDifference. * [NOD-1578] Return errors that occur in the new logClosure.
This commit is contained in:
parent
048caebda3
commit
a1af992d15
@ -1,10 +1,12 @@
|
|||||||
package blockprocessor
|
package blockprocessor
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"github.com/kaspanet/kaspad/domain/consensus/model"
|
"github.com/kaspanet/kaspad/domain/consensus/model"
|
||||||
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
"github.com/kaspanet/kaspad/domain/consensus/model/externalapi"
|
||||||
"github.com/kaspanet/kaspad/domain/consensus/ruleerrors"
|
"github.com/kaspanet/kaspad/domain/consensus/ruleerrors"
|
||||||
"github.com/kaspanet/kaspad/domain/consensus/utils/consensusserialization"
|
"github.com/kaspanet/kaspad/domain/consensus/utils/consensusserialization"
|
||||||
|
"github.com/kaspanet/kaspad/infrastructure/logger"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -153,11 +155,25 @@ func (bp *blockProcessor) validateAndInsertBlock(block *externalapi.DomainBlock)
|
|||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("Block %s validated and inserted", hash)
|
log.Debugf("Block %s validated and inserted", hash)
|
||||||
virtualGhostDAGData, err := bp.ghostdagDataStore.Get(bp.databaseContext, model.VirtualBlockHash)
|
|
||||||
if err != nil {
|
var logClosureErr error
|
||||||
return err
|
log.Debugf("%s", logger.NewLogClosure(func() string {
|
||||||
|
virtualGhostDAGData, err := bp.ghostdagDataStore.Get(bp.databaseContext, model.VirtualBlockHash)
|
||||||
|
if err != nil {
|
||||||
|
logClosureErr = err
|
||||||
|
return fmt.Sprintf("Failed to get virtual GHOSTDAG data: %s", err)
|
||||||
|
}
|
||||||
|
syncInfo, err := bp.syncManager.GetSyncInfo()
|
||||||
|
if err != nil {
|
||||||
|
logClosureErr = err
|
||||||
|
return fmt.Sprintf("Failed to get sync info: %s", err)
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("New virtual's blue score: %d. Sync state: %s. Block count: %d. Header count: %d",
|
||||||
|
virtualGhostDAGData.BlueScore, syncInfo.State, syncInfo.BlockCount, syncInfo.HeaderCount)
|
||||||
|
}))
|
||||||
|
if logClosureErr != nil {
|
||||||
|
return logClosureErr
|
||||||
}
|
}
|
||||||
log.Debugf("New virtual's blue score: %d", virtualGhostDAGData.BlueScore)
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
// areHeaderTipsSyncedMaxTimeDifference is the number of blocks from
|
// areHeaderTipsSyncedMaxTimeDifference is the number of blocks from
|
||||||
// the header virtual selected parent (estimated by timestamps) for
|
// the header virtual selected parent (estimated by timestamps) for
|
||||||
// kaspad to be considered not synced
|
// kaspad to be considered not synced
|
||||||
const areHeaderTipsSyncedMaxTimeDifference = 300_000 // 5 minutes
|
const areHeaderTipsSyncedMaxTimeDifference = 300 // 5 minutes
|
||||||
|
|
||||||
func (sm *syncManager) syncInfo() (*externalapi.SyncInfo, error) {
|
func (sm *syncManager) syncInfo() (*externalapi.SyncInfo, error) {
|
||||||
syncState, err := sm.resolveSyncState()
|
syncState, err := sm.resolveSyncState()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user