mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-07-06 12:52:31 +00:00
[NOD-450] Fix netsync clogging its own request queue with orphans that it had just now processed (#497)
* [NOD-450] Fix netsync clogging its own request queue with orphans that it had just now processed. * [NOD-450] Rename hash to orphanHash.
This commit is contained in:
parent
6725742d2c
commit
a71528fefb
@ -195,7 +195,7 @@ func (dag *BlockDAG) IsKnownOrphan(hash *daghash.Hash) bool {
|
|||||||
// GetOrphanMissingAncestorHashes returns all of the missing parents in the orphan's sub-DAG
|
// GetOrphanMissingAncestorHashes returns all of the missing parents in the orphan's sub-DAG
|
||||||
//
|
//
|
||||||
// This function is safe for concurrent access.
|
// This function is safe for concurrent access.
|
||||||
func (dag *BlockDAG) GetOrphanMissingAncestorHashes(hash *daghash.Hash) ([]*daghash.Hash, error) {
|
func (dag *BlockDAG) GetOrphanMissingAncestorHashes(orphanHash *daghash.Hash) ([]*daghash.Hash, error) {
|
||||||
// Protect concurrent access. Using a read lock only so multiple
|
// Protect concurrent access. Using a read lock only so multiple
|
||||||
// readers can query without blocking each other.
|
// readers can query without blocking each other.
|
||||||
dag.orphanLock.RLock()
|
dag.orphanLock.RLock()
|
||||||
@ -204,7 +204,7 @@ func (dag *BlockDAG) GetOrphanMissingAncestorHashes(hash *daghash.Hash) ([]*dagh
|
|||||||
missingAncestorsHashes := make([]*daghash.Hash, 0)
|
missingAncestorsHashes := make([]*daghash.Hash, 0)
|
||||||
|
|
||||||
visited := make(map[daghash.Hash]bool)
|
visited := make(map[daghash.Hash]bool)
|
||||||
queue := []*daghash.Hash{hash}
|
queue := []*daghash.Hash{orphanHash}
|
||||||
for len(queue) > 0 {
|
for len(queue) > 0 {
|
||||||
var current *daghash.Hash
|
var current *daghash.Hash
|
||||||
current, queue = queue[0], queue[1:]
|
current, queue = queue[0], queue[1:]
|
||||||
@ -216,7 +216,7 @@ func (dag *BlockDAG) GetOrphanMissingAncestorHashes(hash *daghash.Hash) ([]*dagh
|
|||||||
queue = append(queue, parentHash)
|
queue = append(queue, parentHash)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if !dag.BlockExists(current) {
|
if !dag.BlockExists(current) && current != orphanHash {
|
||||||
missingAncestorsHashes = append(missingAncestorsHashes, current)
|
missingAncestorsHashes = append(missingAncestorsHashes, current)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user