test
This commit is contained in:
18
src/komodo.h
18
src/komodo.h
@@ -181,6 +181,7 @@ const char *Notaries[64][2] =
|
|||||||
|
|
||||||
int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,NOTARIZED_HEIGHT,Num_nutxos;
|
int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,NOTARIZED_HEIGHT,Num_nutxos;
|
||||||
std::string NOTARY_PUBKEY;
|
std::string NOTARY_PUBKEY;
|
||||||
|
uint8_t NOTARY_PUBKEY33[33];
|
||||||
uint256 NOTARIZED_HASH,NOTARIZED_BTCHASH;
|
uint256 NOTARIZED_HASH,NOTARIZED_BTCHASH;
|
||||||
struct nutxo_entry { uint256 txhash; uint64_t voutmask; int32_t notaryid; };
|
struct nutxo_entry { uint256 txhash; uint64_t voutmask; int32_t notaryid; };
|
||||||
struct nutxo_entry NUTXOS[10000];
|
struct nutxo_entry NUTXOS[10000];
|
||||||
@@ -205,6 +206,7 @@ int32_t komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numno
|
|||||||
#endif
|
#endif
|
||||||
if ( fp == 0 )
|
if ( fp == 0 )
|
||||||
{
|
{
|
||||||
|
decode_hex(NOTARY_PUBKEY33,33,NOTARY_PUBKEY.ToString().c_str());
|
||||||
if ( (fp= fopen(fname,"rb+")) != 0 )
|
if ( (fp= fopen(fname,"rb+")) != 0 )
|
||||||
{
|
{
|
||||||
while ( (func= fgetc(fp)) != EOF )
|
while ( (func= fgetc(fp)) != EOF )
|
||||||
@@ -513,7 +515,19 @@ void komodo_disconnect(CBlockIndex *pindex,CBlock& block)
|
|||||||
komodo_stateupdate(-pindex->nHeight,0,0,0,zero,0,0);
|
komodo_stateupdate(-pindex->nHeight,0,0,0,zero,0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t komodo_blockindexcheck(CBlockIndex *pindex,uint32_t *nBitsp)
|
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void komodo_block2pubkey33(uint8_t *pubkey33,CBlock& block)
|
||||||
|
{
|
||||||
|
uint8_t *ptr;
|
||||||
|
ptr = block.vtx[0].vout[0].scriptPubKey.data();
|
||||||
|
memcpy(pubkey33,ptr+1,33);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*int32_t komodo_blockindexcheck(CBlockIndex *pindex,uint32_t *nBitsp)
|
||||||
{
|
{
|
||||||
// 1 -> valid notary block, change nBits to KOMODO_MINDIFF_NBITS
|
// 1 -> valid notary block, change nBits to KOMODO_MINDIFF_NBITS
|
||||||
// -1 -> invalid, ie, prior to notarized block
|
// -1 -> invalid, ie, prior to notarized block
|
||||||
@@ -560,6 +574,6 @@ int32_t komodo_blockhdrcheck(CBlockHeader& blockhdr,uint32_t *nBitsp)
|
|||||||
int32_t komodo_blockcheck(CBlock& block,uint32_t *nBitsp)
|
int32_t komodo_blockcheck(CBlock& block,uint32_t *nBitsp)
|
||||||
{
|
{
|
||||||
return(komodo_blockhdrcheck(block,nBitsp));
|
return(komodo_blockhdrcheck(block,nBitsp));
|
||||||
}
|
}*/
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
57
src/main.cpp
57
src/main.cpp
@@ -1278,7 +1278,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
|
|||||||
|
|
||||||
if (pindexSlow) {
|
if (pindexSlow) {
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if (ReadBlockFromDisk(block, pindexSlow,0)) {
|
if (ReadBlockFromDisk(block, pindexSlow)) {
|
||||||
BOOST_FOREACH(const CTransaction &tx, block.vtx) {
|
BOOST_FOREACH(const CTransaction &tx, block.vtx) {
|
||||||
if (tx.GetHash() == hash) {
|
if (tx.GetHash() == hash) {
|
||||||
txOut = tx;
|
txOut = tx;
|
||||||
@@ -1333,9 +1333,9 @@ bool WriteBlockToDisk(CBlock& block, CDiskBlockPos& pos, const CMessageHeader::M
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos,int32_t skipkomodo)
|
bool ReadBlockFromDisk(int32_t height,CBlock& block, const CDiskBlockPos& pos)
|
||||||
{
|
{
|
||||||
int32_t retval=0; uint32_t nBits;
|
uint8_t pubkey33[33];
|
||||||
block.SetNull();
|
block.SetNull();
|
||||||
|
|
||||||
// Open history file to read
|
// Open history file to read
|
||||||
@@ -1350,22 +1350,16 @@ bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos,int32_t skipkomod
|
|||||||
catch (const std::exception& e) {
|
catch (const std::exception& e) {
|
||||||
return error("%s: Deserialize or I/O error - %s at %s", __func__, e.what(), pos.ToString());
|
return error("%s: Deserialize or I/O error - %s at %s", __func__, e.what(), pos.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the header
|
// Check the header
|
||||||
nBits = block.nBits;
|
komodo_block2pubkey33(pubkey33,block);
|
||||||
if ( skipkomodo != 0 || (retval= komodo_blockcheck(block,&nBits)) == 0 )
|
if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus())))
|
||||||
{
|
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
|
||||||
if (!(CheckEquihashSolution(&block, Params()) && CheckProofOfWork(block.GetHash(), nBits, Params().GetConsensus())))
|
|
||||||
return error("ReadBlockFromDisk: Errors in block header at %s", pos.ToString());
|
|
||||||
}
|
|
||||||
else if ( retval < 0 )
|
|
||||||
return(false);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,int32_t skipkomodo)
|
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex)
|
||||||
{
|
{
|
||||||
if (!ReadBlockFromDisk(block, pindex->GetBlockPos(),skipkomodo))
|
if (!ReadBlockFromDisk(pindex->nHeight,block, pindex->GetBlockPos()))
|
||||||
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",
|
||||||
@@ -2405,7 +2399,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,0))
|
if (!ReadBlockFromDisk(block, pindexDelete))
|
||||||
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();
|
||||||
@@ -2468,7 +2462,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,0))
|
if (!ReadBlockFromDisk(block, pindexNew))
|
||||||
return AbortNode(state, "Failed to read block");
|
return AbortNode(state, "Failed to read block");
|
||||||
pblock = █
|
pblock = █
|
||||||
}
|
}
|
||||||
@@ -2956,25 +2950,20 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, bool fCheckPOW)
|
bool CheckBlockHeader(int32_t height,const CBlockHeader& block, CValidationState& state, bool fCheckPOW)
|
||||||
{
|
{
|
||||||
int32_t retval; uint32_t nBits;
|
uint8_t pubkey33[33];
|
||||||
// Check timestamp
|
// Check timestamp
|
||||||
if (block.GetBlockTime() > GetAdjustedTime() + 60)
|
if (block.GetBlockTime() > GetAdjustedTime() + 60)
|
||||||
return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new");
|
return state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new");
|
||||||
nBits = block.nBits;
|
// Check Equihash solution is valid
|
||||||
if ( (retval= komodo_blockhdrcheck(*(CBlockHeader *)&block,&nBits)) == 0 )
|
if ( fCheckPOW && !CheckEquihashSolution(&block, Params()) )
|
||||||
{
|
return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution");
|
||||||
// Check Equihash solution is valid
|
|
||||||
if ( fCheckPOW && !CheckEquihashSolution(&block, Params()) )
|
|
||||||
return state.DoS(100, error("CheckBlockHeader(): Equihash solution invalid"),REJECT_INVALID, "invalid-solution");
|
|
||||||
|
|
||||||
// Check proof of work matches claimed amount
|
// Check proof of work matches claimed amount
|
||||||
if ( fCheckPOW && !CheckProofOfWork(block.GetHash(), nBits, Params().GetConsensus()) )
|
komodo_block2pubkey33(pubkey33,block);
|
||||||
return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),REJECT_INVALID, "high-hash");
|
if ( fCheckPOW && !CheckProofOfWork(height,pubkey33,block.GetHash(), block.nBits, Params().GetConsensus()) )
|
||||||
}
|
return state.DoS(50, error("CheckBlockHeader(): proof of work failed"),REJECT_INVALID, "high-hash");
|
||||||
else if ( retval < 0 ) // komodo rejects block, ie. prior to notarized blockhash
|
|
||||||
return(false);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3606,7 +3595,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,0))
|
if (!ReadBlockFromDisk(block, pindex))
|
||||||
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))
|
||||||
@@ -3646,7 +3635,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,0))
|
if (!ReadBlockFromDisk(block, pindex))
|
||||||
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());
|
||||||
@@ -3819,7 +3808,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,0))
|
if (ReadBlockFromDisk(block, it->second))
|
||||||
{
|
{
|
||||||
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());
|
||||||
@@ -4178,7 +4167,7 @@ void static ProcessGetData(CNode* pfrom)
|
|||||||
{
|
{
|
||||||
// Send block from disk
|
// Send block from disk
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if (!ReadBlockFromDisk(block, (*mi).second,0))
|
if (!ReadBlockFromDisk(block, (*mi).second))
|
||||||
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,int32_t skipkomodo);
|
bool ReadBlockFromDisk(CBlock& block, const CDiskBlockPos& pos);
|
||||||
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex,int32_t skipkomodo);
|
bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex);
|
||||||
|
|
||||||
|
|
||||||
/** Functions for validating blocks and updating the block tree */
|
/** Functions for validating blocks and updating the block tree */
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams& param
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params& params)
|
bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params)
|
||||||
{
|
{
|
||||||
bool fNegative;
|
bool fNegative;
|
||||||
bool fOverflow;
|
bool fOverflow;
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ unsigned int CalculateNextWorkRequired(arith_uint256 bnAvg,
|
|||||||
bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams&);
|
bool CheckEquihashSolution(const CBlockHeader *pblock, const CChainParams&);
|
||||||
|
|
||||||
/** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */
|
/** Check whether a block hash satisfies the proof-of-work requirement specified by nBits */
|
||||||
bool CheckProofOfWork(uint256 hash, unsigned int nBits, const Consensus::Params&);
|
bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params&);
|
||||||
arith_uint256 GetBlockProof(const CBlockIndex& block);
|
arith_uint256 GetBlockProof(const CBlockIndex& block);
|
||||||
|
|
||||||
/** Return the time it would take to redo the work difference between from and to, assuming the current hashrate corresponds to the difficulty at tip, in seconds. */
|
/** Return the time it would take to redo the work difference between from and to, assuming the current hashrate corresponds to the difficulty at tip, in seconds. */
|
||||||
|
|||||||
@@ -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,0))
|
if (!ReadBlockFromDisk(block, pblockindex))
|
||||||
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,0))
|
if(!ReadBlockFromDisk(block, pblockindex))
|
||||||
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)
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ Value getgenerate(const Array& params, bool fHelp)
|
|||||||
return GetBoolArg("-gen", false);
|
return GetBoolArg("-gen", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t komodo_blockcheck(CBlock& block,uint32_t *nBitsp);
|
extern uint8_t NOTARY_PUBKEY33[33];
|
||||||
|
|
||||||
Value generate(const Array& params, bool fHelp)
|
Value generate(const Array& params, bool fHelp)
|
||||||
{
|
{
|
||||||
@@ -193,15 +193,8 @@ Value generate(const Array& params, bool fHelp)
|
|||||||
std::function<bool(std::vector<unsigned char>)> validBlock =
|
std::function<bool(std::vector<unsigned char>)> validBlock =
|
||||||
[&pblock](std::vector<unsigned char> soln)
|
[&pblock](std::vector<unsigned char> soln)
|
||||||
{
|
{
|
||||||
int32_t retval; uint32_t nBits;
|
|
||||||
pblock->nSolution = soln;
|
pblock->nSolution = soln;
|
||||||
nBits = pblock->nBits;
|
return CheckProofOfWork(nHeight,NOTARY_PUBKEY33,pblock->GetHash(), pblock->nBits, Params().GetConsensus());
|
||||||
if ( (retval= komodo_blockcheck(*pblock,&nBits)) == 0 )
|
|
||||||
{
|
|
||||||
return CheckProofOfWork(pblock->GetHash(), nBits, Params().GetConsensus());
|
|
||||||
} else if ( retval < 0 ) // komodo rejects, ie. prior to notarized blockhash
|
|
||||||
return(false);
|
|
||||||
return true;
|
|
||||||
};
|
};
|
||||||
if (EhBasicSolveUncancellable(n, k, curr_state, validBlock))
|
if (EhBasicSolveUncancellable(n, k, curr_state, validBlock))
|
||||||
goto endloop;
|
goto endloop;
|
||||||
|
|||||||
@@ -303,7 +303,7 @@ Value gettxoutproof(const Array& params, bool fHelp)
|
|||||||
}
|
}
|
||||||
|
|
||||||
CBlock block;
|
CBlock block;
|
||||||
if(!ReadBlockFromDisk(block, pblockindex,0))
|
if(!ReadBlockFromDisk(block, pblockindex))
|
||||||
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;
|
||||||
|
|||||||
13
src/txdb.cpp
13
src/txdb.cpp
@@ -306,15 +306,10 @@ bool CBlockTreeDB::LoadBlockIndexGuts()
|
|||||||
pindexNew->nSolution = diskindex.nSolution;
|
pindexNew->nSolution = diskindex.nSolution;
|
||||||
pindexNew->nStatus = diskindex.nStatus;
|
pindexNew->nStatus = diskindex.nStatus;
|
||||||
pindexNew->nTx = diskindex.nTx;
|
pindexNew->nTx = diskindex.nTx;
|
||||||
|
uint8_t pubkey33[33];
|
||||||
int32_t retval; uint32_t nBits;
|
komodo_index2pubkey33(pubkey33,pindexNew);
|
||||||
nBits = pindexNew->nBits;
|
if (!CheckProofOfWork(pindexNew->height,pubkey33,pindexNew->GetBlockHash(), pindexNew->nBits, Params().GetConsensus()))
|
||||||
if ( (retval= komodo_blockindexcheck(pindexNew,&nBits)) == 0 )
|
return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString());
|
||||||
{
|
|
||||||
if (!CheckProofOfWork(pindexNew->GetBlockHash(), nBits, Params().GetConsensus()))
|
|
||||||
return error("LoadBlockIndex(): CheckProofOfWork failed: %s", pindexNew->ToString());
|
|
||||||
} else if ( retval < 0 ) // komodo rejects, ie. prior to notarized blockhash
|
|
||||||
return(false);
|
|
||||||
pcursor->Next();
|
pcursor->Next();
|
||||||
} else {
|
} else {
|
||||||
break; // if shutdown requested or finished loading block index
|
break; // if shutdown requested or finished loading block index
|
||||||
|
|||||||
@@ -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,0);
|
ReadBlockFromDisk(block, pindex);
|
||||||
pblock = █
|
pblock = █
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1651,7 +1651,7 @@ void CWallet::WitnessNoteCommitment(std::vector<uint256> commitments,
|
|||||||
|
|
||||||
while (pindex) {
|
while (pindex) {
|
||||||
CBlock block;
|
CBlock block;
|
||||||
ReadBlockFromDisk(block, pindex,0);
|
ReadBlockFromDisk(block, pindex);
|
||||||
|
|
||||||
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,0);
|
ReadBlockFromDisk(block, pindex);
|
||||||
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