test
This commit is contained in:
@@ -30,12 +30,8 @@ int32_t komodo_blockindexcheck(CBlockIndex *pindex,uint32_t *nBitsp)
|
|||||||
CBlock block; int32_t height; char *coinbasestr;
|
CBlock block; int32_t height; char *coinbasestr;
|
||||||
if ( pindex == 0 )
|
if ( pindex == 0 )
|
||||||
return(0);
|
return(0);
|
||||||
block.SetNull();
|
if ( ReadBlockFromDisk(block,pindex,1) == 0 )
|
||||||
CAutoFile filein(OpenBlockFile(pindex->GetBlockPos(),true),SER_DISK,CLIENT_VERSION);
|
|
||||||
if ( filein.IsNull() )
|
|
||||||
return(0);
|
return(0);
|
||||||
try { filein >> block; }
|
|
||||||
catch (const std::exception& e) { return(0); }
|
|
||||||
if ( block.vtx.size() > 0 )
|
if ( block.vtx.size() > 0 )
|
||||||
{
|
{
|
||||||
height = pindex->nHeight;
|
height = pindex->nHeight;
|
||||||
|
|||||||
22
src/main.cpp
22
src/main.cpp
@@ -1323,9 +1323,9 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos, const CMessageHeader::M
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
|
bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos,int32_t skipkomodo)
|
||||||
{
|
{
|
||||||
int32_t retval; uint32_t nBits;
|
int32_t retval=0; uint32_t nBits;
|
||||||
block.SetNull();
|
block.SetNull();
|
||||||
|
|
||||||
// Open history file to read
|
// Open history file to read
|
||||||
@@ -1343,7 +1343,7 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
|
|||||||
|
|
||||||
// Check the header
|
// Check the header
|
||||||
nBits = block.nBits;
|
nBits = block.nBits;
|
||||||
if ( (retval= komodo_blockcheck(block,&nBits)) == 0 )
|
if ( skipkomodo != 0 || (retval= komodo_blockcheck(block,&nBits)) == 0 )
|
||||||
{
|
{
|
||||||
if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(block.GetHash(), nBits, Params().GetConsensus())))
|
if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(block.GetHash(), nBits, Params().GetConsensus())))
|
||||||
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
|
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
|
||||||
@@ -1353,9 +1353,9 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex)
|
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,int32_t skipkomodo)
|
||||||
{
|
{
|
||||||
if (!ReadBlockFromDisk(block, pindex->GetBlockPos()))
|
if (!ReadBlockFromDisk(block, pindex->GetBlockPos(),skipkomodo))
|
||||||
return false;
|
return false;
|
||||||
if (block.GetHash() != pindex->GetBlockHash())
|
if (block.GetHash() != pindex->GetBlockHash())
|
||||||
return error("ReadBlockFromDisk(CBlock&, CBlockIndex*): GetHash() doesn't match index for %s at %s",
|
return error("ReadBlockFromDisk(CBlock&, CBlockIndex*): GetHash() doesn't match index for %s at %s",
|
||||||
@@ -2392,7 +2392,7 @@ bool static DisconnectTip(CValidationState &state) {
|
|||||||
mempool.check(pcoinsTip);
|
mempool.check(pcoinsTip);
|
||||||
// Read block from disk.
|
// Read block from disk.
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if (!ReadBlockFromDisk(block, pindexDelete))
|
if (!ReadBlockFromDisk(block, pindexDelete,0))
|
||||||
return AbortNode(state, "Failed to read block");
|
return AbortNode(state, "Failed to read block");
|
||||||
// Apply the block atomically to the chain state.
|
// Apply the block atomically to the chain state.
|
||||||
uint256 anchorBeforeDisconnect = pcoinsTip->GetBestAnchor();
|
uint256 anchorBeforeDisconnect = pcoinsTip->GetBestAnchor();
|
||||||
@@ -2455,7 +2455,7 @@ bool static ConnectTip(CValidationState &state, CBlockIndex *pindexNew, CBlock *
|
|||||||
int64_t nTime1 = GetTimeMicros();
|
int64_t nTime1 = GetTimeMicros();
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if (!pblock) {
|
if (!pblock) {
|
||||||
if (!ReadBlockFromDisk(block, pindexNew))
|
if (!ReadBlockFromDisk(block, pindexNew,0))
|
||||||
return AbortNode(state, "Failed to read block");
|
return AbortNode(state, "Failed to read block");
|
||||||
pblock = █
|
pblock = █
|
||||||
}
|
}
|
||||||
@@ -3594,7 +3594,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth
|
|||||||
break;
|
break;
|
||||||
CBlock block;
|
CBlock block;
|
||||||
// check level 0: read from disk
|
// check level 0: read from disk
|
||||||
if (!ReadBlockFromDisk(block, pindex))
|
if (!ReadBlockFromDisk(block, pindex,0))
|
||||||
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||||
// check level 1: verify block validity
|
// check level 1: verify block validity
|
||||||
if (nCheckLevel >= 1 && !CheckBlock(block, state))
|
if (nCheckLevel >= 1 && !CheckBlock(block, state))
|
||||||
@@ -3634,7 +3634,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth
|
|||||||
uiInterface.ShowProgress(_("Verifying blocks..."), std::max(1, std::min(99, 100 - (int)(((double)(chainActive.Height() - pindex->nHeight)) / (double)nCheckDepth * 50))));
|
uiInterface.ShowProgress(_("Verifying blocks..."), std::max(1, std::min(99, 100 - (int)(((double)(chainActive.Height() - pindex->nHeight)) / (double)nCheckDepth * 50))));
|
||||||
pindex = chainActive.Next(pindex);
|
pindex = chainActive.Next(pindex);
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if (!ReadBlockFromDisk(block, pindex))
|
if (!ReadBlockFromDisk(block, pindex,0))
|
||||||
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||||
if (!ConnectBlock(block, state, pindex, coins))
|
if (!ConnectBlock(block, state, pindex, coins))
|
||||||
return error("VerifyDB(): *** found unconnectable block at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
return error("VerifyDB(): *** found unconnectable block at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
|
||||||
@@ -3807,7 +3807,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
|
|||||||
std::pair<std::multimap<uint256, CDiskBlockPos>::iterator, std::multimap<uint256, CDiskBlockPos>::iterator> range = mapBlocksUnknownParent.equal_range(head);
|
std::pair<std::multimap<uint256, CDiskBlockPos>::iterator, std::multimap<uint256, CDiskBlockPos>::iterator> range = mapBlocksUnknownParent.equal_range(head);
|
||||||
while (range.first != range.second) {
|
while (range.first != range.second) {
|
||||||
std::multimap<uint256, CDiskBlockPos>::iterator it = range.first;
|
std::multimap<uint256, CDiskBlockPos>::iterator it = range.first;
|
||||||
if (ReadBlockFromDisk(block, it->second))
|
if (ReadBlockFromDisk(block, it->second,0))
|
||||||
{
|
{
|
||||||
LogPrintf("%s: Processing out of order child %s of %s\n", __func__, block.GetHash().ToString(),
|
LogPrintf("%s: Processing out of order child %s of %s\n", __func__, block.GetHash().ToString(),
|
||||||
head.ToString());
|
head.ToString());
|
||||||
@@ -4166,7 +4166,7 @@ void static ProcessGetData(CNode* pfrom)
|
|||||||
{
|
{
|
||||||
// Send block from disk
|
// Send block from disk
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if (!ReadBlockFromDisk(block, (*mi).second))
|
if (!ReadBlockFromDisk(block, (*mi).second,0))
|
||||||
assert(!"cannot load block from disk");
|
assert(!"cannot load block from disk");
|
||||||
if (inv.type == MSG_BLOCK)
|
if (inv.type == MSG_BLOCK)
|
||||||
pfrom->PushMessage("block", block);
|
pfrom->PushMessage("block", block);
|
||||||
|
|||||||
@@ -393,8 +393,8 @@ public:
|
|||||||
|
|
||||||
/** Functions for disk access for blocks */
|
/** Functions for disk access for blocks */
|
||||||
bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos, const CMessageHeader::MessageStartChars& messageStart);
|
bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos, const CMessageHeader::MessageStartChars& messageStart);
|
||||||
bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos);
|
bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos,int32_t skipkomodo);
|
||||||
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex);
|
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,int32_t skipkomodo);
|
||||||
|
|
||||||
|
|
||||||
/** Functions for validating blocks and updating the block tree */
|
/** Functions for validating blocks and updating the block tree */
|
||||||
|
|||||||
@@ -200,7 +200,7 @@ static bool rest_block(AcceptedConnection* conn,
|
|||||||
if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0)
|
if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0)
|
||||||
throw RESTERR(HTTP_NOT_FOUND, hashStr + " not available (pruned data)");
|
throw RESTERR(HTTP_NOT_FOUND, hashStr + " not available (pruned data)");
|
||||||
|
|
||||||
if (!ReadBlockFromDisk(block, pblockindex))
|
if (!ReadBlockFromDisk(block, pblockindex,0))
|
||||||
throw RESTERR(HTTP_NOT_FOUND, hashStr + " not found");
|
throw RESTERR(HTTP_NOT_FOUND, hashStr + " not found");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -326,7 +326,7 @@ Value getblock(const Array& params, bool fHelp)
|
|||||||
if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0)
|
if (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0)
|
||||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)");
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "Block not available (pruned data)");
|
||||||
|
|
||||||
if(!ReadBlockFromDisk(block, pblockindex))
|
if(!ReadBlockFromDisk(block, pblockindex,0))
|
||||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
|
||||||
|
|
||||||
if (!fVerbose)
|
if (!fVerbose)
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ Value gettxoutproof(const Array& params, bool fHelp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if(!ReadBlockFromDisk(block, pblockindex))
|
if(!ReadBlockFromDisk(block, pblockindex,0))
|
||||||
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
|
throw JSONRPCError(RPC_INTERNAL_ERROR, "Can't read block from disk");
|
||||||
|
|
||||||
unsigned int ntxFound = 0;
|
unsigned int ntxFound = 0;
|
||||||
|
|||||||
@@ -668,7 +668,7 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex,
|
|||||||
const CBlock* pblock {pblockIn};
|
const CBlock* pblock {pblockIn};
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if (!pblock) {
|
if (!pblock) {
|
||||||
ReadBlockFromDisk(block, pindex);
|
ReadBlockFromDisk(block, pindex,0);
|
||||||
pblock = █
|
pblock = █
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1651,7 +1651,7 @@ void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
|
|||||||
|
|
||||||
while (pindex) {
|
while (pindex) {
|
||||||
CBlock block;
|
CBlock block;
|
||||||
ReadBlockFromDisk(block, pindex);
|
ReadBlockFromDisk(block, pindex,0);
|
||||||
|
|
||||||
BOOST_FOREACH(const CTransaction& tx, block.vtx)
|
BOOST_FOREACH(const CTransaction& tx, block.vtx)
|
||||||
{
|
{
|
||||||
@@ -1727,7 +1727,7 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate)
|
|||||||
ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), pindex, false) - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
|
ShowProgress(_("Rescanning..."), std::max(1, std::min(99, (int)((Checkpoints::GuessVerificationProgress(chainParams.Checkpoints(), pindex, false) - dProgressStart) / (dProgressTip - dProgressStart) * 100))));
|
||||||
|
|
||||||
CBlock block;
|
CBlock block;
|
||||||
ReadBlockFromDisk(block, pindex);
|
ReadBlockFromDisk(block, pindex,0);
|
||||||
BOOST_FOREACH(CTransaction& tx, block.vtx)
|
BOOST_FOREACH(CTransaction& tx, block.vtx)
|
||||||
{
|
{
|
||||||
if (AddToWalletIfInvolvingMe(tx, &block, fUpdate))
|
if (AddToWalletIfInvolvingMe(tx, &block, fUpdate))
|
||||||
|
|||||||
Reference in New Issue
Block a user