mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-04 12:55:02 +02:00
Remove use of g_connman / PushInventory in wallet code
This commit does not change behavior.
This commit is contained in:
@@ -1890,7 +1890,7 @@ void CWallet::ReacceptWalletTransactions()
|
||||
}
|
||||
}
|
||||
|
||||
bool CWalletTx::RelayWalletTransaction(interfaces::Chain::Lock& locked_chain, CConnman* connman)
|
||||
bool CWalletTx::RelayWalletTransaction(interfaces::Chain::Lock& locked_chain)
|
||||
{
|
||||
assert(pwallet->GetBroadcastTransactions());
|
||||
if (!IsCoinBase() && !isAbandoned() && GetDepthInMainChain(locked_chain) == 0)
|
||||
@@ -1899,12 +1899,8 @@ bool CWalletTx::RelayWalletTransaction(interfaces::Chain::Lock& locked_chain, CC
|
||||
/* GetDepthInMainChain already catches known conflicts. */
|
||||
if (InMempool() || AcceptToMemoryPool(locked_chain, maxTxFee, state)) {
|
||||
pwallet->WalletLogPrintf("Relaying wtx %s\n", GetHash().ToString());
|
||||
if (connman) {
|
||||
CInv inv(MSG_TX, GetHash());
|
||||
connman->ForEachNode([&inv](CNode* pnode)
|
||||
{
|
||||
pnode->PushInventory(inv);
|
||||
});
|
||||
if (pwallet->chain().p2pEnabled()) {
|
||||
pwallet->chain().relayTransaction(GetHash());
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -2113,7 +2109,7 @@ bool CWalletTx::IsEquivalentTo(const CWalletTx& _tx) const
|
||||
return CTransaction(tx1) == CTransaction(tx2);
|
||||
}
|
||||
|
||||
std::vector<uint256> CWallet::ResendWalletTransactionsBefore(interfaces::Chain::Lock& locked_chain, int64_t nTime, CConnman* connman)
|
||||
std::vector<uint256> CWallet::ResendWalletTransactionsBefore(interfaces::Chain::Lock& locked_chain, int64_t nTime)
|
||||
{
|
||||
std::vector<uint256> result;
|
||||
|
||||
@@ -2132,7 +2128,7 @@ std::vector<uint256> CWallet::ResendWalletTransactionsBefore(interfaces::Chain::
|
||||
for (const std::pair<const unsigned int, CWalletTx*>& item : mapSorted)
|
||||
{
|
||||
CWalletTx& wtx = *item.second;
|
||||
if (wtx.RelayWalletTransaction(locked_chain, connman))
|
||||
if (wtx.RelayWalletTransaction(locked_chain))
|
||||
result.push_back(wtx.GetHash());
|
||||
}
|
||||
return result;
|
||||
@@ -2157,7 +2153,7 @@ void CWallet::ResendWalletTransactions(int64_t nBestBlockTime, CConnman* connman
|
||||
// Rebroadcast unconfirmed txes older than 5 minutes before the last
|
||||
// block was found:
|
||||
auto locked_chain = chain().assumeLocked(); // Temporary. Removed in upcoming lock cleanup
|
||||
std::vector<uint256> relayed = ResendWalletTransactionsBefore(*locked_chain, nBestBlockTime-5*60, connman);
|
||||
std::vector<uint256> relayed = ResendWalletTransactionsBefore(*locked_chain, nBestBlockTime-5*60);
|
||||
if (!relayed.empty())
|
||||
WalletLogPrintf("%s: rebroadcast %u unconfirmed transactions\n", __func__, relayed.size());
|
||||
}
|
||||
@@ -3147,7 +3143,7 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
|
||||
/**
|
||||
* Call after CreateTransaction unless you want to abort
|
||||
*/
|
||||
bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm, CReserveKey& reservekey, CConnman* connman, CValidationState& state)
|
||||
bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::vector<std::pair<std::string, std::string>> orderForm, CReserveKey& reservekey, CValidationState& state)
|
||||
{
|
||||
{
|
||||
auto locked_chain = chain().lock();
|
||||
@@ -3188,7 +3184,7 @@ bool CWallet::CommitTransaction(CTransactionRef tx, mapValue_t mapValue, std::ve
|
||||
WalletLogPrintf("CommitTransaction(): Transaction cannot be broadcast immediately, %s\n", FormatStateMessage(state));
|
||||
// TODO: if we expect the failure to be long term or permanent, instead delete wtx from the wallet and return failure.
|
||||
} else {
|
||||
wtx.RelayWalletTransaction(*locked_chain, connman);
|
||||
wtx.RelayWalletTransaction(*locked_chain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user