mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
Merge #17477: Remove the mempool's NotifyEntryAdded and NotifyEntryRemoved signals
e57980b4738c10344baf136de3e050a3cb958ca5 [mempool] Remove NotifyEntryAdded and NotifyEntryRemoved callbacks (John Newbery) 2dd561f36124972d2364f941de9c3417c65f05b6 [validation] Remove pool member from ConnectTrace (John Newbery) 969b65f3f527631ede1a31c7855151e5c5d91f8f [validation] Remove NotifyEntryRemoved callback from ConnectTrace (John Newbery) 5613f9842b4000fed088b8cf7b99674c328d15e1 [validation] Remove conflictedTxs from PerBlockConnectTrace (John Newbery) cdb893443cc16edf974f099b8485e04b3db1b1d7 [validation interface] Remove vtxConflicted from BlockConnected (John Newbery) 1168394d759b13af68acec6d5bfa04aaa24561f8 [wallet] Notify conflicted transactions in TransactionRemovedFromMempool (John Newbery) Pull request description: These boost signals were added in #9371, before we had a `TransactionRemovedFromMempool` method in the validation interface. The `NotifyEntryAdded` callback was used by validation to build a vector of conflicted transactions when connecting a block, which the wallet was notified of in the `BlockConnected` CValidationInterface callback. Now that we have a `TransactionRemovedFromMempool` callback, we can fire that signal directly from the mempool for conflicted transactions. Note that #9371 was implemented to ensure `-walletnotify` events were fired for these conflicted transaction. We inadvertently stopped sending these notifications in #16624 (Sep 2019 commit 7e89994). We should probably fix that, but in a different PR. ACKs for top commit: jonatack: Re-ACK e57980b ryanofsky: Code review ACK e57980b4738c10344baf136de3e050a3cb958ca5, no code changes since previous review, but helpful new code comments have been added and the PR description is now more clear about where the old code came from Tree-SHA512: 3bdbaf1ef2731e788462d4756e69c42a1efdcf168691ce1bbfdaa4b7b55ac3c5b1fd4ab7b90bcdec653703600501b4224d252cfc086aef28f9ce0da3b0563a69
This commit is contained in:
parent
fa57cb9512
commit
97b7ecb256
@ -494,13 +494,10 @@ void CCoinJoin::TransactionAddedToMempool(const CTransactionRef& tx)
|
||||
UpdateDSTXConfirmedHeight(tx, -1);
|
||||
}
|
||||
|
||||
void CCoinJoin::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted)
|
||||
void CCoinJoin::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
|
||||
{
|
||||
AssertLockNotHeld(cs_mapdstx);
|
||||
LOCK(cs_mapdstx);
|
||||
for (const auto& tx : vtxConflicted) {
|
||||
UpdateDSTXConfirmedHeight(tx, -1);
|
||||
}
|
||||
|
||||
for (const auto& tx : pblock->vtx) {
|
||||
UpdateDSTXConfirmedHeight(tx, pindex->nHeight);
|
||||
|
@ -506,7 +506,7 @@ public:
|
||||
|
||||
static void UpdateDSTXConfirmedHeight(const CTransactionRef& tx, int nHeight);
|
||||
static void TransactionAddedToMempool(const CTransactionRef& tx) LOCKS_EXCLUDED(cs_mapdstx);
|
||||
static void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted) LOCKS_EXCLUDED(cs_mapdstx);
|
||||
static void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex) LOCKS_EXCLUDED(cs_mapdstx);
|
||||
static void BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex*) LOCKS_EXCLUDED(cs_mapdstx);
|
||||
|
||||
};
|
||||
|
@ -94,7 +94,7 @@ void CDSNotificationInterface::TransactionRemovedFromMempool(const CTransactionR
|
||||
llmq_ctx->isman->TransactionRemovedFromMempool(ptx);
|
||||
}
|
||||
|
||||
void CDSNotificationInterface::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted)
|
||||
void CDSNotificationInterface::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
|
||||
{
|
||||
// TODO: Temporarily ensure that mempool removals are notified before
|
||||
// connected transactions. This shouldn't matter, but the abandoned
|
||||
@ -104,9 +104,9 @@ void CDSNotificationInterface::BlockConnected(const std::shared_ptr<const CBlock
|
||||
// to abandon a transaction and then have it inadvertently cleared by
|
||||
// the notification that the conflicted transaction was evicted.
|
||||
|
||||
llmq_ctx->isman->BlockConnected(pblock, pindex, vtxConflicted);
|
||||
llmq_ctx->clhandler->BlockConnected(pblock, pindex, vtxConflicted);
|
||||
CCoinJoin::BlockConnected(pblock, pindex, vtxConflicted);
|
||||
llmq_ctx->isman->BlockConnected(pblock, pindex);
|
||||
llmq_ctx->clhandler->BlockConnected(pblock, pindex);
|
||||
CCoinJoin::BlockConnected(pblock, pindex);
|
||||
}
|
||||
|
||||
void CDSNotificationInterface::BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected)
|
||||
|
@ -32,7 +32,7 @@ protected:
|
||||
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
|
||||
void TransactionAddedToMempool(const CTransactionRef& tx, int64_t nAcceptTime) override;
|
||||
void TransactionRemovedFromMempool(const CTransactionRef& ptx, MemPoolRemovalReason reason) override;
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted) override;
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex) override;
|
||||
void BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected) override;
|
||||
void NotifyMasternodeListChanged(bool undo, const CDeterministicMNList& oldMNList, const CDeterministicMNListDiff& diff, CConnman& connman) override;
|
||||
void NotifyChainLock(const CBlockIndex* pindex, const std::shared_ptr<const llmq::CChainLockSig>& clsig) override;
|
||||
|
@ -186,8 +186,7 @@ bool BaseIndex::Rewind(const CBlockIndex* current_tip, const CBlockIndex* new_ti
|
||||
return true;
|
||||
}
|
||||
|
||||
void BaseIndex::BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex,
|
||||
const std::vector<CTransactionRef>& txn_conflicted)
|
||||
void BaseIndex::BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex)
|
||||
{
|
||||
if (!m_synced) {
|
||||
return;
|
||||
|
@ -71,8 +71,7 @@ private:
|
||||
bool Commit();
|
||||
|
||||
protected:
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex,
|
||||
const std::vector<CTransactionRef>& txn_conflicted) override;
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex) override;
|
||||
|
||||
void ChainStateFlushed(const CBlockLocator& locator) override;
|
||||
|
||||
|
@ -112,6 +112,8 @@
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
#include <boost/signals2/signal.hpp>
|
||||
|
||||
#if ENABLE_ZMQ
|
||||
#include <zmq/zmqabstractnotifier.h>
|
||||
#include <zmq/zmqnotificationinterface.h>
|
||||
|
@ -50,11 +50,9 @@ public:
|
||||
{
|
||||
m_notifications->TransactionRemovedFromMempool(tx, reason);
|
||||
}
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& block,
|
||||
const CBlockIndex* index,
|
||||
const std::vector<CTransactionRef>& tx_conflicted) override
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* index) override
|
||||
{
|
||||
m_notifications->BlockConnected(*block, tx_conflicted, index->nHeight);
|
||||
m_notifications->BlockConnected(*block, index->nHeight);
|
||||
}
|
||||
void BlockDisconnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* index) override
|
||||
{
|
||||
|
@ -222,7 +222,7 @@ public:
|
||||
virtual ~Notifications() {}
|
||||
virtual void TransactionAddedToMempool(const CTransactionRef& tx, int64_t nAcceptTime) {}
|
||||
virtual void TransactionRemovedFromMempool(const CTransactionRef& ptx, MemPoolRemovalReason reason) {}
|
||||
virtual void BlockConnected(const CBlock& block, const std::vector<CTransactionRef>& tx_conflicted, int height) {}
|
||||
virtual void BlockConnected(const CBlock& block, int height) {}
|
||||
virtual void BlockDisconnected(const CBlock& block, int height) {}
|
||||
virtual void UpdatedBlockTip() {}
|
||||
virtual void ChainStateFlushed(const CBlockLocator& locator) {}
|
||||
|
@ -48,6 +48,8 @@
|
||||
|
||||
#include <univalue.h>
|
||||
|
||||
#include <boost/signals2/signal.hpp>
|
||||
|
||||
namespace interfaces {
|
||||
namespace {
|
||||
|
||||
|
@ -353,7 +353,7 @@ void CChainLocksHandler::TransactionAddedToMempool(const CTransactionRef& tx, in
|
||||
txFirstSeenTime.emplace(tx->GetHash(), nAcceptTime);
|
||||
}
|
||||
|
||||
void CChainLocksHandler::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted)
|
||||
void CChainLocksHandler::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
|
||||
{
|
||||
if (!m_mn_sync->IsBlockchainSynced()) {
|
||||
return;
|
||||
|
@ -94,7 +94,7 @@ public:
|
||||
void AcceptedBlockHeader(const CBlockIndex* pindexNew);
|
||||
void UpdatedBlockTip();
|
||||
void TransactionAddedToMempool(const CTransactionRef& tx, int64_t nAcceptTime);
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted);
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex);
|
||||
void BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected);
|
||||
void CheckActiveState();
|
||||
void TrySignChainTip();
|
||||
|
@ -1180,18 +1180,12 @@ void CInstantSendManager::TransactionRemovedFromMempool(const CTransactionRef& t
|
||||
RemoveConflictingLock(::SerializeHash(*islock), *islock);
|
||||
}
|
||||
|
||||
void CInstantSendManager::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted)
|
||||
void CInstantSendManager::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
|
||||
{
|
||||
if (!IsInstantSendEnabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!vtxConflicted.empty()) {
|
||||
for (const auto& tx : vtxConflicted) {
|
||||
RemoveConflictedTx(*tx);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_mn_sync->IsBlockchainSynced()) {
|
||||
for (const auto& tx : pblock->vtx) {
|
||||
if (tx->IsCoinBase() || tx->vin.empty()) {
|
||||
|
@ -320,7 +320,7 @@ public:
|
||||
|
||||
void TransactionAddedToMempool(const CTransactionRef& tx) LOCKS_EXCLUDED(cs_pendingLocks);
|
||||
void TransactionRemovedFromMempool(const CTransactionRef& tx);
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted);
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex);
|
||||
void BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected);
|
||||
|
||||
bool AlreadyHave(const CInv& inv) const LOCKS_EXCLUDED(cs_pendingLocks);
|
||||
|
@ -1289,7 +1289,7 @@ PeerLogicValidation::PeerLogicValidation(CConnman& connman, BanMan* banman, CSch
|
||||
* Evict orphan txn pool entries (EraseOrphanTx) based on a newly connected
|
||||
* block. Also save the time of the last tip update.
|
||||
*/
|
||||
void PeerLogicValidation::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex, const std::vector<CTransactionRef>& vtxConflicted)
|
||||
void PeerLogicValidation::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindex)
|
||||
{
|
||||
{
|
||||
LOCK2(cs_main, g_cs_orphans);
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
/**
|
||||
* Overridden from CValidationInterface.
|
||||
*/
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected, const std::vector<CTransactionRef>& vtxConflicted) override;
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override;
|
||||
void BlockDisconnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex* pindex) override;
|
||||
/**
|
||||
* Overridden from CValidationInterface.
|
||||
|
@ -50,7 +50,7 @@ struct TestSubscriber : public CValidationInterface {
|
||||
BOOST_CHECK_EQUAL(m_expected_tip, pindexNew->GetBlockHash());
|
||||
}
|
||||
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex, const std::vector<CTransactionRef>& txnConflicted) override
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& block, const CBlockIndex* pindex) override
|
||||
{
|
||||
BOOST_CHECK_EQUAL(m_expected_tip, block->hashPrevBlock);
|
||||
BOOST_CHECK_EQUAL(m_expected_tip, pindex->pprev->GetBlockHash());
|
||||
|
@ -363,7 +363,6 @@ void CTxMemPool::AddTransactionsUpdated(unsigned int n)
|
||||
|
||||
void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAncestors, bool validFeeEstimate)
|
||||
{
|
||||
NotifyEntryAdded(entry.GetSharedTx());
|
||||
// Add to memory pool without checking anything.
|
||||
// Used by AcceptToMemoryPool(), which DOES do
|
||||
// all the appropriate checks.
|
||||
@ -619,10 +618,12 @@ bool CTxMemPool::removeSpentIndex(const uint256 txhash)
|
||||
|
||||
void CTxMemPool::removeUnchecked(txiter it, MemPoolRemovalReason reason)
|
||||
{
|
||||
CTransactionRef ptx = it->GetSharedTx();
|
||||
NotifyEntryRemoved(ptx, reason);
|
||||
if (reason != MemPoolRemovalReason::BLOCK && reason != MemPoolRemovalReason::CONFLICT) {
|
||||
GetMainSignals().TransactionRemovedFromMempool(ptx, reason);
|
||||
if (reason != MemPoolRemovalReason::BLOCK) {
|
||||
// Notify clients that a transaction has been removed from the mempool
|
||||
// for any reason except being included in a block. Clients interested
|
||||
// in transactions included in blocks can subscribe to the BlockConnected
|
||||
// notification.
|
||||
GetMainSignals().TransactionRemovedFromMempool(it->GetSharedTx(), reason);
|
||||
}
|
||||
|
||||
const uint256 hash = it->GetTx().GetHash();
|
||||
|
@ -27,11 +27,11 @@
|
||||
#include <netaddress.h>
|
||||
#include <pubkey.h>
|
||||
|
||||
#include <boost/optional.hpp>
|
||||
#include <boost/multi_index_container.hpp>
|
||||
#include <boost/multi_index/hashed_index.hpp>
|
||||
#include <boost/multi_index/ordered_index.hpp>
|
||||
#include <boost/multi_index/sequenced_index.hpp>
|
||||
#include <boost/signals2/signal.hpp>
|
||||
|
||||
class CBLSPublicKey;
|
||||
|
||||
@ -742,9 +742,6 @@ public:
|
||||
|
||||
size_t DynamicMemoryUsage() const;
|
||||
|
||||
boost::signals2::signal<void (CTransactionRef)> NotifyEntryAdded;
|
||||
boost::signals2::signal<void (CTransactionRef, MemPoolRemovalReason)> NotifyEntryRemoved;
|
||||
|
||||
/** Adds a transaction to the unbroadcast set */
|
||||
void AddUnbroadcastTx(const uint256& txid) {
|
||||
LOCK(cs);
|
||||
|
@ -2757,35 +2757,21 @@ static int64_t nTimePostConnect = 0;
|
||||
struct PerBlockConnectTrace {
|
||||
CBlockIndex* pindex = nullptr;
|
||||
std::shared_ptr<const CBlock> pblock;
|
||||
std::shared_ptr<std::vector<CTransactionRef>> conflictedTxs;
|
||||
PerBlockConnectTrace() : conflictedTxs(std::make_shared<std::vector<CTransactionRef>>()) {}
|
||||
PerBlockConnectTrace() {}
|
||||
};
|
||||
/**
|
||||
* Used to track blocks whose transactions were applied to the UTXO state as a
|
||||
* part of a single ActivateBestChainStep call.
|
||||
*
|
||||
* This class also tracks transactions that are removed from the mempool as
|
||||
* conflicts (per block) and can be used to pass all those transactions
|
||||
* through SyncTransaction.
|
||||
*
|
||||
* This class assumes (and asserts) that the conflicted transactions for a given
|
||||
* block are added via mempool callbacks prior to the BlockConnected() associated
|
||||
* with those transactions. If any transactions are marked conflicted, it is
|
||||
* assumed that an associated block will always be added.
|
||||
*
|
||||
* This class is single-use, once you call GetBlocksConnected() you have to throw
|
||||
* it away and make a new one.
|
||||
*/
|
||||
class ConnectTrace {
|
||||
private:
|
||||
std::vector<PerBlockConnectTrace> blocksConnected;
|
||||
CTxMemPool &pool;
|
||||
boost::signals2::scoped_connection m_connNotifyEntryRemoved;
|
||||
|
||||
public:
|
||||
explicit ConnectTrace(CTxMemPool &_pool) : blocksConnected(1), pool(_pool) {
|
||||
m_connNotifyEntryRemoved = pool.NotifyEntryRemoved.connect(std::bind(&ConnectTrace::NotifyEntryRemoved, this, std::placeholders::_1, std::placeholders::_2));
|
||||
}
|
||||
explicit ConnectTrace() : blocksConnected(1) {}
|
||||
|
||||
void BlockConnected(CBlockIndex* pindex, std::shared_ptr<const CBlock> pblock) {
|
||||
assert(!blocksConnected.back().pindex);
|
||||
@ -2803,17 +2789,9 @@ public:
|
||||
// one waiting for the transactions from the next block. We pop
|
||||
// the last entry here to make sure the list we return is sane.
|
||||
assert(!blocksConnected.back().pindex);
|
||||
assert(blocksConnected.back().conflictedTxs->empty());
|
||||
blocksConnected.pop_back();
|
||||
return blocksConnected;
|
||||
}
|
||||
|
||||
void NotifyEntryRemoved(CTransactionRef txRemoved, MemPoolRemovalReason reason) {
|
||||
assert(!blocksConnected.back().pindex);
|
||||
if (reason == MemPoolRemovalReason::CONFLICT) {
|
||||
blocksConnected.back().conflictedTxs->emplace_back(std::move(txRemoved));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
@ -3120,7 +3098,7 @@ bool CChainState::ActivateBestChain(CValidationState &state, const CChainParams&
|
||||
do {
|
||||
// We absolutely may not unlock cs_main until we've made forward progress
|
||||
// (with the exception of shutdown due to hardware issues, low disk space, etc).
|
||||
ConnectTrace connectTrace(mempool); // Destructed before cs_main is unlocked
|
||||
ConnectTrace connectTrace; // Destructed before cs_main is unlocked
|
||||
|
||||
if (pindexMostWork == nullptr) {
|
||||
pindexMostWork = FindMostWorkChain();
|
||||
@ -3147,7 +3125,7 @@ bool CChainState::ActivateBestChain(CValidationState &state, const CChainParams&
|
||||
|
||||
for (const PerBlockConnectTrace& trace : connectTrace.GetBlocksConnected()) {
|
||||
assert(trace.pblock && trace.pindex);
|
||||
GetMainSignals().BlockConnected(trace.pblock, trace.pindex, trace.conflictedTxs);
|
||||
GetMainSignals().BlockConnected(trace.pblock, trace.pindex);
|
||||
}
|
||||
} while (!m_chain.Tip() || (starting_tip && CBlockIndexWorkComparator()(m_chain.Tip(), starting_tip)));
|
||||
if (!blocks_connected) return true;
|
||||
|
@ -40,7 +40,7 @@ struct MainSignalsInstance {
|
||||
boost::signals2::signal<void (const CBlockIndex *, const CBlockIndex *, bool fInitialDownload)> UpdatedBlockTip;
|
||||
boost::signals2::signal<void (const CBlockIndex *, const CBlockIndex *, bool fInitialDownload)> SynchronousUpdatedBlockTip;
|
||||
boost::signals2::signal<void (const CTransactionRef &, int64_t)> TransactionAddedToMempool;
|
||||
boost::signals2::signal<void (const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex, const std::vector<CTransactionRef>&)> BlockConnected;
|
||||
boost::signals2::signal<void (const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex)> BlockConnected;
|
||||
boost::signals2::signal<void (const std::shared_ptr<const CBlock>&, const CBlockIndex* pindex)> BlockDisconnected;
|
||||
boost::signals2::signal<void (const CTransactionRef &, MemPoolRemovalReason)> TransactionRemovedFromMempool;
|
||||
boost::signals2::signal<void (const CBlockLocator &)> ChainStateFlushed;
|
||||
@ -100,7 +100,7 @@ void RegisterSharedValidationInterface(std::shared_ptr<CValidationInterface> pwa
|
||||
conns.UpdatedBlockTip = g_signals.m_internals->UpdatedBlockTip.connect(std::bind(&CValidationInterface::UpdatedBlockTip, pwalletIn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
conns.SynchronousUpdatedBlockTip = g_signals.m_internals->SynchronousUpdatedBlockTip.connect(std::bind(&CValidationInterface::SynchronousUpdatedBlockTip, pwalletIn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
conns.TransactionAddedToMempool = g_signals.m_internals->TransactionAddedToMempool.connect(std::bind(&CValidationInterface::TransactionAddedToMempool, pwalletIn, std::placeholders::_1, std::placeholders::_2));
|
||||
conns.BlockConnected = g_signals.m_internals->BlockConnected.connect(std::bind(&CValidationInterface::BlockConnected, pwalletIn, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||
conns.BlockConnected = g_signals.m_internals->BlockConnected.connect(std::bind(&CValidationInterface::BlockConnected, pwalletIn, std::placeholders::_1, std::placeholders::_2));
|
||||
conns.BlockDisconnected = g_signals.m_internals->BlockDisconnected.connect(std::bind(&CValidationInterface::BlockDisconnected, pwalletIn, std::placeholders::_1, std::placeholders::_2));
|
||||
conns.NotifyTransactionLock = g_signals.m_internals->NotifyTransactionLock.connect(std::bind(&CValidationInterface::NotifyTransactionLock, pwalletIn, std::placeholders::_1, std::placeholders::_2));
|
||||
conns.NotifyChainLock = g_signals.m_internals->NotifyChainLock.connect(std::bind(&CValidationInterface::NotifyChainLock, pwalletIn, std::placeholders::_1, std::placeholders::_2));
|
||||
@ -180,9 +180,9 @@ void CMainSignals::TransactionRemovedFromMempool(const CTransactionRef &ptx, Mem
|
||||
});
|
||||
}
|
||||
|
||||
void CMainSignals::BlockConnected(const std::shared_ptr<const CBlock> &pblock, const CBlockIndex *pindex, const std::shared_ptr<const std::vector<CTransactionRef>>& pvtxConflicted) {
|
||||
m_internals->m_schedulerClient.AddToProcessQueue([pblock, pindex, pvtxConflicted, this] {
|
||||
m_internals->BlockConnected(pblock, pindex, *pvtxConflicted);
|
||||
void CMainSignals::BlockConnected(const std::shared_ptr<const CBlock> &pblock, const CBlockIndex *pindex) {
|
||||
m_internals->m_schedulerClient.AddToProcessQueue([pblock, pindex, this] {
|
||||
m_internals->BlockConnected(pblock, pindex);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -117,10 +117,31 @@ protected:
|
||||
/**
|
||||
* Notifies listeners of a transaction leaving mempool.
|
||||
*
|
||||
* This only fires for transactions which leave mempool because of expiry,
|
||||
* size limiting, reorg (changes in lock times/coinbase maturity), or
|
||||
* replacement. This does not include any transactions which are included
|
||||
* in BlockConnectedDisconnected either in block->vtx or in txnConflicted.
|
||||
* This notification fires for transactions that are removed from the
|
||||
* mempool for the following reasons:
|
||||
*
|
||||
* - EXPIRY (expired from mempool after -mempoolexpiry hours)
|
||||
* - SIZELIMIT (removed in size limiting if the mempool exceeds -maxmempool megabytes)
|
||||
* - REORG (removed during a reorg)
|
||||
* - CONFLICT (removed because it conflicts with in-block transaction)
|
||||
*
|
||||
* This does not fire for transactions that are removed from the mempool
|
||||
* because they have been included in a block. Any client that is interested
|
||||
* in transactions removed from the mempool for inclusion in a block can learn
|
||||
* about those transactions from the BlockConnected notification.
|
||||
*
|
||||
* Transactions that are removed from the mempool because they conflict
|
||||
* with a transaction in the new block will have
|
||||
* TransactionRemovedFromMempool events fired *before* the BlockConnected
|
||||
* event is fired. If multiple blocks are connected in one step, then the
|
||||
* ordering could be:
|
||||
*
|
||||
* - TransactionRemovedFromMempool(tx1 from block A)
|
||||
* - TransactionRemovedFromMempool(tx2 from block A)
|
||||
* - TransactionRemovedFromMempool(tx1 from block B)
|
||||
* - TransactionRemovedFromMempool(tx2 from block B)
|
||||
* - BlockConnected(A)
|
||||
* - BlockConnected(B)
|
||||
*
|
||||
* Called on a background thread.
|
||||
*/
|
||||
@ -131,7 +152,7 @@ protected:
|
||||
*
|
||||
* Called on a background thread.
|
||||
*/
|
||||
virtual void BlockConnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex *pindex, const std::vector<CTransactionRef> &txnConflicted) {}
|
||||
virtual void BlockConnected(const std::shared_ptr<const CBlock> &block, const CBlockIndex *pindex) {}
|
||||
/**
|
||||
* Notifies listeners of a block being disconnected
|
||||
*
|
||||
@ -205,7 +226,7 @@ public:
|
||||
void SynchronousUpdatedBlockTip(const CBlockIndex *, const CBlockIndex *, bool fInitialDownload);
|
||||
void TransactionAddedToMempool(const CTransactionRef &, int64_t);
|
||||
void TransactionRemovedFromMempool(const CTransactionRef &, MemPoolRemovalReason);
|
||||
void BlockConnected(const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex, const std::shared_ptr<const std::vector<CTransactionRef>> &);
|
||||
void BlockConnected(const std::shared_ptr<const CBlock> &, const CBlockIndex *pindex);
|
||||
void BlockDisconnected(const std::shared_ptr<const CBlock> &, const CBlockIndex* pindex);
|
||||
void NotifyTransactionLock(const CTransactionRef &tx, const std::shared_ptr<const llmq::CInstantSendLock>& islock);
|
||||
void NotifyChainLock(const CBlockIndex* pindex, const std::shared_ptr<const llmq::CChainLockSig>& clsig);
|
||||
|
@ -1209,7 +1209,7 @@ void CWallet::TransactionRemovedFromMempool(const CTransactionRef &ptx, MemPoolR
|
||||
}
|
||||
}
|
||||
|
||||
void CWallet::BlockConnected(const CBlock& block, const std::vector<CTransactionRef>& vtxConflicted, int height)
|
||||
void CWallet::BlockConnected(const CBlock& block, int height)
|
||||
{
|
||||
const uint256& block_hash = block.GetHash();
|
||||
LOCK(cs_wallet);
|
||||
@ -1221,9 +1221,6 @@ void CWallet::BlockConnected(const CBlock& block, const std::vector<CTransaction
|
||||
SyncTransaction(block.vtx[index], confirm);
|
||||
TransactionRemovedFromMempool(block.vtx[index], MemPoolRemovalReason::MANUAL);
|
||||
}
|
||||
for (const CTransactionRef& ptx : vtxConflicted) {
|
||||
TransactionRemovedFromMempool(ptx, MemPoolRemovalReason::MANUAL);
|
||||
}
|
||||
|
||||
// reset cache to make sure no longer immature coins are included
|
||||
fAnonymizableTallyCached = false;
|
||||
|
@ -948,7 +948,7 @@ public:
|
||||
bool AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose=true);
|
||||
void LoadToWallet(CWalletTx& wtxIn) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||
void TransactionAddedToMempool(const CTransactionRef& tx, int64_t nAcceptTime) override;
|
||||
void BlockConnected(const CBlock& block, const std::vector<CTransactionRef>& vtxConflicted, int height) override;
|
||||
void BlockConnected(const CBlock& block, int height) override;
|
||||
void BlockDisconnected(const CBlock& block, int height) override;
|
||||
void UpdatedBlockTip() override;
|
||||
int64_t RescanFromTime(int64_t startTime, const WalletRescanReserver& reserver, bool update);
|
||||
|
@ -170,7 +170,7 @@ void CZMQNotificationInterface::TransactionAddedToMempool(const CTransactionRef&
|
||||
});
|
||||
}
|
||||
|
||||
void CZMQNotificationInterface::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected, const std::vector<CTransactionRef>& vtxConflicted)
|
||||
void CZMQNotificationInterface::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected)
|
||||
{
|
||||
for (const CTransactionRef& ptx : pblock->vtx) {
|
||||
// Do a normal notify for each transaction added in the block
|
||||
|
@ -27,7 +27,7 @@ protected:
|
||||
|
||||
// CValidationInterface
|
||||
void TransactionAddedToMempool(const CTransactionRef& tx, int64_t nAcceptTime) override;
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected, const std::vector<CTransactionRef>& vtxConflicted) override;
|
||||
void BlockConnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexConnected) override;
|
||||
void BlockDisconnected(const std::shared_ptr<const CBlock>& pblock, const CBlockIndex* pindexDisconnected) override;
|
||||
void UpdatedBlockTip(const CBlockIndex *pindexNew, const CBlockIndex *pindexFork, bool fInitialDownload) override;
|
||||
void NotifyChainLock(const CBlockIndex *pindex, const std::shared_ptr<const llmq::CChainLockSig>& clsig) override;
|
||||
|
@ -59,6 +59,7 @@ EXPECTED_BOOST_INCLUDES=(
|
||||
boost/multi_index/ordered_index.hpp
|
||||
boost/multi_index/sequenced_index.hpp
|
||||
boost/multi_index_container.hpp
|
||||
boost/optional.hpp
|
||||
boost/pool/pool_alloc.hpp
|
||||
boost/preprocessor/cat.hpp
|
||||
boost/preprocessor/stringize.hpp
|
||||
|
Loading…
Reference in New Issue
Block a user