mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-05 05:36:54 +00:00
[NOD-1527] Allow to process headers while in missing utxo set sync state (#1018)
* [NOD-1527] Allow to process headers while in missing utxo set sync state * [NOD-1527] Add isHeaderOnlyBlock function
This commit is contained in:
parent
32da4440ba
commit
31c5264430
@ -15,20 +15,25 @@ func (bp *blockProcessor) validateAndInsertBlock(block *externalapi.DomainBlock)
|
||||
|
||||
hash := consensusserialization.HeaderHash(block.Header)
|
||||
if mode.State == externalapi.SyncStateMissingUTXOSet {
|
||||
headerTipsPruningPoint, err := bp.consensusStateManager.HeaderTipsPruningPoint()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if isHeaderOnlyBlock(block) {
|
||||
// Allow processing headers while in state SyncStateMissingUTXOSet
|
||||
mode.State = externalapi.SyncStateHeadersFirst
|
||||
} else {
|
||||
headerTipsPruningPoint, err := bp.consensusStateManager.HeaderTipsPruningPoint()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if *hash != *headerTipsPruningPoint {
|
||||
return errors.Errorf("cannot insert blocks other than the header pruning point "+
|
||||
"while in %s mode", mode.State)
|
||||
}
|
||||
if *hash != *headerTipsPruningPoint {
|
||||
return errors.Errorf("cannot insert blocks other than the header pruning point "+
|
||||
"while in %s mode", mode.State)
|
||||
}
|
||||
|
||||
mode.State = externalapi.SyncStateMissingBlockBodies
|
||||
mode.State = externalapi.SyncStateMissingBlockBodies
|
||||
}
|
||||
}
|
||||
|
||||
if mode.State == externalapi.SyncStateHeadersFirst && len(block.Transactions) != 0 {
|
||||
if mode.State == externalapi.SyncStateHeadersFirst && !isHeaderOnlyBlock(block) {
|
||||
mode.State = externalapi.SyncStateNormal
|
||||
log.Warnf("block %s contains transactions while validating in header only mode", hash)
|
||||
}
|
||||
@ -138,6 +143,10 @@ func (bp *blockProcessor) updateReachabilityReindexRoot(oldHeadersSelectedTip *e
|
||||
return bp.reachabilityManager.UpdateReindexRoot(headersSelectedTip)
|
||||
}
|
||||
|
||||
func isHeaderOnlyBlock(block *externalapi.DomainBlock) bool {
|
||||
return len(block.Transactions) == 0
|
||||
}
|
||||
|
||||
func (bp *blockProcessor) checkBlockStatus(hash *externalapi.DomainHash, mode *externalapi.SyncInfo) error {
|
||||
exists, err := bp.blockStatusStore.Exists(bp.databaseContext, hash)
|
||||
if err != nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user