Browse Source

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
0.13
Jonas Schnelli 9 years ago
parent
commit
012fc91511
No known key found for this signature in database
GPG Key ID: 29D4BCB6416F53EC
  1. 7
      src/init.cpp
  2. 4
      src/main.cpp
  3. 3
      src/ui_interface.h

7
src/init.cpp

@ -515,11 +515,14 @@ std::string LicenseInfo()
"\n"; "\n";
} }
static void BlockNotifyCallback(const uint256& hashNewTip) static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex)
{ {
if (initialSync || !pBlockIndex)
return;
std::string strCmd = GetArg("-blocknotify", ""); std::string strCmd = GetArg("-blocknotify", "");
boost::replace_all(strCmd, "%s", hashNewTip.GetHex()); boost::replace_all(strCmd, "%s", pBlockIndex->GetBlockHash().GetHex());
boost::thread t(runCommand, strCmd); // thread runs free boost::thread t(runCommand, strCmd); // thread runs free
} }

4
src/main.cpp

@ -2636,9 +2636,11 @@ bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams,
// Notify external listeners about the new tip. // Notify external listeners about the new tip.
if (!vHashes.empty()) { if (!vHashes.empty()) {
GetMainSignals().UpdatedBlockTip(pindexNewTip); GetMainSignals().UpdatedBlockTip(pindexNewTip);
uiInterface.NotifyBlockTip(vHashes.front());
} }
} }
if (!vHashes.empty()) {
uiInterface.NotifyBlockTip(fInitialDownload, pindexNewTip);
}
} while(pindexMostWork != chainActive.Tip()); } while(pindexMostWork != chainActive.Tip());
CheckBlockIndex(chainparams.GetConsensus()); CheckBlockIndex(chainparams.GetConsensus());

3
src/ui_interface.h

@ -15,6 +15,7 @@
class CBasicKeyStore; class CBasicKeyStore;
class CWallet; class CWallet;
class uint256; class uint256;
class CBlockIndex;
/** General change type (added, updated, removed). */ /** General change type (added, updated, removed). */
enum ChangeType enum ChangeType
@ -94,7 +95,7 @@ public:
boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress; boost::signals2::signal<void (const std::string &title, int nProgress)> ShowProgress;
/** New block has been accepted */ /** New block has been accepted */
boost::signals2::signal<void (const uint256& hash)> NotifyBlockTip; boost::signals2::signal<void (bool, const CBlockIndex *)> NotifyBlockTip;
/** Banlist did change. */ /** Banlist did change. */
boost::signals2::signal<void (void)> BannedListChanged; boost::signals2::signal<void (void)> BannedListChanged;

Loading…
Cancel
Save