Skip to content

Commit

Permalink
Minor refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
prasannavl committed Oct 24, 2023
1 parent 8325240 commit 6d354b0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1214,11 +1214,11 @@ void ThreadStaker::operator()(std::vector<ThreadStaker::Args> args, CChainParams
LogPrintCategoryOrThreadThrottled(BCLog::STAKING, "no_kernel_found", 1000 * 60 * 10, "ThreadStaker: (%s) Staked, but no kernel found yet.\n", operatorName);
}
} catch (const std::runtime_error& e) {
LogPrintf("ThreadStaker: (%s) runtime error: %s failure count: %d\n", e.what(), operatorName, nPastFailures);
LogPrintf("ThreadStaker: (%s) runtime error: %s, nPastFailures: %d\n", e.what(), operatorName, nPastFailures);

if (!nPastFailures) {
LOCK2(cs_main, mempool.cs);
mempool.rebuildCustomCSView();
mempool.rebuildViews();
} else {
// Could be failed TX in mempool, wipe mempool and allow loop to continue.
LOCK(cs_main);
Expand Down
18 changes: 11 additions & 7 deletions src/txmempool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -645,7 +645,7 @@ void CTxMemPool::removeForBlock(const std::vector<CTransactionRef>& vtx, unsigne
blockSinceLastRollingFeeBump = true;
}

void CTxMemPool::rebuildCustomCSView() {
void CTxMemPool::rebuildViews() {
if (!pcustomcsview) {
return;
}
Expand Down Expand Up @@ -683,7 +683,7 @@ void CTxMemPool::clear()
LOCK(cs);
_clear();
acview.reset();
rebuildCustomCSView();
rebuildViews();
}

static void CheckInputsAndUpdateCoins(const CTransaction& tx, CCoinsViewCache& mempoolDuplicate, CCustomCSView& mnviewDuplicate, const int64_t spendheight, const CChainParams& chainparams)
Expand Down Expand Up @@ -1244,18 +1244,22 @@ void CTxMemPool::rebuildAccountsView(int height, const CCoinsViewCache& coinsCac
for (auto it = txsByEntryTime.begin(); it != txsByEntryTime.end(); ++it) {
CValidationState state;
const auto& tx = it->GetTx();
if (!Consensus::CheckTxInputs(tx, state, coinsCache, viewDuplicate, height, txfee, Params())) {
LogPrintf("%s: Remove conflicting TX: %s\n", __func__, tx.GetHash().GetHex());
auto removeConflict = [&it](const indexed_transaction_set& mapTx, CTxMemPool::setEntries& staged,
std::vector<CTransactionRef>& vtx, const CTransaction& tx) {
LogPrint(BCLog::MEMPOOL, "mempool: Remove conflicting TX: %s (cause: accountsView)\n", tx.GetHash().GetHex());
staged.insert(mapTx.project<0>(it));
vtx.push_back(it->GetSharedTx());
};

if (!Consensus::CheckTxInputs(tx, state, coinsCache, viewDuplicate, height, txfee, Params())) {
removeConflict(mapTx, staged, vtx, tx);
continue;
}

std::shared_ptr<CScopedTemplate> evmTemplate{};
auto res = ApplyCustomTx(viewDuplicate, coinsCache, tx, consensus, height, 0, nullptr, 0, evmTemplate, isEvmEnabledForBlock, true);
if (!res && (res.code & CustomTxErrCodes::Fatal)) {
LogPrintf("%s: Remove conflicting custom TX: %s\n", __func__, tx.GetHash().GetHex());
staged.insert(mapTx.project<0>(it));
vtx.push_back(it->GetSharedTx());
removeConflict(mapTx, staged, vtx, tx);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/txmempool.h
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ class CTxMemPool
boost::signals2::signal<void (CTransactionRef, MemPoolRemovalReason)> NotifyEntryRemoved;

CCustomCSView& accountsView();
void rebuildCustomCSView();
void rebuildViews();
void rebuildAccountsView(int height, const CCoinsViewCache& coinsCache);
void setAccountViewDirty();
bool getAccountViewDirty() const;
Expand Down

0 comments on commit 6d354b0

Please sign in to comment.