From bc0af21fc0a3a020d9c775f577631ad3b79369b7 Mon Sep 17 00:00:00 2001
From: lateminer <9951982+lateminer@users.noreply.github.com>
Date: Tue, 30 Jan 2024 22:24:02 +0100
Subject: [PATCH] chainstate: Set nFlags for proof-of-stake blocks in
 LoadExternalBlockFile()

---
 src/validation.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/validation.cpp b/src/validation.cpp
index a7ac757b48..28c69b35cd 100644
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -4803,6 +4803,10 @@ void Chainstate::LoadExternalBlockFile(
                         blkdat >> *pblock;
                         nRewind = blkdat.GetPos();
 
+                        // Set nFlags in case of proof of stake block
+                        if (pblock->IsProofOfStake())
+                            pblock->nFlags |= CBlockIndex::BLOCK_PROOF_OF_STAKE;
+
                         BlockValidationState state;
                         if (AcceptBlock(pblock, state, nullptr, true, dbp, nullptr, true)) {
                             nLoaded++;
@@ -4841,6 +4845,7 @@ void Chainstate::LoadExternalBlockFile(
                             LogPrint(BCLog::REINDEX, "%s: Processing out of order child %s of %s\n", __func__, pblockrecursive->GetHash().ToString(),
                                     head.ToString());
                             LOCK(cs_main);
+
                             BlockValidationState dummy;
                             if (AcceptBlock(pblockrecursive, dummy, nullptr, true, &it->second, nullptr, true)) {
                                 nLoaded++;