made a new "claims" logging category (off by default)
This commit is contained in:
parent
6259378466
commit
328ee12e8b
7 changed files with 73 additions and 51 deletions
|
@ -98,7 +98,7 @@ bool DeserializeFileDB(const fs::path& path, Data& data)
|
|||
FILE *file = fsbridge::fopen(path, "rb");
|
||||
CAutoFile filein(file, SER_DISK, CLIENT_VERSION);
|
||||
if (filein.IsNull())
|
||||
return error("%s: Failed to open file %s", __func__, path.string());
|
||||
return false;
|
||||
|
||||
return DeserializeDB(filein, data);
|
||||
}
|
||||
|
|
|
@ -38,32 +38,37 @@ CClaimScriptUndoAddOp::CClaimScriptUndoAddOp(const COutPoint& point, int nHeight
|
|||
bool CClaimScriptUndoAddOp::claimName(CClaimTrieCache& trieCache, const std::string& name)
|
||||
{
|
||||
auto claimId = ClaimIdHash(point.hash, point.n);
|
||||
LogPrintf("--- [%lu]: OP_CLAIM_NAME \"%s\" with claimId %s and tx prevout %s at index %d\n", nHeight, name, claimId.GetHex(), point.hash.ToString(), point.n);
|
||||
LogPrint(BCLog::CLAIMS, "--- [%lu]: OP_CLAIM_NAME \"%s\" with claimId %s and tx prevout %s at index %d\n", nHeight, name, claimId.GetHex(), point.hash.ToString(), point.n);
|
||||
return undoAddClaim(trieCache, name, claimId);
|
||||
}
|
||||
|
||||
bool CClaimScriptUndoAddOp::updateClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId)
|
||||
{
|
||||
LogPrintf("--- [%lu]: OP_UPDATE_CLAIM \"%s\" with claimId %s and tx prevout %s at index %d\n", nHeight, name, claimId.GetHex(), point.hash.ToString(), point.n);
|
||||
LogPrint(BCLog::CLAIMS, "--- [%lu]: OP_UPDATE_CLAIM \"%s\" with claimId %s and tx prevout %s at index %d\n", nHeight, name, claimId.GetHex(), point.hash.ToString(), point.n);
|
||||
return undoAddClaim(trieCache, name, claimId);
|
||||
}
|
||||
|
||||
bool CClaimScriptUndoAddOp::undoAddClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId)
|
||||
{
|
||||
LogPrintf("%s: (txid: %s, nOut: %d) Removing %s, claimId: %s, from the claim trie due to block disconnect\n", __func__, point.hash.ToString(), point.n, name, claimId.ToString());
|
||||
LogPrint(BCLog::CLAIMS, "%s: (txid: %s, nOut: %d) Removing %s, claimId: %s, from the claim trie due to block disconnect\n", __func__, point.hash.ToString(), point.n, name, claimId.ToString());
|
||||
bool res = trieCache.undoAddClaim(name, point, nHeight);
|
||||
if (!res)
|
||||
LogPrintf("%s: Removing fails\n", __func__);
|
||||
LogPrint(BCLog::CLAIMS, "%s: Removing claim fails\n", __func__);
|
||||
return res;
|
||||
}
|
||||
|
||||
bool CClaimScriptUndoAddOp::supportClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId)
|
||||
{
|
||||
LogPrintf("--- [%lu]: OP_SUPPORT_CLAIM \"%s\" with claimId %s and tx prevout %s at index %d\n", nHeight, name, claimId.GetHex(), point.hash.ToString(), point.n);
|
||||
LogPrintf("%s: (txid: %s, nOut: %d) Removing support for %s, claimId: %s, from the claim trie due to block disconnect\n", __func__, point.hash.ToString(), point.n, name, claimId.ToString());
|
||||
if (LogAcceptCategory(BCLog::CLAIMS)) {
|
||||
LogPrintf("--- [%lu]: OP_SUPPORT_CLAIM \"%s\" with claimId %s and tx prevout %s at index %d\n", nHeight, name,
|
||||
claimId.GetHex(), point.hash.ToString(), point.n);
|
||||
LogPrintf(
|
||||
"%s: (txid: %s, nOut: %d) Removing support for %s, claimId: %s, from the claim trie due to block disconnect\n",
|
||||
__func__, point.hash.ToString(), point.n, name, claimId.ToString());
|
||||
}
|
||||
bool res = trieCache.undoAddSupport(name, point, nHeight);
|
||||
if (!res)
|
||||
LogPrintf("%s: Removing support fails\n", __func__);
|
||||
LogPrint(BCLog::CLAIMS, "%s: Removing support fails\n", __func__);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -75,32 +80,36 @@ CClaimScriptSpendOp::CClaimScriptSpendOp(const COutPoint& point, int nHeight, in
|
|||
bool CClaimScriptSpendOp::claimName(CClaimTrieCache& trieCache, const std::string& name)
|
||||
{
|
||||
auto claimId = ClaimIdHash(point.hash, point.n);
|
||||
LogPrintf("+++ [%lu]: OP_CLAIM_NAME \"%s\" with claimId %s and tx prevout %s at index %d\n", nHeight, name, claimId.GetHex(), point.hash.ToString(), point.n);
|
||||
LogPrint(BCLog::CLAIMS, "+++ [%lu]: OP_CLAIM_NAME \"%s\" with claimId %s and tx prevout %s at index %d\n", nHeight, name, claimId.GetHex(), point.hash.ToString(), point.n);
|
||||
return spendClaim(trieCache, name, claimId);
|
||||
}
|
||||
|
||||
bool CClaimScriptSpendOp::updateClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId)
|
||||
{
|
||||
LogPrintf("+++ [%lu]: OP_UPDATE_CLAIM \"%s\" with claimId %s and tx prevout %s at index %d\n", nHeight, name, claimId.GetHex(), point.hash.ToString(), point.n);
|
||||
LogPrint(BCLog::CLAIMS, "+++ [%lu]: OP_UPDATE_CLAIM \"%s\" with claimId %s and tx prevout %s at index %d\n", nHeight, name, claimId.GetHex(), point.hash.ToString(), point.n);
|
||||
return spendClaim(trieCache, name, claimId);
|
||||
}
|
||||
|
||||
bool CClaimScriptSpendOp::spendClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId)
|
||||
{
|
||||
LogPrintf("%s: (txid: %s, nOut: %d) Removing %s, claimId: %s, from the claim trie\n", __func__, point.hash.ToString(), point.n, name, claimId.ToString());
|
||||
LogPrint(BCLog::CLAIMS, "%s: (txid: %s, nOut: %d) Removing %s, claimId: %s, from the claim trie\n", __func__, point.hash.ToString(), point.n, name, claimId.ToString());
|
||||
bool res = trieCache.spendClaim(name, point, nHeight, nValidHeight);
|
||||
if (!res)
|
||||
LogPrintf("%s: Removing fails\n", __func__);
|
||||
LogPrint(BCLog::CLAIMS, "%s: Removing fails\n", __func__);
|
||||
return res;
|
||||
}
|
||||
|
||||
bool CClaimScriptSpendOp::supportClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId)
|
||||
{
|
||||
LogPrintf("+++ [%lu]: OP_SUPPORT_CLAIM \"%s\" with claimId %s and tx prevout %s at index %d\n", nHeight, name, claimId.GetHex(), point.hash.ToString(), point.n);
|
||||
LogPrintf("%s: (txid: %s, nOut: %d) Restoring support for %s, claimId: %s, to the claim trie\n", __func__, point.hash.ToString(), point.n, name, claimId.ToString());
|
||||
if (LogAcceptCategory(BCLog::CLAIMS)) {
|
||||
LogPrintf("+++ [%lu]: OP_SUPPORT_CLAIM \"%s\" with claimId %s and tx prevout %s at index %d\n", nHeight, name,
|
||||
claimId.GetHex(), point.hash.ToString(), point.n);
|
||||
LogPrintf("%s: (txid: %s, nOut: %d) Restoring support for %s, claimId: %s, to the claim trie\n", __func__,
|
||||
point.hash.ToString(), point.n, name, claimId.ToString());
|
||||
}
|
||||
bool res = trieCache.spendSupport(name, point, nHeight, nValidHeight);
|
||||
if (!res)
|
||||
LogPrintf("%s: Removing support fails\n", __func__);
|
||||
LogPrint(BCLog::CLAIMS, "%s: Removing support fails\n", __func__);
|
||||
return res;
|
||||
}
|
||||
|
||||
|
@ -121,13 +130,13 @@ bool CClaimScriptUndoSpendOp::updateClaim(CClaimTrieCache& trieCache, const std:
|
|||
|
||||
bool CClaimScriptUndoSpendOp::undoSpendClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId)
|
||||
{
|
||||
LogPrintf("%s: (txid: %s, nOut: %d) Restoring %s, claimId: %s, to the claim trie due to block disconnect\n", __func__, point.hash.ToString(), point.n, name, claimId.ToString());
|
||||
LogPrint(BCLog::CLAIMS, "%s: (txid: %s, nOut: %d) Restoring %s, claimId: %s, to the claim trie due to block disconnect\n", __func__, point.hash.ToString(), point.n, name, claimId.ToString());
|
||||
return trieCache.undoSpendClaim(name, point, claimId, nValue, nHeight, nValidHeight);
|
||||
}
|
||||
|
||||
bool CClaimScriptUndoSpendOp::supportClaim(CClaimTrieCache& trieCache, const std::string& name, const uint160& claimId)
|
||||
{
|
||||
LogPrintf("%s: (txid: %s, nOut: %d) Restoring support for %s, claimId: %s, to the claim trie due to block disconnect\n", __func__, point.hash.ToString(), point.n, name, claimId.ToString());
|
||||
LogPrint(BCLog::CLAIMS, "%s: (txid: %s, nOut: %d) Restoring support for %s, claimId: %s, to the claim trie due to block disconnect\n", __func__, point.hash.ToString(), point.n, name, claimId.ToString());
|
||||
return trieCache.undoSpendSupport(name, point, claimId, nValue, nHeight, nValidHeight);
|
||||
}
|
||||
|
||||
|
|
|
@ -92,10 +92,12 @@ bool CClaimTrieData::removeClaim(const COutPoint& outPoint, CClaimValue& claim)
|
|||
if (eraseOutPoint(claims, outPoint, &claim))
|
||||
return true;
|
||||
|
||||
LogPrintf("CClaimTrieData::%s() : asked to remove a claim that doesn't exist\n", __func__);
|
||||
LogPrintf("CClaimTrieData::%s() : claims that do exist:\n", __func__);
|
||||
for (auto& iClaim : claims)
|
||||
LogPrintf("\t%s\n", iClaim.outPoint.ToString());
|
||||
if (LogAcceptCategory(BCLog::CLAIMS)) {
|
||||
LogPrintf("CClaimTrieData::%s() : asked to remove a claim that doesn't exist\n", __func__);
|
||||
LogPrintf("CClaimTrieData::%s() : claims that do exist:\n", __func__);
|
||||
for (auto& iClaim : claims)
|
||||
LogPrintf("\t%s\n", iClaim.outPoint.ToString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -445,7 +447,6 @@ bool CClaimTrieCacheBase::getClaimById(const uint160& claimId, std::string& name
|
|||
claim = element.claim;
|
||||
return true;
|
||||
}
|
||||
LogPrintf("%s: ClaimIndex[%s] returned unmatched claimId %s when looking for %s\n", __func__, claimId.GetHex(), element.claim.claimId.GetHex(), name);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -513,7 +514,7 @@ bool CClaimTrieCacheBase::flush()
|
|||
|
||||
base->nNextHeight = nNextHeight;
|
||||
if (!nodesToAddOrUpdate.empty())
|
||||
LogPrintf("Cache size: %zu from base size: %zu on block %d\n", nodesToAddOrUpdate.height(), base->height(), nNextHeight);
|
||||
LogPrint(BCLog::CLAIMS, "Cache size: %zu from base size: %zu on block %d\n", nodesToAddOrUpdate.height(), base->height(), nNextHeight);
|
||||
auto ret = base->db->WriteBatch(batch);
|
||||
clear();
|
||||
return ret;
|
||||
|
@ -711,7 +712,7 @@ bool CClaimTrieCacheBase::removeClaimFromTrie(const std::string& name, const COu
|
|||
auto it = cacheData(name, false);
|
||||
|
||||
if (!it || !it->removeClaim(outPoint, claim)) {
|
||||
LogPrintf("%s: Removing a claim was unsuccessful. name = %s, txhash = %s, nOut = %d", __func__, name, outPoint.hash.GetHex(), outPoint.n);
|
||||
LogPrint(BCLog::CLAIMS, "%s: Removing a claim was unsuccessful. name = %s, txhash = %s, nOut = %d", __func__, name, outPoint.hash.GetHex(), outPoint.n);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -755,13 +756,13 @@ bool CClaimTrieCacheBase::addClaim(const std::string& name, const COutPoint& out
|
|||
{
|
||||
auto claim = add<CClaimValue>(name, outPoint, claimId, nAmount, nHeight);
|
||||
claimsToAddToByIdIndex.emplace_back(name, claim);
|
||||
LogPrintf("%s: name: %s, txhash: %s, nOut: %d, claimId: %s, nAmount: %d, nHeight: %d, nValidHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, claimId.GetHex(), nAmount, nHeight, claim.nValidAtHeight);
|
||||
LogPrint(BCLog::CLAIMS, "%s: name: %s, txhash: %s, nOut: %d, claimId: %s, nAmount: %d, nHeight: %d, nValidHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, claimId.GetHex(), nAmount, nHeight, claim.nValidAtHeight);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CClaimTrieCacheBase::addSupport(const std::string& name, const COutPoint& outPoint, CAmount nAmount, const uint160& supportedClaimId, int nHeight)
|
||||
{
|
||||
LogPrintf("%s: name: %s, txhash: %s, nOut: %d, nAmount: %d, supportedClaimId: %s, nHeight: %d, nNextHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nAmount, supportedClaimId.GetHex(), nHeight, nNextHeight);
|
||||
LogPrint(BCLog::CLAIMS, "%s: name: %s, txhash: %s, nOut: %d, nAmount: %d, supportedClaimId: %s, nHeight: %d, nNextHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nAmount, supportedClaimId.GetHex(), nHeight, nNextHeight);
|
||||
add<CSupportValue>(name, outPoint, supportedClaimId, nAmount, nHeight);
|
||||
return true;
|
||||
}
|
||||
|
@ -813,7 +814,7 @@ bool CClaimTrieCacheBase::undoSpend(const std::string& name, const T& value, int
|
|||
|
||||
bool CClaimTrieCacheBase::undoSpendClaim(const std::string& name, const COutPoint& outPoint, const uint160& claimId, CAmount nAmount, int nHeight, int nValidAtHeight)
|
||||
{
|
||||
LogPrintf("%s: name: %s, txhash: %s, nOut: %d, claimId: %s, nAmount: %d, nHeight: %d, nValidAtHeight: %d, nNextHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, claimId.GetHex(), nAmount, nHeight, nValidAtHeight, nNextHeight);
|
||||
LogPrint(BCLog::CLAIMS, "%s: name: %s, txhash: %s, nOut: %d, claimId: %s, nAmount: %d, nHeight: %d, nValidAtHeight: %d, nNextHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, claimId.GetHex(), nAmount, nHeight, nValidAtHeight, nNextHeight);
|
||||
CClaimValue claim(outPoint, claimId, nAmount, nHeight, nValidAtHeight);
|
||||
claimsToAddToByIdIndex.emplace_back(name, claim);
|
||||
return undoSpend(name, claim, nValidAtHeight);
|
||||
|
@ -821,7 +822,7 @@ bool CClaimTrieCacheBase::undoSpendClaim(const std::string& name, const COutPoin
|
|||
|
||||
bool CClaimTrieCacheBase::undoSpendSupport(const std::string& name, const COutPoint& outPoint, const uint160& supportedClaimId, CAmount nAmount, int nHeight, int nValidAtHeight)
|
||||
{
|
||||
LogPrintf("%s: name: %s, txhash: %s, nOut: %d, nAmount: %d, supportedClaimId: %s, nHeight: %d, nNextHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nAmount, supportedClaimId.GetHex(), nHeight, nNextHeight);
|
||||
LogPrint(BCLog::CLAIMS, "%s: name: %s, txhash: %s, nOut: %d, nAmount: %d, supportedClaimId: %s, nHeight: %d, nNextHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nAmount, supportedClaimId.GetHex(), nHeight, nNextHeight);
|
||||
CSupportValue support(outPoint, supportedClaimId, nAmount, nHeight, nValidAtHeight);
|
||||
return undoSpend(name, support, nValidAtHeight);
|
||||
}
|
||||
|
@ -856,7 +857,7 @@ bool CClaimTrieCacheBase::undoAddClaim(const std::string& name, const COutPoint&
|
|||
|
||||
bool CClaimTrieCacheBase::undoAddSupport(const std::string& name, const COutPoint& outPoint, int nHeight)
|
||||
{
|
||||
LogPrintf("%s: name: %s, txhash: %s, nOut: %d, nHeight: %d, nNextHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nHeight, nNextHeight);
|
||||
LogPrint(BCLog::CLAIMS, "%s: name: %s, txhash: %s, nOut: %d, nHeight: %d, nNextHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nHeight, nNextHeight);
|
||||
int throwaway;
|
||||
return removeSupport(name, outPoint, nHeight, throwaway, false);
|
||||
}
|
||||
|
@ -868,7 +869,7 @@ bool CClaimTrieCacheBase::spendClaim(const std::string& name, const COutPoint& o
|
|||
|
||||
bool CClaimTrieCacheBase::spendSupport(const std::string& name, const COutPoint& outPoint, int nHeight, int& nValidAtHeight)
|
||||
{
|
||||
LogPrintf("%s: name: %s, txhash: %s, nOut: %d, nHeight: %d, nNextHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nHeight, nNextHeight);
|
||||
LogPrint(BCLog::CLAIMS, "%s: name: %s, txhash: %s, nOut: %d, nHeight: %d, nNextHeight: %d\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nHeight, nNextHeight);
|
||||
return removeSupport(name, outPoint, nHeight, nValidAtHeight, true);
|
||||
}
|
||||
|
||||
|
@ -910,7 +911,7 @@ bool CClaimTrieCacheBase::remove(T& value, const std::string& name, const COutPo
|
|||
|
||||
bool CClaimTrieCacheBase::removeClaim(const std::string& name, const COutPoint& outPoint, int nHeight, int& nValidAtHeight, bool fCheckTakeover)
|
||||
{
|
||||
LogPrintf("%s: name: %s, txhash: %s, nOut: %s, nNextHeight: %s\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nNextHeight);
|
||||
LogPrint(BCLog::CLAIMS, "%s: name: %s, txhash: %s, nOut: %s, nNextHeight: %s\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nNextHeight);
|
||||
|
||||
CClaimValue claim;
|
||||
if (remove(claim, name, outPoint, nHeight, nValidAtHeight, fCheckTakeover)) {
|
||||
|
@ -958,7 +959,7 @@ bool CClaimTrieCacheBase::removeSupportFromMap(const std::string& name, const CO
|
|||
}
|
||||
return true;
|
||||
}
|
||||
LogPrintf("CClaimTrieCacheBase::%s() : asked to remove a support that doesn't exist\n", __func__);
|
||||
LogPrint(BCLog::CLAIMS, "CClaimTrieCacheBase::%s() : asked to remove a support that doesn't exist\n", __func__);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1142,7 +1143,7 @@ bool CClaimTrieCacheBase::incrementBlock(insertUndoType& insertUndo, claimQueueR
|
|||
// not sure if this should happen above or below the above code:
|
||||
auto shouldUse = shouldUseTakeoverWorkaround(itNamesToCheck);
|
||||
if (!takeoverHappened && shouldUse)
|
||||
LogPrintf("TakeoverHeight workaround affects block: %d, name: %s, th: %d\n", nNextHeight, itNamesToCheck, ownersTakeoverHeight);
|
||||
LogPrint(BCLog::CLAIMS, "TakeoverHeight workaround affects block: %d, name: %s, th: %d\n", nNextHeight, itNamesToCheck, ownersTakeoverHeight);
|
||||
takeoverHappened |= shouldUse;
|
||||
|
||||
if (haveClaimInTrie && takeoverHappened)
|
||||
|
|
|
@ -119,6 +119,7 @@ const CLogCategoryDesc LogCategories[] =
|
|||
{BCLog::COINDB, "coindb"},
|
||||
{BCLog::QT, "qt"},
|
||||
{BCLog::LEVELDB, "leveldb"},
|
||||
{BCLog::CLAIMS, "claims"},
|
||||
{BCLog::ALL, "1"},
|
||||
{BCLog::ALL, "all"},
|
||||
};
|
||||
|
|
|
@ -53,6 +53,7 @@ namespace BCLog {
|
|||
COINDB = (1 << 18),
|
||||
QT = (1 << 19),
|
||||
LEVELDB = (1 << 20),
|
||||
CLAIMS = (1 << 30),
|
||||
ALL = ~(uint32_t)0,
|
||||
};
|
||||
|
||||
|
|
|
@ -1546,7 +1546,6 @@ DisconnectResult CChainState::DisconnectBlock(const CBlock& block, const CBlockI
|
|||
}
|
||||
for (unsigned int j = tx.vin.size(); j-- > 0;) {
|
||||
const COutPoint &out = tx.vin[j].prevout;
|
||||
/* int res = ApplyTxInUndo(std::move(txundo.vprevout[j]), txundo, view, trieCache, out); */
|
||||
int res = ApplyTxInUndo(j, txundo, view, trieCache, out);
|
||||
if (res == DISCONNECT_FAILED) return DISCONNECT_FAILED;
|
||||
fClean = fClean && res != DISCONNECT_UNCLEAN;
|
||||
|
@ -1903,7 +1902,7 @@ bool CChainState::ConnectBlock(const CBlock& block, CValidationState& state, CBl
|
|||
// post BIP34 before approximately height 486,000,000 and presumably will
|
||||
// be reset before it reaches block 1,983,702 and starts doing unnecessary
|
||||
// BIP30 checking again.
|
||||
/* assert(pindex->pprev); */
|
||||
|
||||
if (pindex->pprev)
|
||||
{
|
||||
CBlockIndex *pindexBIP34height = pindex->pprev->GetAncestor(chainparams.GetConsensus().BIP34Height);
|
||||
|
@ -2205,6 +2204,7 @@ bool static FlushStateToDisk(const CChainParams& chainparams, CValidationState &
|
|||
if (full_flush_completed) {
|
||||
// Update best block in wallet (so we can detect restored wallets).
|
||||
GetMainSignals().ChainStateFlushed(chainActive.GetLocator());
|
||||
LogPrint(BCLog::BENCH, "Finished full disk flush in %.2fms\n", (GetTimeMicros() - nLastFlush) * MILLI);
|
||||
}
|
||||
} catch (const std::runtime_error& e) {
|
||||
return AbortNode(state, std::string("System error while flushing: ") + e.what());
|
||||
|
@ -2291,14 +2291,22 @@ void static UpdateTip(const CBlockIndex *pindexNew, const CChainParams& chainPar
|
|||
DoWarning(strWarning);
|
||||
}
|
||||
}
|
||||
LogPrintf("%s: new best=%s height=%d version=0x%08x log2_work=%.8g tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo)", __func__, /* Continued */
|
||||
pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, pindexNew->nVersion,
|
||||
log(pindexNew->nChainWork.getdouble())/log(2.0), (unsigned long)pindexNew->nChainTx,
|
||||
FormatISO8601DateTime(pindexNew->GetBlockTime()),
|
||||
GuessVerificationProgress(chainParams.TxData(), pindexNew), pcoinsTip->DynamicMemoryUsage() * (1.0 / (1<<20)), pcoinsTip->GetCacheSize());
|
||||
if (!warningMessages.empty())
|
||||
LogPrintf(" warning='%s'", warningMessages); /* Continued */
|
||||
LogPrintf("\n");
|
||||
static int64_t lastBlockPrintTime = 0;
|
||||
auto currentTime = GetAdjustedTime();
|
||||
auto oldBlock = pindexNew->nTime + MAX_FUTURE_BLOCK_TIME < currentTime;
|
||||
if (!warningMessages.empty() || !oldBlock || lastBlockPrintTime < currentTime - 15 || LogAcceptCategory(BCLog::CLAIMS)) {
|
||||
lastBlockPrintTime = currentTime;
|
||||
LogPrintf("%s: new best=%s height=%d version=0x%08x log2_work=%.8g txb=%lu tx=%lu date='%s' progress=%f cache=%.1fMiB(%utxo) trie nodes=%zu%s",
|
||||
__func__, pindexNew->GetBlockHash().ToString(), pindexNew->nHeight, pindexNew->nVersion,
|
||||
log(pindexNew->nChainWork.getdouble()) / log(2.0), (unsigned long) pindexNew->nTx,
|
||||
(unsigned long) pindexNew->nChainTx, FormatISO8601DateTime(pindexNew->GetBlockTime()),
|
||||
GuessVerificationProgress(chainParams.TxData(), pindexNew),
|
||||
pcoinsTip->DynamicMemoryUsage() * (1.0 / (1U << 20U)), pcoinsTip->GetCacheSize(),
|
||||
pclaimTrie->height(), oldBlock ? " (synchronizing)" : "");
|
||||
if (!warningMessages.empty())
|
||||
LogPrintf(" warning='%s'", warningMessages); /* Continued */
|
||||
LogPrintf("\n");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -2775,12 +2783,14 @@ bool CChainState::ActivateBestChain(CValidationState &state, const CChainParams&
|
|||
} while (pindexNewTip != pindexMostWork);
|
||||
CheckBlockIndex(chainparams.GetConsensus());
|
||||
|
||||
// Write changes periodically to disk, after relay.
|
||||
if (!FlushStateToDisk(chainparams, state, FlushStateMode::PERIODIC)) {
|
||||
return false;
|
||||
auto flushMode = FlushStateMode::PERIODIC;
|
||||
if (pindexNewTip && pindexNewTip->nTime + chainparams.GetConsensus().nPowTargetSpacing > GetAdjustedTime()) {
|
||||
// trying to ensure that we flush to disk after new blocks when we're caught up to the chain
|
||||
// they're technically allowed to be two hours late, but experience says one minute is more likely
|
||||
// LogPrintf("Added tip with time %d but it is now %ll\n", pindexNewTip->nTime, GetAdjustedTime());
|
||||
flushMode = FlushStateMode::ALWAYS;
|
||||
}
|
||||
|
||||
return true;
|
||||
return FlushStateToDisk(chainparams, state, flushMode);
|
||||
}
|
||||
|
||||
bool ActivateBestChain(CValidationState &state, const CChainParams& chainparams, std::shared_ptr<const CBlock> pblock) {
|
||||
|
@ -3050,7 +3060,7 @@ static bool FindBlockPos(CDiskBlockPos &pos, unsigned int nAddSize, unsigned int
|
|||
if (CheckDiskSpace(nNewChunks * BLOCKFILE_CHUNK_SIZE - pos.nPos, true)) {
|
||||
FILE *file = OpenBlockFile(pos);
|
||||
if (file) {
|
||||
LogPrintf("Pre-allocating up to position 0x%x in blk%05u.dat\n", nNewChunks * BLOCKFILE_CHUNK_SIZE, pos.nFile);
|
||||
LogPrint(BCLog::BENCH, "Pre-allocating up to position 0x%x in blk%05u.dat\n", nNewChunks * BLOCKFILE_CHUNK_SIZE, pos.nFile);
|
||||
AllocateFileRange(file, pos.nPos, nNewChunks * BLOCKFILE_CHUNK_SIZE - pos.nPos);
|
||||
fclose(file);
|
||||
}
|
||||
|
@ -3083,7 +3093,7 @@ static bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos,
|
|||
if (CheckDiskSpace(nNewChunks * UNDOFILE_CHUNK_SIZE - pos.nPos, true)) {
|
||||
FILE *file = OpenUndoFile(pos);
|
||||
if (file) {
|
||||
LogPrintf("Pre-allocating up to position 0x%x in rev%05u.dat\n", nNewChunks * UNDOFILE_CHUNK_SIZE, pos.nFile);
|
||||
LogPrint(BCLog::BENCH, "Pre-allocating up to position 0x%x in rev%05u.dat\n", nNewChunks * UNDOFILE_CHUNK_SIZE, pos.nFile);
|
||||
AllocateFileRange(file, pos.nPos, nNewChunks * UNDOFILE_CHUNK_SIZE - pos.nPos);
|
||||
fclose(file);
|
||||
}
|
||||
|
|
|
@ -200,7 +200,7 @@ static const unsigned int MIN_BLOCKS_TO_KEEP = 288;
|
|||
/** Minimum blocks required to signal NODE_NETWORK_LIMITED */
|
||||
static const unsigned int NODE_NETWORK_LIMITED_MIN_BLOCKS = 288;
|
||||
|
||||
static const signed int DEFAULT_CHECKBLOCKS = 288 * 3; // 36 hours
|
||||
static const signed int DEFAULT_CHECKBLOCKS = 144; // 6 hours
|
||||
static const unsigned int DEFAULT_CHECKLEVEL = 3;
|
||||
|
||||
// Require that user allocate at least 550MB for block & undo files (blk???.dat and rev???.dat)
|
||||
|
|
Loading…
Reference in a new issue