mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-06-07 06:36:46 +00:00
In blockParentBuilder.BuildParents check if a block is isInFutureOfVi… (#1993)
* In blockParentBuilder.BuildParents check if a block is isInFutureOfVirtualGenesisChildren instead of checking if it has reachability data * Add comment
This commit is contained in:
parent
753f4a2ec1
commit
63c6d7443b
@ -136,10 +136,19 @@ func (bpb *blockParentBuilder) BuildParents(stagingArea *model.StagingArea,
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, parent := range blockLevelParentsInHeader {
|
for _, parent := range blockLevelParentsInHeader {
|
||||||
|
isInFutureOfVirtualGenesisChildren := false
|
||||||
hasReachabilityData, err := bpb.reachabilityDataStore.HasReachabilityData(bpb.databaseContext, stagingArea, parent)
|
hasReachabilityData, err := bpb.reachabilityDataStore.HasReachabilityData(bpb.databaseContext, stagingArea, parent)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
if hasReachabilityData {
|
||||||
|
// If a block is in the future of one of the virtual genesis children it means we have the full DAG between the current block
|
||||||
|
// and this parent, so there's no need for any indirect reference blocks, and normal reachability queries can be used.
|
||||||
|
isInFutureOfVirtualGenesisChildren, err = bpb.dagTopologyManager.IsAnyAncestorOf(stagingArea, virtualGenesisChildren, parent)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Reference blocks are the blocks that are used in reachability queries to check if
|
// Reference blocks are the blocks that are used in reachability queries to check if
|
||||||
// a candidate is in the future of another candidate. In most cases this is just the
|
// a candidate is in the future of another candidate. In most cases this is just the
|
||||||
@ -152,7 +161,7 @@ func (bpb *blockParentBuilder) BuildParents(stagingArea *model.StagingArea,
|
|||||||
// virtual genesis children have this block as parent and use those block as
|
// virtual genesis children have this block as parent and use those block as
|
||||||
// reference blocks.
|
// reference blocks.
|
||||||
var referenceBlocks []*externalapi.DomainHash
|
var referenceBlocks []*externalapi.DomainHash
|
||||||
if hasReachabilityData {
|
if isInFutureOfVirtualGenesisChildren {
|
||||||
referenceBlocks = []*externalapi.DomainHash{parent}
|
referenceBlocks = []*externalapi.DomainHash{parent}
|
||||||
} else {
|
} else {
|
||||||
for childHash, childHeader := range virtualGenesisChildrenHeaders {
|
for childHash, childHeader := range virtualGenesisChildrenHeaders {
|
||||||
@ -168,7 +177,7 @@ func (bpb *blockParentBuilder) BuildParents(stagingArea *model.StagingArea,
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
if !hasReachabilityData {
|
if !isInFutureOfVirtualGenesisChildren {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user