blockchain: add --reorg-notify

This will trigger if a reorg is seen. This may be used to do things
like stop automated withdrawals on large reorgs.

%s is replaced by the height at the split point
%h is replaced by the height of the new chain
%n is replaced by the number of new blocks after the reorg
This commit is contained in:
moneromooo-monero 2019-01-09 14:29:28 +00:00
parent 1168e8d5d5
commit 7d2f817f5e
No known key found for this signature in database
GPG key ID: 686F07454D6CEFC3
3 changed files with 32 additions and 1 deletions

View file

@ -1043,6 +1043,11 @@ bool Blockchain::switch_to_alternative_blockchain(std::list<blocks_ext_by_hash::
m_hardfork->reorganize_from_chain_height(split_height);
std::shared_ptr<tools::Notify> reorg_notify = m_reorg_notify;
if (reorg_notify)
reorg_notify->notify("%s", std::to_string(split_height).c_str(), "%h", std::to_string(m_db->height()).c_str(),
"%n", std::to_string(m_db->height() - split_height).c_str(), NULL);
MGINFO_GREEN("REORGANIZE SUCCESS! on height: " << split_height << ", new blockchain size: " << m_db->height());
return true;
}