-
Notifications
You must be signed in to change notification settings - Fork 1
/
reachability.go
31 lines (27 loc) · 1.17 KB
/
reachability.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package reachabilitymanager
import (
"github.com/BTCGhostdag/BTCD/domain/consensus/model"
"github.com/BTCGhostdag/BTCD/domain/consensus/model/externalapi"
)
// IsDAGAncestorOf returns true if blockHashA is an ancestor of
// blockHashB in the DAG.
//
// Note: this method will return true if blockHashA == blockHashB
// The complexity of this method is O(log(|this.futureCoveringTreeNodeSet|))
func (rt *reachabilityManager) IsDAGAncestorOf(stagingArea *model.StagingArea, blockHashA *externalapi.DomainHash, blockHashB *externalapi.DomainHash) (bool, error) {
// Check if this node is a reachability tree ancestor of the
// other node
isReachabilityTreeAncestor, err := rt.IsReachabilityTreeAncestorOf(stagingArea, blockHashA, blockHashB)
if err != nil {
return false, err
}
if isReachabilityTreeAncestor {
return true, nil
}
// Otherwise, use previously registered future blocks to complete the
// reachability test
return rt.futureCoveringSetHasAncestorOf(stagingArea, blockHashA, blockHashB)
}
func (rt *reachabilityManager) UpdateReindexRoot(stagingArea *model.StagingArea, selectedTip *externalapi.DomainHash) error {
return rt.updateReindexRoot(stagingArea, selectedTip)
}