Skip to content

Commit 012fc91

Browse files
committed
NotifyBlockTip signal: switch from hash (uint256) to CBlockIndex*
- also adds a boolean for indication if the tip update was happening during initial sync - emit notification also during initial sync
1 parent 5d5ef3a commit 012fc91

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

src/init.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,14 @@ std::string LicenseInfo()
515515
"\n";
516516
}
517517

518-
static void BlockNotifyCallback(const uint256& hashNewTip)
518+
static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex)
519519
{
520+
if (initialSync || !pBlockIndex)
521+
return;
522+
520523
std::string strCmd = GetArg("-blocknotify", "");
521524

522-
boost::replace_all(strCmd, "%s", hashNewTip.GetHex());
525+
boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex());
523526
boost::thread t(runCommand, strCmd); // thread runs free
524527
}
525528

src/main.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2636,9 +2636,11 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
26362636
// Notify external listeners about the new tip.
26372637
if (!vHashes.empty()) {
26382638
GetMainSignals().UpdatedBlockTip(pindexNewTip);
2639-
uiInterface.NotifyBlockTip(vHashes.front());
26402639
}
26412640
}
2641+
if (!vHashes.empty()) {
2642+
uiInterface.NotifyBlockTip(fInitialDownload, pindexNewTip);
2643+
}
26422644
} while(pindexMostWork != chainActive.Tip());
26432645
CheckBlockIndex(chainparams.GetConsensus());
26442646

src/ui_interface.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
class CBasicKeyStore;
1616
class CWallet;
1717
class uint256;
18+
class CBlockIndex;
1819

1920
/** General change type (added, updated, removed). */
2021
enum ChangeType
@@ -94,7 +95,7 @@ class CClientUIInterface
9495
boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress;
9596

9697
/** New block has been accepted */
97-
boost::signals2::signal<void (const uint256& hash)> NotifyBlockTip;
98+
boost::signals2::signal<void (bool, const CBlockIndex *)> NotifyBlockTip;
9899

99100
/** Banlist did change. */
100101
boost::signals2::signal<void (void)> BannedListChanged;

0 commit comments

Comments
 (0)