Changeset View
Changeset View
Standalone View
Standalone View
src/node/transaction.cpp
Show First 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | TransactionError BroadcastTransaction(NodeContext &node, const Config &config, | ||||
assert(node.mempool); | assert(node.mempool); | ||||
std::promise<void> promise; | std::promise<void> promise; | ||||
TxId txid = tx->GetId(); | TxId txid = tx->GetId(); | ||||
bool callback_set = false; | bool callback_set = false; | ||||
{ // cs_main scope | { // cs_main scope | ||||
assert(node.chainman); | assert(node.chainman); | ||||
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 | // If the transaction is already confirmed in the chain, don't do | ||||
// anything and return early. | // anything and return early. | ||||
CCoinsViewCache &view = node.chainman->ActiveChainstate().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(txid, o)); | const Coin &existingCoin = view.AccessCoin(COutPoint(txid, o)); | ||||
// IsSpent doesn't mean the coin is spent, it means the output | // IsSpent doesn't mean the coin is spent, it means the output | ||||
// doesn't exist. So if the output does exist, then this transaction | // doesn't exist. So if the output does exist, then this transaction | ||||
// exists in the chain. | // exists in the chain. | ||||
▲ Show 20 Lines • Show All 62 Lines • Show Last 20 Lines |