mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 03:52:49 +01:00
merge bitcoin#15728: Refactor relay transactions
This commit is contained in:
parent
11fc0f5667
commit
ee4f2fc8b4
@ -2284,20 +2284,25 @@ void CWallet::ReacceptWalletTransactions()
|
||||
|
||||
bool CWalletTx::RelayWalletTransaction(interfaces::Chain::Lock& locked_chain)
|
||||
{
|
||||
assert(pwallet->GetBroadcastTransactions());
|
||||
if (!IsCoinBase() && !isAbandoned() && GetDepthInMainChain(locked_chain) == 0)
|
||||
{
|
||||
CValidationState state;
|
||||
/* GetDepthInMainChain already catches known conflicts. */
|
||||
if (InMempool() || AcceptToMemoryPool(locked_chain, state)) {
|
||||
// Can't relay if wallet is not broadcasting
|
||||
if (!pwallet->GetBroadcastTransactions()) return false;
|
||||
// Don't relay coinbase transactions outside blocks
|
||||
if (IsCoinBase()) return false;
|
||||
// Don't relay abandoned transactions
|
||||
if (isAbandoned()) return false;
|
||||
// Don't relay conflicted or already confirmed transactions
|
||||
if (GetDepthInMainChain(locked_chain) != 0) return false;
|
||||
// Don't relay transactions that aren't accepted to the mempool
|
||||
CValidationState unused_state;
|
||||
if (!InMempool() && !AcceptToMemoryPool(locked_chain, unused_state)) return false;
|
||||
// Don't try to relay if the node is not connected to the p2p network
|
||||
if (!pwallet->chain().p2pEnabled()) return false;
|
||||
|
||||
// Try to relay the transaction
|
||||
pwallet->WalletLogPrintf("Relaying wtx %s\n", GetHash().ToString());
|
||||
if (pwallet->chain().p2pEnabled()) {
|
||||
pwallet->chain().relayTransaction(GetHash());
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::set<uint256> CWalletTx::GetConflicts() const
|
||||
|
@ -520,7 +520,7 @@ public:
|
||||
|
||||
int64_t GetTxTime() const;
|
||||
|
||||
// RelayWalletTransaction may only be called if fBroadcastTransactions!
|
||||
// Pass this transaction to the node to relay to its peers
|
||||
bool RelayWalletTransaction(interfaces::Chain::Lock& locked_chain);
|
||||
|
||||
/** Pass this transaction to the mempool. Fails if absolute fee exceeds absurd fee. */
|
||||
|
Loading…
Reference in New Issue
Block a user