mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-07 14:46:44 +00:00
Cache the pruning point anticone (#2002)
This commit is contained in:
parent
3f840233d8
commit
ab73def07a
@ -44,6 +44,9 @@ type pruningManager struct {
|
|||||||
shouldSanityCheckPruningUTXOSet bool
|
shouldSanityCheckPruningUTXOSet bool
|
||||||
k externalapi.KType
|
k externalapi.KType
|
||||||
difficultyAdjustmentWindowSize int
|
difficultyAdjustmentWindowSize int
|
||||||
|
|
||||||
|
cachedPruningPoint *externalapi.DomainHash
|
||||||
|
cachedPruningPointAnticone []*externalapi.DomainHash
|
||||||
}
|
}
|
||||||
|
|
||||||
// New instantiates a new PruningManager
|
// New instantiates a new PruningManager
|
||||||
@ -932,6 +935,12 @@ func (pm *pruningManager) PruningPointAndItsAnticone() ([]*externalapi.DomainHas
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// By the Prunality proof, The pruning point anticone is a closed set (i.e., guaranteed not to change) ,
|
||||||
|
// so we can safely cache it.
|
||||||
|
if pm.cachedPruningPoint != nil && pm.cachedPruningPoint.Equal(pruningPoint) {
|
||||||
|
return append([]*externalapi.DomainHash{pruningPoint}, pm.cachedPruningPointAnticone...), nil
|
||||||
|
}
|
||||||
|
|
||||||
pruningPointAnticone, err := pm.dagTraversalManager.AnticoneFromVirtualPOV(stagingArea, pruningPoint)
|
pruningPointAnticone, err := pm.dagTraversalManager.AnticoneFromVirtualPOV(stagingArea, pruningPoint)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -958,6 +967,9 @@ func (pm *pruningManager) PruningPointAndItsAnticone() ([]*externalapi.DomainHas
|
|||||||
return nil, sortErr
|
return nil, sortErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pm.cachedPruningPoint = pruningPoint
|
||||||
|
pm.cachedPruningPointAnticone = pruningPointAnticone
|
||||||
|
|
||||||
// The pruning point should always come first
|
// The pruning point should always come first
|
||||||
return append([]*externalapi.DomainHash{pruningPoint}, pruningPointAnticone...), nil
|
return append([]*externalapi.DomainHash{pruningPoint}, pruningPointAnticone...), nil
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ func (d *domain) migrate() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
log.Infof("Current pruning point: %s", pruningPoint)
|
||||||
|
|
||||||
if d.consensusConfig.Params.GenesisHash.Equal(pruningPoint) {
|
if d.consensusConfig.Params.GenesisHash.Equal(pruningPoint) {
|
||||||
err = d.initStagingConsensus(d.consensusConfig)
|
err = d.initStagingConsensus(d.consensusConfig)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user