Skip to content

Commit ffe5ff1

Browse files
committed
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-
1 parent 180973a commit ffe5ff1

File tree

4 files changed

+18
-18
lines changed

4 files changed

+18
-18
lines changed

src/wallet/interfaces.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ WalletTxStatus MakeWalletTxStatus(const CWallet& wallet, const CWalletTx& wtx)
9292
WalletTxStatus result;
9393
result.block_height =
9494
wtx.state<TxStateConfirmed>() ? wtx.state<TxStateConfirmed>()->confirmed_block_height :
95-
wtx.state<TxStateConflicted>() ? wtx.state<TxStateConflicted>()->conflicting_block_height :
95+
wtx.state<TxStateBlockConflicted>() ? wtx.state<TxStateBlockConflicted>()->conflicting_block_height :
9696
std::numeric_limits<int>::max();
9797
result.blocks_to_maturity = wallet.GetTxBlocksToMaturity(wtx);
9898
result.depth_in_main_chain = wallet.GetTxDepthInMainChain(wtx);

src/wallet/transaction.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void CWalletTx::updateState(interfaces::Chain& chain)
4545
};
4646
if (auto* conf = state<TxStateConfirmed>()) {
4747
lookup_block(conf->confirmed_block_hash, conf->confirmed_block_height, m_state);
48-
} else if (auto* conf = state<TxStateConflicted>()) {
48+
} else if (auto* conf = state<TxStateBlockConflicted>()) {
4949
lookup_block(conf->conflicting_block_hash, conf->conflicting_block_height, m_state);
5050
}
5151
}

src/wallet/transaction.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,11 @@ struct TxStateInMempool {
4343
};
4444

4545
//! State of rejected transaction that conflicts with a confirmed block.
46-
struct TxStateConflicted {
46+
struct TxStateBlockConflicted {
4747
uint256 conflicting_block_hash;
4848
int conflicting_block_height;
4949

50-
explicit TxStateConflicted(const uint256& block_hash, int height) : conflicting_block_hash(block_hash), conflicting_block_height(height) {}
50+
explicit TxStateBlockConflicted(const uint256& block_hash, int height) : conflicting_block_hash(block_hash), conflicting_block_height(height) {}
5151
std::string toString() const { return strprintf("Conflicted (block=%s, height=%i)", conflicting_block_hash.ToString(), conflicting_block_height); }
5252
};
5353

@@ -75,7 +75,7 @@ struct TxStateUnrecognized {
7575
};
7676

7777
//! All possible CWalletTx states
78-
using TxState = std::variant<TxStateConfirmed, TxStateInMempool, TxStateConflicted, TxStateInactive, TxStateUnrecognized>;
78+
using TxState = std::variant<TxStateConfirmed, TxStateInMempool, TxStateBlockConflicted, TxStateInactive, TxStateUnrecognized>;
7979

8080
//! Subset of states transaction sync logic is implemented to handle.
8181
using SyncTxState = std::variant<TxStateConfirmed, TxStateInMempool, TxStateInactive>;
@@ -90,7 +90,7 @@ static inline TxState TxStateInterpretSerialized(TxStateUnrecognized data)
9090
} else if (data.index >= 0) {
9191
return TxStateConfirmed{data.block_hash, /*height=*/-1, data.index};
9292
} else if (data.index == -1) {
93-
return TxStateConflicted{data.block_hash, /*height=*/-1};
93+
return TxStateBlockConflicted{data.block_hash, /*height=*/-1};
9494
}
9595
return data;
9696
}
@@ -102,7 +102,7 @@ static inline uint256 TxStateSerializedBlockHash(const TxState& state)
102102
[](const TxStateInactive& inactive) { return inactive.abandoned ? uint256::ONE : uint256::ZERO; },
103103
[](const TxStateInMempool& in_mempool) { return uint256::ZERO; },
104104
[](const TxStateConfirmed& confirmed) { return confirmed.confirmed_block_hash; },
105-
[](const TxStateConflicted& conflicted) { return conflicted.conflicting_block_hash; },
105+
[](const TxStateBlockConflicted& conflicted) { return conflicted.conflicting_block_hash; },
106106
[](const TxStateUnrecognized& unrecognized) { return unrecognized.block_hash; }
107107
}, state);
108108
}
@@ -114,7 +114,7 @@ static inline int TxStateSerializedIndex(const TxState& state)
114114
[](const TxStateInactive& inactive) { return inactive.abandoned ? -1 : 0; },
115115
[](const TxStateInMempool& in_mempool) { return 0; },
116116
[](const TxStateConfirmed& confirmed) { return confirmed.position_in_block; },
117-
[](const TxStateConflicted& conflicted) { return -1; },
117+
[](const TxStateBlockConflicted& conflicted) { return -1; },
118118
[](const TxStateUnrecognized& unrecognized) { return unrecognized.index; }
119119
}, state);
120120
}
@@ -335,9 +335,9 @@ class CWalletTx
335335
void updateState(interfaces::Chain& chain);
336336

337337
bool isAbandoned() const { return state<TxStateInactive>() && state<TxStateInactive>()->abandoned; }
338-
bool isConflicted() const { return state<TxStateConflicted>(); }
338+
bool isBlockConflicted() const { return state<TxStateBlockConflicted>(); }
339339
bool isInactive() const { return state<TxStateInactive>(); }
340-
bool isUnconfirmed() const { return !isAbandoned() && !isConflicted() && !isConfirmed(); }
340+
bool isUnconfirmed() const { return !isAbandoned() && !isBlockConflicted() && !isConfirmed(); }
341341
bool isConfirmed() const { return state<TxStateConfirmed>(); }
342342
const Txid& GetHash() const LIFETIMEBOUND { return tx->GetHash(); }
343343
const Wtxid& GetWitnessHash() const LIFETIMEBOUND { return tx->GetWitnessHash(); }

src/wallet/wallet.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -1197,7 +1197,7 @@ bool CWallet::LoadToWallet(const uint256& hash, const UpdateWalletTxFn& fill_wtx
11971197
auto it = mapWallet.find(txin.prevout.hash);
11981198
if (it != mapWallet.end()) {
11991199
CWalletTx& prevtx = it->second;
1200-
if (auto* prev = prevtx.state<TxStateConflicted>()) {
1200+
if (auto* prev = prevtx.state<TxStateBlockConflicted>()) {
12011201
MarkConflicted(prev->conflicting_block_hash, prev->conflicting_block_height, wtx.GetHash());
12021202
}
12031203
}
@@ -1309,7 +1309,7 @@ bool CWallet::AbandonTransaction(const uint256& hashTx)
13091309
assert(!wtx.isConfirmed());
13101310
assert(!wtx.InMempool());
13111311
// If already conflicted or abandoned, no need to set abandoned
1312-
if (!wtx.isConflicted() && !wtx.isAbandoned()) {
1312+
if (!wtx.isBlockConflicted() && !wtx.isAbandoned()) {
13131313
wtx.m_state = TxStateInactive{/*abandoned=*/true};
13141314
return TxUpdate::NOTIFY_CHANGED;
13151315
}
@@ -1346,7 +1346,7 @@ void CWallet::MarkConflicted(const uint256& hashBlock, int conflicting_height, c
13461346
if (conflictconfirms < GetTxDepthInMainChain(wtx)) {
13471347
// Block is 'more conflicted' than current confirm; update.
13481348
// Mark transaction as conflicted with this block.
1349-
wtx.m_state = TxStateConflicted{hashBlock, conflicting_height};
1349+
wtx.m_state = TxStateBlockConflicted{hashBlock, conflicting_height};
13501350
return TxUpdate::CHANGED;
13511351
}
13521352
return TxUpdate::UNCHANGED;
@@ -1506,11 +1506,11 @@ void CWallet::blockDisconnected(const interfaces::BlockInfo& block)
15061506
for (TxSpends::const_iterator _it = range.first; _it != range.second; ++_it) {
15071507
CWalletTx& wtx = mapWallet.find(_it->second)->second;
15081508

1509-
if (!wtx.isConflicted()) continue;
1509+
if (!wtx.isBlockConflicted()) continue;
15101510

15111511
auto try_updating_state = [&](CWalletTx& tx) {
1512-
if (!tx.isConflicted()) return TxUpdate::UNCHANGED;
1513-
if (tx.state<TxStateConflicted>()->conflicting_block_height >= disconnect_height) {
1512+
if (!tx.isBlockConflicted()) return TxUpdate::UNCHANGED;
1513+
if (tx.state<TxStateBlockConflicted>()->conflicting_block_height >= disconnect_height) {
15141514
tx.m_state = TxStateInactive{};
15151515
return TxUpdate::CHANGED;
15161516
}
@@ -2725,7 +2725,7 @@ unsigned int CWallet::ComputeTimeSmart(const CWalletTx& wtx, bool rescanning_old
27252725
std::optional<uint256> block_hash;
27262726
if (auto* conf = wtx.state<TxStateConfirmed>()) {
27272727
block_hash = conf->confirmed_block_hash;
2728-
} else if (auto* conf = wtx.state<TxStateConflicted>()) {
2728+
} else if (auto* conf = wtx.state<TxStateBlockConflicted>()) {
27292729
block_hash = conf->conflicting_block_hash;
27302730
}
27312731

@@ -3315,7 +3315,7 @@ int CWallet::GetTxDepthInMainChain(const CWalletTx& wtx) const
33153315
if (auto* conf = wtx.state<TxStateConfirmed>()) {
33163316
assert(conf->confirmed_block_height >= 0);
33173317
return GetLastBlockHeight() - conf->confirmed_block_height + 1;
3318-
} else if (auto* conf = wtx.state<TxStateConflicted>()) {
3318+
} else if (auto* conf = wtx.state<TxStateBlockConflicted>()) {
33193319
assert(conf->conflicting_block_height >= 0);
33203320
return -1 * (GetLastBlockHeight() - conf->conflicting_block_height + 1);
33213321
} else {

0 commit comments

Comments
 (0)