Skip to content

Commit 4903f31

Browse files
committed
Removing blocksizenotify abomination.
Essentially, we were re-serializing every new connected block tip just to calculate the size and broadcast a notification for external listeners if the block size is above 1mb. Which well.. (1) the block arrives serialized from the network and it's parsed into a block object by the core, there is no need to re-serialize the entire block.. (2) the complete serialization is just done to notify external listeners if a block exceeds the 1mb block size.. --> which can easily be done from outside of the core without having the most important node processing thread's work notifying nor calculating it, blocking cs_main for its whole time.. Github-Pull: #2284 Rebased-From: 479d065
1 parent c865148 commit 4903f31

File tree

3 files changed

+0
-26
lines changed

3 files changed

+0
-26
lines changed

src/guiinterface.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,6 @@ class CClientUIInterface
100100
/** New block has been accepted */
101101
boost::signals2::signal<void(bool fInitialDownload, const CBlockIndex* newTip)> NotifyBlockTip;
102102

103-
/** New block has been accepted and is over a certain size */
104-
boost::signals2::signal<void(int size, const uint256& hash)> NotifyBlockSize;
105-
106103
/** Banlist did change. */
107104
boost::signals2::signal<void (void)> BannedListChanged;
108105
};

src/init.cpp

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,6 @@ std::string HelpMessage(HelpMessageMode mode)
422422
strUsage += HelpMessageOpt("-version", _("Print version and exit"));
423423
strUsage += HelpMessageOpt("-alertnotify=<cmd>", _("Execute command when a relevant alert is received or we see a really long fork (%s in cmd is replaced by message)"));
424424
strUsage += HelpMessageOpt("-blocknotify=<cmd>", _("Execute command when the best block changes (%s in cmd is replaced by block hash)"));
425-
strUsage += HelpMessageOpt("-blocksizenotify=<cmd>", _("Execute command when the best block changes and its size is over (%s in cmd is replaced by block hash, %d with the block size)"));
426425
strUsage += HelpMessageOpt("-checkblocks=<n>", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), DEFAULT_CHECKBLOCKS));
427426
strUsage += HelpMessageOpt("-conf=<file>", strprintf(_("Specify configuration file (default: %s)"), PIVX_CONF_FILENAME));
428427
if (mode == HMM_BITCOIND) {
@@ -622,16 +621,6 @@ static void BlockNotifyCallback(bool initialSync, const CBlockIndex *pBlockIndex
622621
}
623622
}
624623

625-
static void BlockSizeNotifyCallback(int size, const uint256& hashNewTip)
626-
{
627-
std::string strCmd = gArgs.GetArg("-blocksizenotify", "");
628-
629-
boost::replace_all(strCmd, "%s", hashNewTip.GetHex());
630-
boost::replace_all(strCmd, "%d", std::to_string(size));
631-
std::thread t(runCommand, strCmd);
632-
t.detach(); // thread runs free
633-
}
634-
635624
////////////////////////////////////////////////////
636625

637626
static bool fHaveGenesis = false;
@@ -1786,9 +1775,6 @@ bool AppInitMain()
17861775
if (gArgs.IsArgSet("-blocknotify"))
17871776
uiInterface.NotifyBlockTip.connect(BlockNotifyCallback);
17881777

1789-
if (gArgs.IsArgSet("-blocksizenotify"))
1790-
uiInterface.NotifyBlockSize.connect(BlockSizeNotifyCallback);
1791-
17921778
// scan for better chains in the block chain database, that are not yet connected in the active best chain
17931779
CValidationState state;
17941780
if (!ActivateBestChain(state)) {

src/validation.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2271,17 +2271,8 @@ bool ActivateBestChain(CValidationState& state, std::shared_ptr<const CBlock> pb
22712271

22722272
// Always notify the UI if a new block tip was connected
22732273
if (pindexFork != pindexNewTip) {
2274-
22752274
// Notify the UI
22762275
uiInterface.NotifyBlockTip(fInitialDownload, pindexNewTip);
2277-
2278-
unsigned size = 0;
2279-
if (pblock)
2280-
size = GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION);
2281-
// If the size is over 1 MB notify external listeners, and it is within the last 5 minutes
2282-
if (size > MAX_BLOCK_SIZE_LEGACY && pblock->GetBlockTime() > GetAdjustedTime() - 300) {
2283-
uiInterface.NotifyBlockSize(static_cast<int>(size), pindexNewTip->GetBlockHash());
2284-
}
22852276
}
22862277

22872278
} while (pindexMostWork != chainActive.Tip());

0 commit comments

Comments
 (0)