Compare commits

...

2 Commits

Author SHA1 Message Date
Elichai Turkel
c198a3839e Fixed DAGToplogy test mock 2021-03-02 20:28:52 +02:00
Elichai Turkel
2cf101de6a Add comments and fix off-by-one in the mergeSetIncrease queue 2021-03-02 20:28:52 +02:00
2 changed files with 17 additions and 3 deletions

View File

@@ -193,14 +193,25 @@ func (csm *consensusStateManager) selectVirtualSelectedParent(
}
}
func (csm *consensusStateManager) mergeSetIncrease(
candidate *externalapi.DomainHash, selectedVirtualParents []*externalapi.DomainHash, mergeSetSize uint64) (canBeParent bool, newCandidate *externalapi.DomainHash, mergeSetIncrease uint64, err error) {
// mergeSetIncrease returns different things depending on the result:
// If the candidate can be a virtual parent then canBeParent=true and mergeSetIncrease=The increase in merge set size
// If the candidate can't be a virtual parent, then canBeParent=false and newCandidate is a new proposed candidate in the past of candidate.
func (csm *consensusStateManager) mergeSetIncrease(candidate *externalapi.DomainHash, selectedVirtualParents []*externalapi.DomainHash, mergeSetSize uint64,
) (canBeParent bool, newCandidate *externalapi.DomainHash, mergeSetIncrease uint64, err error) {
onEnd := logger.LogAndMeasureExecutionTime(log, "mergeSetIncrease")
defer onEnd()
visited := hashset.New()
queue := []*externalapi.DomainHash{candidate}
// Start with the parents in the queue as we already know the candidate isn't an ancestor of the parents.
parents, err := csm.dagTopologyManager.Parents(candidate)
if err != nil {
return false, nil, 0, err
}
for _, parent := range parents {
visited.Add(parent)
}
queue := parents
mergeSetIncrease = uint64(1) // starts with 1 for the candidate itself
var current *externalapi.DomainHash

View File

@@ -390,6 +390,9 @@ func (dt *DAGTopologyManagerImpl) IsAncestorOf(hashBlockA *externalapi.DomainHas
func (dt *DAGTopologyManagerImpl) IsAncestorOfAny(blockHash *externalapi.DomainHash, potentialDescendants []*externalapi.DomainHash) (bool, error) {
panic("unimplemented")
}
func (dt *DAGTopologyManagerImpl) IsAnyAncestorOf([]*externalapi.DomainHash, *externalapi.DomainHash) (bool, error) {
panic("unimplemented")
}
func (dt *DAGTopologyManagerImpl) IsInSelectedParentChainOf(blockHashA *externalapi.DomainHash, blockHashB *externalapi.DomainHash) (bool, error) {
panic("unimplemented")
}