mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 18:53:23 -03:00
node: Use existing NodeContext
This commit is contained in:
parent
106bcd4f39
commit
4cde4a701b
2 changed files with 6 additions and 4 deletions
|
@ -12,7 +12,8 @@ void FindCoins(const NodeContext& node, std::map<COutPoint, Coin>& coins)
|
||||||
{
|
{
|
||||||
assert(node.mempool);
|
assert(node.mempool);
|
||||||
LOCK2(cs_main, node.mempool->cs);
|
LOCK2(cs_main, node.mempool->cs);
|
||||||
CCoinsViewCache& chain_view = ::ChainstateActive().CoinsTip();
|
assert(std::addressof(::ChainstateActive()) == std::addressof(node.chainman->ActiveChainstate()));
|
||||||
|
CCoinsViewCache& chain_view = node.chainman->ActiveChainstate().CoinsTip();
|
||||||
CCoinsViewMemPool mempool_view(&chain_view, *node.mempool);
|
CCoinsViewMemPool mempool_view(&chain_view, *node.mempool);
|
||||||
for (auto& coin : coins) {
|
for (auto& coin : coins) {
|
||||||
if (!mempool_view.GetCoin(coin.first, coin.second)) {
|
if (!mempool_view.GetCoin(coin.first, coin.second)) {
|
||||||
|
|
|
@ -39,9 +39,10 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
|
||||||
|
|
||||||
{ // cs_main scope
|
{ // cs_main scope
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
assert(std::addressof(::ChainstateActive()) == std::addressof(node.chainman->ActiveChainstate()));
|
||||||
// If the transaction is already confirmed in the chain, don't do anything
|
// If the transaction is already confirmed in the chain, don't do anything
|
||||||
// and return early.
|
// and return early.
|
||||||
CCoinsViewCache &view = ::ChainstateActive().CoinsTip();
|
CCoinsViewCache &view = node.chainman->ActiveChainstate().CoinsTip();
|
||||||
for (size_t o = 0; o < tx->vout.size(); o++) {
|
for (size_t o = 0; o < tx->vout.size(); o++) {
|
||||||
const Coin& existingCoin = view.AccessCoin(COutPoint(hashTx, o));
|
const Coin& existingCoin = view.AccessCoin(COutPoint(hashTx, o));
|
||||||
// IsSpent doesn't mean the coin is spent, it means the output doesn't exist.
|
// 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
|
||||||
if (max_tx_fee > 0) {
|
if (max_tx_fee > 0) {
|
||||||
// First, call ATMP with test_accept and check the fee. If ATMP
|
// First, call ATMP with test_accept and check the fee. If ATMP
|
||||||
// fails here, return error immediately.
|
// fails here, return error immediately.
|
||||||
const MempoolAcceptResult result = AcceptToMemoryPool(::ChainstateActive(), *node.mempool, tx, false /* bypass_limits */,
|
const MempoolAcceptResult result = AcceptToMemoryPool(node.chainman->ActiveChainstate(), *node.mempool, tx, false /* bypass_limits */,
|
||||||
true /* test_accept */);
|
true /* test_accept */);
|
||||||
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
|
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
|
||||||
return HandleATMPError(result.m_state, err_string);
|
return HandleATMPError(result.m_state, err_string);
|
||||||
|
@ -62,7 +63,7 @@ TransactionError BroadcastTransaction(NodeContext& node, const CTransactionRef t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Try to submit the transaction to the mempool.
|
// Try to submit the transaction to the mempool.
|
||||||
const MempoolAcceptResult result = AcceptToMemoryPool(::ChainstateActive(), *node.mempool, tx, false /* bypass_limits */,
|
const MempoolAcceptResult result = AcceptToMemoryPool(node.chainman->ActiveChainstate(), *node.mempool, tx, false /* bypass_limits */,
|
||||||
false /* test_accept */);
|
false /* test_accept */);
|
||||||
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
|
if (result.m_result_type != MempoolAcceptResult::ResultType::VALID) {
|
||||||
return HandleATMPError(result.m_state, err_string);
|
return HandleATMPError(result.m_state, err_string);
|
||||||
|
|
Loading…
Add table
Reference in a new issue