Skip to content

Commit 4cde4a7

Browse files
committed
node: Use existing NodeContext
1 parent 106bcd4 commit 4cde4a7

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/node/coin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ void FindCoins(const NodeContext& node, std::map<COutPoint, Coin>& coins)
1212
{
1313
assert(node.mempool);
1414
LOCK2(cs_main, node.mempool->cs);
15-
CCoinsViewCache& chain_view = ::ChainstateActive().CoinsTip();
15+
assert(std::addressof(::ChainstateActive()) == std::addressof(node.chainman->ActiveChainstate()));
16+
CCoinsViewCache& chain_view = node.chainman->ActiveChainstate().CoinsTip();
1617
CCoinsViewMemPool mempool_view(&chain_view, *node.mempool);
1718
for (auto& coin : coins) {
1819
if (!mempool_view.GetCoin(coin.first, coin.second)) {

src/node/transaction.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
3939

4040
{ // cs_main scope
4141
LOCK(cs_main);
42+
assert(std::addressof(::ChainstateActive()) == std::addressof(node.chainman->ActiveChainstate()));
4243
// If the transaction is already confirmed in the chain, don't do anything
4344
// and return early.
44-
CCoinsViewCache &view = ::ChainstateActive().CoinsTip();
45+
CCoinsViewCache &view = node.chainman->ActiveChainstate().CoinsTip();
4546
for (size_t o = 0; o < tx->vout.size(); o++) {
4647
const Coin& existingCoin = view.AccessCoin(COutPoint(hashTx, o));
4748
// IsSpent doesn't mean the coin is spent, it means the output doesn't exist.
@@ -53,7 +54,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
5354
if (max_tx_fee > 0) {
5455
// First, call ATMP with test_accept and check the fee. If ATMP
5556
// fails here, return error immediately.
56-
const MempoolAcceptResult result = AcceptToMemoryPool(::ChainstateActive(), *node.mempool, tx, false /* bypass_limits */,
57+
const MempoolAcceptResult result = AcceptToMemoryPool(node.chainman->ActiveChainstate(), *node.mempool, tx, false /* bypass_limits */,
5758
true /* test_accept */);
5859
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
5960
return HandleATMPError(result.m_state, err_string);
@@ -62,7 +63,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
6263
}
6364
}
6465
// Try to submit the transaction to the mempool.
65-
const MempoolAcceptResult result = AcceptToMemoryPool(::ChainstateActive(), *node.mempool, tx, false /* bypass_limits */,
66+
const MempoolAcceptResult result = AcceptToMemoryPool(node.chainman->ActiveChainstate(), *node.mempool, tx, false /* bypass_limits */,
6667
false /* test_accept */);
6768
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
6869
return HandleATMPError(result.m_state, err_string);

0 commit comments

Comments
 (0)