Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F10615276
D7506.id23669.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
7 KB
Subscribers
None
D7506.id23669.diff
View Options
diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h
--- a/src/interfaces/chain.h
+++ b/src/interfaces/chain.h
@@ -235,8 +235,9 @@
}
virtual void
BlockConnected(const CBlock &block,
- const std::vector<CTransactionRef> &tx_conflicted) {}
- virtual void BlockDisconnected(const CBlock &block) {}
+ const std::vector<CTransactionRef> &tx_conflicted,
+ int height) {}
+ virtual void BlockDisconnected(const CBlock &block, int height) {}
virtual void UpdatedBlockTip() {}
virtual void ChainStateFlushed(const CBlockLocator &locator) {}
};
diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp
--- a/src/interfaces/chain.cpp
+++ b/src/interfaces/chain.cpp
@@ -165,11 +165,12 @@
const std::shared_ptr<const CBlock> &block,
const CBlockIndex *index,
const std::vector<CTransactionRef> &tx_conflicted) override {
- m_notifications->BlockConnected(*block, tx_conflicted);
+ m_notifications->BlockConnected(*block, tx_conflicted,
+ index->nHeight);
}
- void
- BlockDisconnected(const std::shared_ptr<const CBlock> &block) override {
- m_notifications->BlockDisconnected(*block);
+ void BlockDisconnected(const std::shared_ptr<const CBlock> &block,
+ const CBlockIndex *index) override {
+ m_notifications->BlockDisconnected(*block, index->nHeight);
}
void UpdatedBlockTip(const CBlockIndex *index,
const CBlockIndex *fork_index,
diff --git a/src/test/validation_block_tests.cpp b/src/test/validation_block_tests.cpp
--- a/src/test/validation_block_tests.cpp
+++ b/src/test/validation_block_tests.cpp
@@ -42,9 +42,10 @@
m_expected_tip = block->GetHash();
}
- void
- BlockDisconnected(const std::shared_ptr<const CBlock> &block) override {
+ void BlockDisconnected(const std::shared_ptr<const CBlock> &block,
+ const CBlockIndex *pindex) override {
BOOST_CHECK_EQUAL(m_expected_tip, block->GetHash());
+ BOOST_CHECK_EQUAL(m_expected_tip, pindex->GetBlockHash());
m_expected_tip = block->hashPrevBlock;
}
diff --git a/src/validation.cpp b/src/validation.cpp
--- a/src/validation.cpp
+++ b/src/validation.cpp
@@ -2165,7 +2165,7 @@
UpdateTip(params, pindexDelete->pprev);
// Let wallets know transactions went from 1-confirmed to
// 0-confirmed or conflicted:
- GetMainSignals().BlockDisconnected(pblock);
+ GetMainSignals().BlockDisconnected(pblock, pindexDelete);
return true;
}
diff --git a/src/validationinterface.h b/src/validationinterface.h
--- a/src/validationinterface.h
+++ b/src/validationinterface.h
@@ -128,8 +128,8 @@
*
* Called on a background thread.
*/
- virtual void BlockDisconnected(const std::shared_ptr<const CBlock> &block) {
- }
+ virtual void BlockDisconnected(const std::shared_ptr<const CBlock> &block,
+ const CBlockIndex *pindex) {}
/**
* Notifies listeners of the new active block chain on-disk.
*
@@ -200,7 +200,8 @@
BlockConnected(const std::shared_ptr<const CBlock> &,
const CBlockIndex *pindex,
const std::shared_ptr<const std::vector<CTransactionRef>> &);
- void BlockDisconnected(const std::shared_ptr<const CBlock> &);
+ void BlockDisconnected(const std::shared_ptr<const CBlock> &,
+ const CBlockIndex *pindex);
void ChainStateFlushed(const CBlockLocator &);
void BlockChecked(const CBlock &, const BlockValidationState &);
void NewPoWValidBlock(const CBlockIndex *,
diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp
--- a/src/validationinterface.cpp
+++ b/src/validationinterface.cpp
@@ -235,12 +235,10 @@
}
void CMainSignals::BlockDisconnected(
- const std::shared_ptr<const CBlock> &pblock) {
- // TODO: This function was refactored as part of an out-of-order backport
- // of https://github.com/bitcoin/bitcoin/pull/16688
- auto event = [pblock, this] {
+ const std::shared_ptr<const CBlock> &pblock, const CBlockIndex *pindex) {
+ auto event = [pblock, pindex, this] {
m_internals->Iterate([&](CValidationInterface &callbacks) {
- callbacks.BlockDisconnected(pblock);
+ callbacks.BlockDisconnected(pblock, pindex);
});
};
ENQUEUE_AND_LOG_EVENT(event, "%s: block hash=%s", __func__,
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -984,10 +984,10 @@
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) override;
- void BlockDisconnected(const CBlock &block) override;
+ void BlockConnected(const CBlock &block,
+ const std::vector<CTransactionRef> &vtxConflicted,
+ 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);
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -1135,8 +1135,9 @@
}
}
-void CWallet::BlockConnected(
- const CBlock &block, const std::vector<CTransactionRef> &vtxConflicted) {
+void CWallet::BlockConnected(const CBlock &block,
+ const std::vector<CTransactionRef> &vtxConflicted,
+ int height) {
const BlockHash &block_hash = block.GetHash();
auto locked_chain = chain().lock();
LOCK(cs_wallet);
@@ -1153,7 +1154,7 @@
m_last_block_processed = block_hash;
}
-void CWallet::BlockDisconnected(const CBlock &block) {
+void CWallet::BlockDisconnected(const CBlock &block, int height) {
auto locked_chain = chain().lock();
LOCK(cs_wallet);
diff --git a/src/zmq/zmqnotificationinterface.h b/src/zmq/zmqnotificationinterface.h
--- a/src/zmq/zmqnotificationinterface.h
+++ b/src/zmq/zmqnotificationinterface.h
@@ -30,8 +30,8 @@
BlockConnected(const std::shared_ptr<const CBlock> &pblock,
const CBlockIndex *pindexConnected,
const std::vector<CTransactionRef> &vtxConflicted) override;
- void
- BlockDisconnected(const std::shared_ptr<const CBlock> &pblock) 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;
diff --git a/src/zmq/zmqnotificationinterface.cpp b/src/zmq/zmqnotificationinterface.cpp
--- a/src/zmq/zmqnotificationinterface.cpp
+++ b/src/zmq/zmqnotificationinterface.cpp
@@ -177,7 +177,8 @@
}
void CZMQNotificationInterface::BlockDisconnected(
- const std::shared_ptr<const CBlock> &pblock) {
+ const std::shared_ptr<const CBlock> &pblock,
+ const CBlockIndex *pindexDisconnected) {
for (const CTransactionRef &ptx : pblock->vtx) {
// Do a normal notify for each transaction removed in block
// disconnection
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 22, 10:03 (5 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
4559229
Default Alt Text
D7506.id23669.diff (7 KB)
Attached To
D7506: [backport#15931 1/9] Pass block height in Chain::BlockConnected/Chain::BlockDisconnected
Event Timeline
Log In to Comment