rolled back BlockUntilSyncedToCurrentChain
This commit is contained in:
parent
a31300f8f9
commit
86b9c279d9
6 changed files with 11 additions and 16 deletions
|
@ -347,17 +347,16 @@ public:
|
|||
{
|
||||
return MakeUnique<NotificationsHandlerImpl>(*this, notifications);
|
||||
}
|
||||
bool waitForNotificationsIfTipIsNotSame(const uint256& tip) override
|
||||
void waitForNotificationsIfTipIsNotSame(const uint256& tip) override
|
||||
{
|
||||
if (!tip.IsNull()) {
|
||||
LOCK(::cs_main);
|
||||
auto chainTip = ::ChainActive().Tip();
|
||||
if (tip == chainTip->GetBlockHash()) return true;
|
||||
if (tip == chainTip->GetBlockHash()) return;
|
||||
CBlockIndex* block = LookupBlockIndex(tip);
|
||||
if (block && block->GetAncestor(::ChainActive().Height()) == chainTip) return true;
|
||||
if (block && block->GetAncestor(::ChainActive().Height()) == chainTip) return;
|
||||
}
|
||||
SyncWithValidationInterfaceQueue();
|
||||
return false;
|
||||
}
|
||||
std::unique_ptr<Handler> handleRpc(const CRPCCommand& command) override
|
||||
{
|
||||
|
|
|
@ -230,7 +230,7 @@ public:
|
|||
//! Wait for pending notifications to be processed unless block hash points to the current
|
||||
//! chain tip, or to a possible descendant of the current chain tip that isn't currently
|
||||
//! connected.
|
||||
virtual bool waitForNotificationsIfTipIsNotSame(const uint256& tip) = 0;
|
||||
virtual void waitForNotificationsIfTipIsNotSame(const uint256& tip) = 0;
|
||||
|
||||
//! Register handler for RPC. Command is not copied, so reference
|
||||
//! needs to remain valid until Handler is disconnected.
|
||||
|
|
|
@ -25,7 +25,7 @@ enum isminetype : unsigned int
|
|||
ISMINE_USED = 1 << 4,
|
||||
ISMINE_STAKE = ISMINE_CLAIM | ISMINE_SUPPORT,
|
||||
ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE,
|
||||
ISMINE_ALL_USED = ISMINE_ALL | ISMINE_USED | ISMINE_STAKE,
|
||||
ISMINE_ALL_USED = ISMINE_ALL | ISMINE_USED,
|
||||
ISMINE_ENUM_ELEMENTS,
|
||||
};
|
||||
/** used for bitflags of isminetype */
|
||||
|
|
|
@ -2228,7 +2228,8 @@ static UniValue listsinceblock(const JSONRPCRequest& request)
|
|||
for (const auto& pairWtx : pwallet->mapWallet) {
|
||||
CWalletTx tx = pairWtx.second;
|
||||
|
||||
if (depth == -1 || abs(tx.GetDepthInMainChain(*locked_chain)) < depth) {
|
||||
auto dmc = tx.GetDepthInMainChain(*locked_chain);
|
||||
if (depth == -1 || (dmc >= 0 && dmc < depth)) {
|
||||
ListTransactions(*locked_chain, pwallet, tx, 0, true, transactions, filter, nullptr /* filter_label */);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ static int64_t AddTx(CWallet& wallet, uint32_t lockTime, int64_t mockTime, int64
|
|||
LOCK(wallet.cs_wallet);
|
||||
// If transaction is already in map, to avoid inconsistencies, unconfirmation
|
||||
// is needed before confirm again with different block.
|
||||
std::map<uint256, CWalletTx>::iterator it = wallet.mapWallet.find(wtx.GetHash());
|
||||
auto it = wallet.mapWallet.find(wtx.GetHash());
|
||||
if (it != wallet.mapWallet.end()) {
|
||||
wtx.setUnconfirmed();
|
||||
wallet.AddToWallet(wtx);
|
||||
|
|
|
@ -1498,13 +1498,8 @@ void CWallet::BlockUntilSyncedToCurrentChain() {
|
|||
// ::ChainActive().Tip(), otherwise put a callback in the validation interface queue and wait
|
||||
// for the queue to drain enough to execute it (indicating we are caught up
|
||||
// at least with the time we entered this function).
|
||||
auto lastProcessedBlock = [this]() -> uint256 {
|
||||
return WITH_LOCK(cs_wallet, return m_last_block_processed);
|
||||
};
|
||||
bool tipIsSame = false;
|
||||
uint256 last_block_hash;
|
||||
while (!tipIsSame && !(last_block_hash = lastProcessedBlock()).IsNull())
|
||||
tipIsSame = chain().waitForNotificationsIfTipIsNotSame(last_block_hash);
|
||||
uint256 last_block_hash = WITH_LOCK(cs_wallet, return m_last_block_processed);
|
||||
chain().waitForNotificationsIfTipIsNotSame(last_block_hash);
|
||||
}
|
||||
|
||||
|
||||
|
@ -2444,7 +2439,7 @@ void CWallet::ResendWalletTransactions()
|
|||
LOCK(cs_wallet);
|
||||
|
||||
// Relay transactions
|
||||
for (std::pair<const uint256, CWalletTx>& item : mapWallet) {
|
||||
for (auto& item : mapWallet) {
|
||||
CWalletTx& wtx = item.second;
|
||||
// Attempt to rebroadcast all txes more than 5 minutes older than
|
||||
// the last block. SubmitMemoryPoolAndRelay() will not rebroadcast
|
||||
|
|
Loading…
Reference in a new issue