From a71528fefbc1ca4b1894bb96bff953efe317e71b Mon Sep 17 00:00:00 2001 From: stasatdaglabs <39559713+stasatdaglabs@users.noreply.github.com> Date: Thu, 28 Nov 2019 11:30:50 +0200 Subject: [PATCH] [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. --- blockdag/dag.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/blockdag/dag.go b/blockdag/dag.go index 903794405..6ed34d168 100644 --- a/blockdag/dag.go +++ b/blockdag/dag.go @@ -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 // // 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 // readers can query without blocking each other. dag.orphanLock.RLock() @@ -204,7 +204,7 @@ func (dag *BlockDAG) GetOrphanMissingAncestorHashes(hash *daghash.Hash) ([]*dagh missingAncestorsHashes := make([]*daghash.Hash, 0) visited := make(map[daghash.Hash]bool) - queue := []*daghash.Hash{hash} + queue := []*daghash.Hash{orphanHash} for len(queue) > 0 { var current *daghash.Hash current, queue = queue[0], queue[1:] @@ -216,7 +216,7 @@ func (dag *BlockDAG) GetOrphanMissingAncestorHashes(hash *daghash.Hash) ([]*dagh queue = append(queue, parentHash) } } else { - if !dag.BlockExists(current) { + if !dag.BlockExists(current) && current != orphanHash { missingAncestorsHashes = append(missingAncestorsHashes, current) } }