mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
scripted-diff: wallet: s/TxStateConflicted/TxStateBlockConflicted
-BEGIN VERIFY SCRIPT- sed -i 's/TxStateConflicted/TxStateBlockConflicted/g' src/wallet/wallet.cpp src/wallet/interfaces.cpp src/wallet/transaction.h src/wallet/transaction.cpp sed -i 's/isConflicted/isBlockConflicted/g' src/wallet/transaction.h src/wallet/wallet.cpp -END VERIFY SCRIPT-
This commit is contained in:
parent
180973a941
commit
ffe5ff1fb6
4 changed files with 18 additions and 18 deletions
|
@ -92,7 +92,7 @@ WalletTxStatus MakeWalletTxStatus(const CWallet& wallet, const CWalletTx& wtx)
|
|||
WalletTxStatus result;
|
||||
result.block_height =
|
||||
wtx.state<TxStateConfirmed>() ? wtx.state<TxStateConfirmed>()->confirmed_block_height :
|
||||
wtx.state<TxStateConflicted>() ? wtx.state<TxStateConflicted>()->conflicting_block_height :
|
||||
wtx.state<TxStateBlockConflicted>() ? wtx.state<TxStateBlockConflicted>()->conflicting_block_height :
|
||||
std::numeric_limits<int>::max();
|
||||
result.blocks_to_maturity = wallet.GetTxBlocksToMaturity(wtx);
|
||||
result.depth_in_main_chain = wallet.GetTxDepthInMainChain(wtx);
|
||||
|
|
|
@ -45,7 +45,7 @@ void CWalletTx::updateState(interfaces::Chain& chain)
|
|||
};
|
||||
if (auto* conf = state<TxStateConfirmed>()) {
|
||||
lookup_block(conf->confirmed_block_hash, conf->confirmed_block_height, m_state);
|
||||
} else if (auto* conf = state<TxStateConflicted>()) {
|
||||
} else if (auto* conf = state<TxStateBlockConflicted>()) {
|
||||
lookup_block(conf->conflicting_block_hash, conf->conflicting_block_height, m_state);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,11 +43,11 @@ struct TxStateInMempool {
|
|||
};
|
||||
|
||||
//! State of rejected transaction that conflicts with a confirmed block.
|
||||
struct TxStateConflicted {
|
||||
struct TxStateBlockConflicted {
|
||||
uint256 conflicting_block_hash;
|
||||
int conflicting_block_height;
|
||||
|
||||
explicit TxStateConflicted(const uint256& block_hash, int height) : conflicting_block_hash(block_hash), conflicting_block_height(height) {}
|
||||
explicit TxStateBlockConflicted(const uint256& block_hash, int height) : conflicting_block_hash(block_hash), conflicting_block_height(height) {}
|
||||
std::string toString() const { return strprintf("Conflicted (block=%s, height=%i)", conflicting_block_hash.ToString(), conflicting_block_height); }
|
||||
};
|
||||
|
||||
|
@ -75,7 +75,7 @@ struct TxStateUnrecognized {
|
|||
};
|
||||
|
||||
//! All possible CWalletTx states
|
||||
using TxState = std::variant<TxStateConfirmed, TxStateInMempool, TxStateConflicted, TxStateInactive, TxStateUnrecognized>;
|
||||
using TxState = std::variant<TxStateConfirmed, TxStateInMempool, TxStateBlockConflicted, TxStateInactive, TxStateUnrecognized>;
|
||||
|
||||
//! Subset of states transaction sync logic is implemented to handle.
|
||||
using SyncTxState = std::variant<TxStateConfirmed, TxStateInMempool, TxStateInactive>;
|
||||
|
@ -90,7 +90,7 @@ static inline TxState TxStateInterpretSerialized(TxStateUnrecognized data)
|
|||
} else if (data.index >= 0) {
|
||||
return TxStateConfirmed{data.block_hash, /*height=*/-1, data.index};
|
||||
} else if (data.index == -1) {
|
||||
return TxStateConflicted{data.block_hash, /*height=*/-1};
|
||||
return TxStateBlockConflicted{data.block_hash, /*height=*/-1};
|
||||
}
|
||||
return data;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ static inline uint256 TxStateSerializedBlockHash(const TxState& state)
|
|||
[](const TxStateInactive& inactive) { return inactive.abandoned ? uint256::ONE : uint256::ZERO; },
|
||||
[](const TxStateInMempool& in_mempool) { return uint256::ZERO; },
|
||||
[](const TxStateConfirmed& confirmed) { return confirmed.confirmed_block_hash; },
|
||||
[](const TxStateConflicted& conflicted) { return conflicted.conflicting_block_hash; },
|
||||
[](const TxStateBlockConflicted& conflicted) { return conflicted.conflicting_block_hash; },
|
||||
[](const TxStateUnrecognized& unrecognized) { return unrecognized.block_hash; }
|
||||
}, state);
|
||||
}
|
||||
|
@ -114,7 +114,7 @@ static inline int TxStateSerializedIndex(const TxState& state)
|
|||
[](const TxStateInactive& inactive) { return inactive.abandoned ? -1 : 0; },
|
||||
[](const TxStateInMempool& in_mempool) { return 0; },
|
||||
[](const TxStateConfirmed& confirmed) { return confirmed.position_in_block; },
|
||||
[](const TxStateConflicted& conflicted) { return -1; },
|
||||
[](const TxStateBlockConflicted& conflicted) { return -1; },
|
||||
[](const TxStateUnrecognized& unrecognized) { return unrecognized.index; }
|
||||
}, state);
|
||||
}
|
||||
|
@ -335,9 +335,9 @@ public:
|
|||
void updateState(interfaces::Chain& chain);
|
||||
|
||||
bool isAbandoned() const { return state<TxStateInactive>() && state<TxStateInactive>()->abandoned; }
|
||||
bool isConflicted() const { return state<TxStateConflicted>(); }
|
||||
bool isBlockConflicted() const { return state<TxStateBlockConflicted>(); }
|
||||
bool isInactive() const { return state<TxStateInactive>(); }
|
||||
bool isUnconfirmed() const { return !isAbandoned() && !isConflicted() && !isConfirmed(); }
|
||||
bool isUnconfirmed() const { return !isAbandoned() && !isBlockConflicted() && !isConfirmed(); }
|
||||
bool isConfirmed() const { return state<TxStateConfirmed>(); }
|
||||
const Txid& GetHash() const LIFETIMEBOUND { return tx->GetHash(); }
|
||||
const Wtxid& GetWitnessHash() const LIFETIMEBOUND { return tx->GetWitnessHash(); }
|
||||
|
|
|
@ -1197,7 +1197,7 @@ bool CWallet::LoadToWallet(const uint256& hash, const UpdateWalletTxFn& fill_wtx
|
|||
auto it = mapWallet.find(txin.prevout.hash);
|
||||
if (it != mapWallet.end()) {
|
||||
CWalletTx& prevtx = it->second;
|
||||
if (auto* prev = prevtx.state<TxStateConflicted>()) {
|
||||
if (auto* prev = prevtx.state<TxStateBlockConflicted>()) {
|
||||
MarkConflicted(prev->conflicting_block_hash, prev->conflicting_block_height, wtx.GetHash());
|
||||
}
|
||||
}
|
||||
|
@ -1309,7 +1309,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
|
|||
assert(!wtx.isConfirmed());
|
||||
assert(!wtx.InMempool());
|
||||
// If already conflicted or abandoned, no need to set abandoned
|
||||
if (!wtx.isConflicted() && !wtx.isAbandoned()) {
|
||||
if (!wtx.isBlockConflicted() && !wtx.isAbandoned()) {
|
||||
wtx.m_state = TxStateInactive{/*abandoned=*/true};
|
||||
return TxUpdate::NOTIFY_CHANGED;
|
||||
}
|
||||
|
@ -1346,7 +1346,7 @@ void CWallet::MarkConflicted(const uint256& hashBlock, int conflicting_height, c
|
|||
if (conflictconfirms < GetTxDepthInMainChain(wtx)) {
|
||||
// Block is 'more conflicted' than current confirm; update.
|
||||
// Mark transaction as conflicted with this block.
|
||||
wtx.m_state = TxStateConflicted{hashBlock, conflicting_height};
|
||||
wtx.m_state = TxStateBlockConflicted{hashBlock, conflicting_height};
|
||||
return TxUpdate::CHANGED;
|
||||
}
|
||||
return TxUpdate::UNCHANGED;
|
||||
|
@ -1506,11 +1506,11 @@ void CWallet::blockDisconnected(const interfaces::BlockInfo& block)
|
|||
for (TxSpends::const_iterator _it = range.first; _it != range.second; ++_it) {
|
||||
CWalletTx& wtx = mapWallet.find(_it->second)->second;
|
||||
|
||||
if (!wtx.isConflicted()) continue;
|
||||
if (!wtx.isBlockConflicted()) continue;
|
||||
|
||||
auto try_updating_state = [&](CWalletTx& tx) {
|
||||
if (!tx.isConflicted()) return TxUpdate::UNCHANGED;
|
||||
if (tx.state<TxStateConflicted>()->conflicting_block_height >= disconnect_height) {
|
||||
if (!tx.isBlockConflicted()) return TxUpdate::UNCHANGED;
|
||||
if (tx.state<TxStateBlockConflicted>()->conflicting_block_height >= disconnect_height) {
|
||||
tx.m_state = TxStateInactive{};
|
||||
return TxUpdate::CHANGED;
|
||||
}
|
||||
|
@ -2725,7 +2725,7 @@ unsigned int CWallet::ComputeTimeSmart(const CWalletTx& wtx, bool rescanning_old
|
|||
std::optional<uint256> block_hash;
|
||||
if (auto* conf = wtx.state<TxStateConfirmed>()) {
|
||||
block_hash = conf->confirmed_block_hash;
|
||||
} else if (auto* conf = wtx.state<TxStateConflicted>()) {
|
||||
} else if (auto* conf = wtx.state<TxStateBlockConflicted>()) {
|
||||
block_hash = conf->conflicting_block_hash;
|
||||
}
|
||||
|
||||
|
@ -3315,7 +3315,7 @@ int CWallet::GetTxDepthInMainChain(const CWalletTx& wtx) const
|
|||
if (auto* conf = wtx.state<TxStateConfirmed>()) {
|
||||
assert(conf->confirmed_block_height >= 0);
|
||||
return GetLastBlockHeight() - conf->confirmed_block_height + 1;
|
||||
} else if (auto* conf = wtx.state<TxStateConflicted>()) {
|
||||
} else if (auto* conf = wtx.state<TxStateBlockConflicted>()) {
|
||||
assert(conf->conflicting_block_height >= 0);
|
||||
return -1 * (GetLastBlockHeight() - conf->conflicting_block_height + 1);
|
||||
} else {
|
||||
|
|
Loading…
Add table
Reference in a new issue