Changeset View
Changeset View
Standalone View
Standalone View
src/interfaces/chain.cpp
// Copyright (c) 2018 The Bitcoin Core developers | // Copyright (c) 2018 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <interfaces/chain.h> | #include <interfaces/chain.h> | ||||
#include <chain.h> | #include <chain.h> | ||||
#include <chainparams.h> | #include <chainparams.h> | ||||
#include <interfaces/handler.h> | #include <interfaces/handler.h> | ||||
#include <interfaces/wallet.h> | #include <interfaces/wallet.h> | ||||
#include <net.h> | #include <net.h> | ||||
#include <net_processing.h> | #include <net_processing.h> | ||||
#include <node/coin.h> | #include <node/coin.h> | ||||
#include <node/transaction.h> | |||||
#include <policy/mempool.h> | #include <policy/mempool.h> | ||||
#include <policy/policy.h> | #include <policy/policy.h> | ||||
#include <policy/settings.h> | #include <policy/settings.h> | ||||
#include <primitives/block.h> | #include <primitives/block.h> | ||||
#include <primitives/blockhash.h> | #include <primitives/blockhash.h> | ||||
#include <primitives/transaction.h> | #include <primitives/transaction.h> | ||||
#include <protocol.h> | #include <protocol.h> | ||||
#include <rpc/protocol.h> | #include <rpc/protocol.h> | ||||
▲ Show 20 Lines • Show All 268 Lines • ▼ Show 20 Lines | public: | ||||
bool hasDescendantsInMempool(const TxId &txid) override { | bool hasDescendantsInMempool(const TxId &txid) override { | ||||
LOCK(::g_mempool.cs); | LOCK(::g_mempool.cs); | ||||
auto it = ::g_mempool.GetIter(txid); | auto it = ::g_mempool.GetIter(txid); | ||||
return it && (*it)->GetCountWithDescendants() > 1; | return it && (*it)->GetCountWithDescendants() > 1; | ||||
} | } | ||||
void relayTransaction(const TxId &txid) override { | void relayTransaction(const TxId &txid) override { | ||||
RelayTransaction(txid, *g_connman); | RelayTransaction(txid, *g_connman); | ||||
} | } | ||||
bool broadcastTransaction(const Config &config, | |||||
const CTransactionRef &tx, | |||||
std::string &err_string, | |||||
const Amount &max_tx_fee, | |||||
bool relay) override { | |||||
const TransactionError err = | |||||
BroadcastTransaction(config, tx, err_string, max_tx_fee, relay, | |||||
/*wait_callback*/ false); | |||||
// Chain clients only care about failures to accept the tx to the | |||||
// mempool. Disregard non-mempool related failures. Note: this will | |||||
// need to be updated if BroadcastTransactions() is updated to | |||||
// return other non-mempool failures that Chain clients do not need | |||||
// to know about. | |||||
return err == TransactionError::OK; | |||||
} | |||||
void getTransactionAncestry(const TxId &txid, size_t &ancestors, | void getTransactionAncestry(const TxId &txid, size_t &ancestors, | ||||
size_t &descendants) override { | size_t &descendants) override { | ||||
::g_mempool.GetTransactionAncestry(txid, ancestors, descendants); | ::g_mempool.GetTransactionAncestry(txid, ancestors, descendants); | ||||
} | } | ||||
bool checkChainLimits(const CTransactionRef &tx) override { | bool checkChainLimits(const CTransactionRef &tx) override { | ||||
LockPoints lp; | LockPoints lp; | ||||
CTxMemPoolEntry entry(tx, Amount(), 0, 0, false, 0, lp); | CTxMemPoolEntry entry(tx, Amount(), 0, 0, false, 0, lp); | ||||
CTxMemPool::setEntries ancestors; | CTxMemPool::setEntries ancestors; | ||||
▲ Show 20 Lines • Show All 98 Lines • Show Last 20 Lines |