mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
[validation interface] Remove vtxConflicted from BlockConnected
The wallet now uses TransactionRemovedFromMempool to be notified about conflicted wallet, and no other clients use vtxConflicted.
This commit is contained in:
parent
1168394d75
commit
cdb893443c
14 changed files with 20 additions and 24 deletions
|
@ -188,8 +188,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;
|
||||
|
|
|
@ -64,8 +64,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;
|
||||
|
||||
|
|
|
@ -172,11 +172,9 @@ public:
|
|||
{
|
||||
m_notifications->TransactionRemovedFromMempool(tx);
|
||||
}
|
||||
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
|
||||
{
|
||||
|
|
|
@ -219,7 +219,7 @@ public:
|
|||
virtual ~Notifications() {}
|
||||
virtual void TransactionAddedToMempool(const CTransactionRef& tx) {}
|
||||
virtual void TransactionRemovedFromMempool(const CTransactionRef& ptx) {}
|
||||
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) {}
|
||||
|
|
|
@ -1132,7 +1132,7 @@ PeerLogicValidation::PeerLogicValidation(CConnman* connmanIn, BanMan* banman, CS
|
|||
* 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)
|
||||
{
|
||||
{
|
||||
LOCK(g_cs_orphans);
|
||||
|
|
|
@ -32,7 +32,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.
|
||||
|
|
|
@ -42,7 +42,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());
|
||||
|
|
|
@ -2881,7 +2881,7 @@ bool CChainState::ActivateBestChain(BlockValidationState &state, const CChainPar
|
|||
|
||||
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;
|
||||
|
|
|
@ -33,7 +33,7 @@ struct ValidationInterfaceConnections {
|
|||
struct MainSignalsInstance {
|
||||
boost::signals2::signal<void (const CBlockIndex *, const CBlockIndex *, bool fInitialDownload)> UpdatedBlockTip;
|
||||
boost::signals2::signal<void (const CTransactionRef &)> 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 &)> TransactionRemovedFromMempool;
|
||||
boost::signals2::signal<void (const CBlockLocator &)> ChainStateFlushed;
|
||||
|
@ -80,7 +80,7 @@ void RegisterValidationInterface(CValidationInterface* pwalletIn) {
|
|||
ValidationInterfaceConnections& conns = g_signals.m_internals->m_connMainSignals[pwalletIn];
|
||||
conns.UpdatedBlockTip = g_signals.m_internals->UpdatedBlockTip.connect(std::bind(&CValidationInterface::UpdatedBlockTip, 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));
|
||||
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.TransactionRemovedFromMempool = g_signals.m_internals->TransactionRemovedFromMempool.connect(std::bind(&CValidationInterface::TransactionRemovedFromMempool, pwalletIn, std::placeholders::_1));
|
||||
conns.ChainStateFlushed = g_signals.m_internals->ChainStateFlushed.connect(std::bind(&CValidationInterface::ChainStateFlushed, pwalletIn, std::placeholders::_1));
|
||||
|
@ -164,9 +164,9 @@ void CMainSignals::TransactionRemovedFromMempool(const CTransactionRef &ptx) {
|
|||
ptx->GetWitnessHash().ToString());
|
||||
}
|
||||
|
||||
void CMainSignals::BlockConnected(const std::shared_ptr<const CBlock> &pblock, const CBlockIndex *pindex, const std::shared_ptr<const std::vector<CTransactionRef>>& pvtxConflicted) {
|
||||
auto event = [pblock, pindex, pvtxConflicted, this] {
|
||||
m_internals->BlockConnected(pblock, pindex, *pvtxConflicted);
|
||||
void CMainSignals::BlockConnected(const std::shared_ptr<const CBlock> &pblock, const CBlockIndex *pindex) {
|
||||
auto event = [pblock, pindex, this] {
|
||||
m_internals->BlockConnected(pblock, pindex);
|
||||
};
|
||||
ENQUEUE_AND_LOG_EVENT(event, "%s: block hash=%s block height=%d", __func__,
|
||||
pblock->GetHash().ToString(),
|
||||
|
|
|
@ -128,7 +128,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
|
||||
*
|
||||
|
@ -192,7 +192,7 @@ public:
|
|||
void UpdatedBlockTip(const CBlockIndex *, const CBlockIndex *, bool fInitialDownload);
|
||||
void TransactionAddedToMempool(const CTransactionRef &);
|
||||
void TransactionRemovedFromMempool(const CTransactionRef &);
|
||||
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 ChainStateFlushed(const CBlockLocator &);
|
||||
void BlockChecked(const CBlock&, const BlockValidationState&);
|
||||
|
|
|
@ -1110,7 +1110,7 @@ void CWallet::TransactionRemovedFromMempool(const CTransactionRef &ptx) {
|
|||
}
|
||||
}
|
||||
|
||||
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();
|
||||
auto locked_chain = chain().lock();
|
||||
|
|
|
@ -874,7 +874,7 @@ public:
|
|||
bool AddToWallet(const CWalletTx& wtxIn, bool fFlushOnClose=true);
|
||||
void LoadToWallet(CWalletTx& wtxIn) EXCLUSIVE_LOCKS_REQUIRED(cs_wallet);
|
||||
void TransactionAddedToMempool(const CTransactionRef& tx) 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);
|
||||
|
|
|
@ -177,7 +177,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
|
||||
|
|
|
@ -26,7 +26,7 @@ protected:
|
|||
|
||||
// CValidationInterface
|
||||
void TransactionAddedToMempool(const CTransactionRef& tx) 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;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue