Changeset View
Changeset View
Standalone View
Standalone View
src/node/transaction.cpp
Show All 34 Lines | TransactionError BroadcastTransaction(NodeContext &node, const Config &config, | ||||
{ // cs_main scope | { // cs_main scope | ||||
LOCK(cs_main); | LOCK(cs_main); | ||||
// 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 = ::ChainstateActive().CoinsTip(); | CCoinsViewCache &view = ::ChainstateActive().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 doesnt mean the coin is spent, it means the output | // IsSpent doesn't mean the coin is spent, it means the output | ||||
// doesnt' 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. | ||||
if (!existingCoin.IsSpent()) { | if (!existingCoin.IsSpent()) { | ||||
return TransactionError::ALREADY_IN_CHAIN; | return TransactionError::ALREADY_IN_CHAIN; | ||||
} | } | ||||
} | } | ||||
if (!node.mempool->exists(txid)) { | if (!node.mempool->exists(txid)) { | ||||
// Transaction is not already in the mempool. Submit it. | // Transaction is not already in the mempool. Submit it. | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |