aboutsummaryrefslogtreecommitdiff
path: root/src/node
diff options
context:
space:
mode:
Diffstat (limited to 'src/node')
-rw-r--r--src/node/interfaces.cpp14
-rw-r--r--src/node/mini_miner.h2
2 files changed, 11 insertions, 5 deletions
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index e0bab6e22e..fa151407fa 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -870,10 +870,17 @@ public:
return context()->mempool->GetTransactionsUpdated();
}
- bool testBlockValidity(BlockValidationState& state, const CBlock& block, bool check_merkle_root) override
+ bool testBlockValidity(const CBlock& block, bool check_merkle_root, BlockValidationState& state) override
{
- LOCK(::cs_main);
- return TestBlockValidity(state, chainman().GetParams(), chainman().ActiveChainstate(), block, chainman().ActiveChain().Tip(), /*fCheckPOW=*/false, check_merkle_root);
+ LOCK(cs_main);
+ CBlockIndex* tip{chainman().ActiveChain().Tip()};
+ // Fail if the tip updated before the lock was taken
+ if (block.hashPrevBlock != tip->GetBlockHash()) {
+ state.Error("Block does not connect to current chain tip.");
+ return false;
+ }
+
+ return TestBlockValidity(state, chainman().GetParams(), chainman().ActiveChainstate(), block, tip, /*fCheckPOW=*/false, check_merkle_root);
}
std::unique_ptr<CBlockTemplate> createNewBlock(const CScript& script_pub_key, bool use_mempool) override
@@ -881,7 +888,6 @@ public:
BlockAssembler::Options options;
ApplyArgsManOptions(gArgs, options);
- LOCK(::cs_main);
return BlockAssembler{chainman().ActiveChainstate(), use_mempool ? context()->mempool.get() : nullptr, options}.CreateNewBlock(script_pub_key);
}
diff --git a/src/node/mini_miner.h b/src/node/mini_miner.h
index de62c0af75..aec2aaf6b6 100644
--- a/src/node/mini_miner.h
+++ b/src/node/mini_miner.h
@@ -63,7 +63,7 @@ struct IteratorComparator
template<typename I>
bool operator()(const I& a, const I& b) const
{
- return &(*a) < &(*b);
+ return a->first < b->first;
}
};