From 73a439185d3a52119fbdca6a897ecb18b2faf4f2 Mon Sep 17 00:00:00 2001
From: Jack Grigg <jack@z.cash>
Date: Wed, 2 Nov 2016 09:20:35 -0500
Subject: [PATCH] Ensure that no tracked blocks are skipped during orphan
 detection

---
 src/metrics.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/metrics.cpp b/src/metrics.cpp
index 6b047bbe8..4d97312e2 100644
--- a/src/metrics.cpp
+++ b/src/metrics.cpp
@@ -165,7 +165,8 @@ int printMetrics(size_t cols, int64_t nStart, bool mining)
             auto tipHeight = chainActive.Height();
 
             // Update orphans and calculate subsidies
-            for (std::list<uint256>::iterator it = u->begin(); it != u->end(); it++) {
+            std::list<uint256>::iterator it = u->begin();
+            while (it != u->end()) {
                 auto hash = *it;
                 if (mapBlockIndex.count(hash) > 0 &&
                         chainActive.Contains(mapBlockIndex[hash])) {
@@ -179,6 +180,7 @@ int printMetrics(size_t cols, int64_t nStart, bool mining)
                     } else {
                         mature += subsidy;
                     }
+                    it++;
                 } else {
                     it = u->erase(it);
                 }
-- 
2.42.0