mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-22 21:50:14 +01:00
Merge bitcoin/bitcoin#25494: indexes: Stop using node internal types
7878f97bf1indexes, refactor: Remove CChainState use in index CommitInternal method (Ryan Ofsky)ee3a079fabindexes, refactor: Remove CBlockIndex* uses in index Rewind methods (Ryan Ofsky)dc971be083indexes, refactor: Remove CBlockIndex* uses in index WriteBlock methods (Ryan Ofsky)bef4e405f3indexes, refactor: Remove CBlockIndex* uses in index Init methods (Ryan Ofsky)addb4f2af1indexes, refactor: Remove CBlockIndex* uses in coinstatsindex LookUpOne function (Ryan Ofsky)33b4d48cfcindexes, refactor: Pass Chain interface instead of CChainState class to indexes (Ryan Ofsky)a0b5b4ae5ainterfaces, refactor: Add more block information to block connected notifications (Ryan Ofsky) Pull request description: Start transitioning index code away from using internal node types like `CBlockIndex` and `CChain` so index code is less coupled to node code and index code will later be able to stop locking cs_main and sync without having to deal with validationinterface race conditions, and so new indexes are easier to write and can run as plugins or separate processes. This PR contains the first 7 commits from https://github.com/bitcoin/bitcoin/pull/24230#issuecomment-1165625977 which have been split off for easier review. Previous review comments can be found in #24230 ACKs for top commit: MarcoFalke: ACK7878f97bf1though did not review the last commit 🤼 mzumsande: Code Review ACK7878f97bf1Tree-SHA512: f84ac2eb6dca2c305566ddeb35ea14d0b71c00860c0fd752bbcf1a0188be833d8c2a6ac9d3ef6ab5b46fbd02d7a24cbb8f60cf12464cb8ba208e22287f709989
This commit is contained in:
@@ -1314,30 +1314,31 @@ void CWallet::transactionRemovedFromMempool(const CTransactionRef& tx, MemPoolRe
|
||||
}
|
||||
}
|
||||
|
||||
void CWallet::blockConnected(const CBlock& block, int height)
|
||||
void CWallet::blockConnected(const interfaces::BlockInfo& block)
|
||||
{
|
||||
const uint256& block_hash = block.GetHash();
|
||||
assert(block.data);
|
||||
LOCK(cs_wallet);
|
||||
|
||||
m_last_block_processed_height = height;
|
||||
m_last_block_processed = block_hash;
|
||||
for (size_t index = 0; index < block.vtx.size(); index++) {
|
||||
SyncTransaction(block.vtx[index], TxStateConfirmed{block_hash, height, static_cast<int>(index)});
|
||||
transactionRemovedFromMempool(block.vtx[index], MemPoolRemovalReason::BLOCK, 0 /* mempool_sequence */);
|
||||
m_last_block_processed_height = block.height;
|
||||
m_last_block_processed = block.hash;
|
||||
for (size_t index = 0; index < block.data->vtx.size(); index++) {
|
||||
SyncTransaction(block.data->vtx[index], TxStateConfirmed{block.hash, block.height, static_cast<int>(index)});
|
||||
transactionRemovedFromMempool(block.data->vtx[index], MemPoolRemovalReason::BLOCK, 0 /* mempool_sequence */);
|
||||
}
|
||||
}
|
||||
|
||||
void CWallet::blockDisconnected(const CBlock& block, int height)
|
||||
void CWallet::blockDisconnected(const interfaces::BlockInfo& block)
|
||||
{
|
||||
assert(block.data);
|
||||
LOCK(cs_wallet);
|
||||
|
||||
// At block disconnection, this will change an abandoned transaction to
|
||||
// be unconfirmed, whether or not the transaction is added back to the mempool.
|
||||
// User may have to call abandontransaction again. It may be addressed in the
|
||||
// future with a stickier abandoned state or even removing abandontransaction call.
|
||||
m_last_block_processed_height = height - 1;
|
||||
m_last_block_processed = block.hashPrevBlock;
|
||||
for (const CTransactionRef& ptx : block.vtx) {
|
||||
m_last_block_processed_height = block.height - 1;
|
||||
m_last_block_processed = *Assert(block.prev_hash);
|
||||
for (const CTransactionRef& ptx : Assert(block.data)->vtx) {
|
||||
SyncTransaction(ptx, TxStateInactive{});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user