mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00
[NOD-1487] Implement dagtopology's IsAncestorOfAny and IsInSelectedParentChainOf (#971)
* [NOD-1487] Implement dagtopology's IsAncestorOfAny and IsInSelectedParentChainOf * [NOD-1487] Fix IsInSelectedParentChainOf to use reachabilityTree
This commit is contained in:
parent
03790ad8a2
commit
ed6d8243ef
@ -13,7 +13,4 @@ type DAGTopologyManager interface {
|
||||
IsDescendantOf(blockHashA *externalapi.DomainHash, blockHashB *externalapi.DomainHash) (bool, error)
|
||||
IsAncestorOfAny(blockHash *externalapi.DomainHash, potentialDescendants []*externalapi.DomainHash) (bool, error)
|
||||
IsInSelectedParentChainOf(blockHashA *externalapi.DomainHash, blockHashB *externalapi.DomainHash) (bool, error)
|
||||
|
||||
Tips() ([]*externalapi.DomainHash, error)
|
||||
AddTip(tipHash *externalapi.DomainHash) error
|
||||
}
|
||||
|
@ -75,12 +75,23 @@ func (dtm *dagTopologyManager) IsDescendantOf(blockHashA *externalapi.DomainHash
|
||||
|
||||
// IsAncestorOfAny returns true if `blockHash` is an ancestor of at least one of `potentialDescendants`
|
||||
func (dtm *dagTopologyManager) IsAncestorOfAny(blockHash *externalapi.DomainHash, potentialDescendants []*externalapi.DomainHash) (bool, error) {
|
||||
panic("unimplemented")
|
||||
for _, potentialDescendant := range potentialDescendants {
|
||||
isAncestorOf, err := dtm.IsAncestorOf(blockHash, potentialDescendant)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
if isAncestorOf {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
// IsInSelectedParentChainOf returns true if blockHashA is in the selected parent chain of blockHashB
|
||||
func (dtm *dagTopologyManager) IsInSelectedParentChainOf(blockHashA *externalapi.DomainHash, blockHashB *externalapi.DomainHash) (bool, error) {
|
||||
panic("unimplemented")
|
||||
return dtm.reachabilityTree.IsReachabilityTreeAncestorOf(blockHashA, blockHashB)
|
||||
}
|
||||
|
||||
func isHashInSlice(hash *externalapi.DomainHash, hashes []*externalapi.DomainHash) bool {
|
||||
@ -91,13 +102,3 @@ func isHashInSlice(hash *externalapi.DomainHash, hashes []*externalapi.DomainHas
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Tips returns the current DAG tips
|
||||
func (dtm *dagTopologyManager) Tips() ([]*externalapi.DomainHash, error) {
|
||||
panic("implement me")
|
||||
}
|
||||
|
||||
// AddTip adds the given tip to the current DAG tips
|
||||
func (dtm *dagTopologyManager) AddTip(tipHash *externalapi.DomainHash) error {
|
||||
panic("implement me")
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user