aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/chain.cpp
diff options
context:
space:
mode:
authorAntoine Riard <ariard@student.42.fr>2019-04-18 08:21:35 -0400
committerAntoine Riard <ariard@student.42.fr>2019-04-23 13:53:46 -0400
commit422677963a7b41e340b911b4cd53d29dd8d63f21 (patch)
tree90de47147f475d9b879fd7d65bb2015dad032d0b /src/interfaces/chain.cpp
parentedfe9438ca54274815f076fc21beb790df5aa0a2 (diff)
refactor: replace isPotentialtip/waitForNotifications by higher method
Add GUARDED_BY(cs_wallet) annotation to m_last_block_processed, given that its now guarded by cs_wallet instead of cs_main
Diffstat (limited to 'src/interfaces/chain.cpp')
-rw-r--r--src/interfaces/chain.cpp17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp
index b61a51b235..ed0c3925f9 100644
--- a/src/interfaces/chain.cpp
+++ b/src/interfaces/chain.cpp
@@ -136,12 +136,6 @@ class LockImpl : public Chain::Lock
}
return nullopt;
}
- bool isPotentialTip(const uint256& hash) override
- {
- if (::chainActive.Tip()->GetBlockHash() == hash) return true;
- CBlockIndex* block = LookupBlockIndex(hash);
- return block && block->GetAncestor(::chainActive.Height()) == ::chainActive.Tip();
- }
CBlockLocator getTipLocator() override { return ::chainActive.GetLocator(); }
Optional<int> findLocatorFork(const CBlockLocator& locator) override
{
@@ -358,7 +352,16 @@ public:
{
return MakeUnique<NotificationsHandlerImpl>(*this, notifications);
}
- void waitForNotifications() override { SyncWithValidationInterfaceQueue(); }
+ void waitForNotificationsIfNewBlocksConnected(const uint256& old_tip) override
+ {
+ if (!old_tip.IsNull()) {
+ LOCK(::cs_main);
+ if (old_tip == ::chainActive.Tip()->GetBlockHash()) return;
+ CBlockIndex* block = LookupBlockIndex(old_tip);
+ if (block && block->GetAncestor(::chainActive.Height()) == ::chainActive.Tip()) return;
+ }
+ SyncWithValidationInterfaceQueue();
+ }
std::unique_ptr<Handler> handleRpc(const CRPCCommand& command) override
{
return MakeUnique<RpcHandlerImpl>(command);