Merge pull request #1487 from blackjok3rtt/beta

bug fixes
This commit is contained in:
jl777
2019-05-16 02:39:35 -11:00
committed by GitHub
2 changed files with 14 additions and 6 deletions

View File

@@ -3978,8 +3978,10 @@ bool static DisconnectTip(CValidationState &state, bool fBare = false) {
if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block,pindexDelete->GetHeight()) != 0))) if ((i == (block.vtx.size() - 1)) && (ASSETCHAINS_STAKED != 0 && (komodo_isPoS((CBlock *)&block,pindexDelete->GetHeight()) != 0)))
{ {
#ifdef ENABLE_WALLET #ifdef ENABLE_WALLET
LOCK2(cs_main, pwalletMain->cs_wallet); if ( !GetBoolArg("-disablewallet", false) ) {
pwalletMain->EraseFromWallet(tx.GetHash()); LOCK(pwalletMain->cs_wallet);
pwalletMain->EraseFromWallet(tx.GetHash());
}
#endif #endif
} }
else else
@@ -6360,7 +6362,7 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
try { try {
// This takes over fileIn and calls fclose() on it in the CBufferedFile destructor // This takes over fileIn and calls fclose() on it in the CBufferedFile destructor
//CBufferedFile blkdat(fileIn, 2*MAX_BLOCK_SIZE, MAX_BLOCK_SIZE+8, SER_DISK, CLIENT_VERSION); //CBufferedFile blkdat(fileIn, 2*MAX_BLOCK_SIZE, MAX_BLOCK_SIZE+8, SER_DISK, CLIENT_VERSION);
CBufferedFile blkdat(fileIn, 32*MAX_BLOCK_SIZE(10000000), MAX_BLOCK_SIZE(10000000)+8, SER_DISK, CLIENT_VERSION); CBufferedFile blkdat(fileIn, 2*MAX_BLOCK_SIZE(10000000), MAX_BLOCK_SIZE(10000000)+8, SER_DISK, CLIENT_VERSION);
uint64_t nRewind = blkdat.GetPos(); uint64_t nRewind = blkdat.GetPos();
while (!blkdat.eof()) { while (!blkdat.eof()) {
boost::this_thread::interruption_point(); boost::this_thread::interruption_point();
@@ -6387,15 +6389,15 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp)
} }
try { try {
// read block // read block
CBlock block;
uint64_t nBlockPos = blkdat.GetPos(); uint64_t nBlockPos = blkdat.GetPos();
if (dbp) if (dbp)
dbp->nPos = nBlockPos; dbp->nPos = nBlockPos;
blkdat.SetLimit(nBlockPos + nSize); blkdat.SetLimit(nBlockPos + nSize);
blkdat.SetPos(nBlockPos); blkdat.SetPos(nBlockPos);
CBlock block;
blkdat >> block; blkdat >> block;
nRewind = blkdat.GetPos();
nRewind = blkdat.GetPos();
// detect out of order blocks, and store them for later // detect out of order blocks, and store them for later
uint256 hash = block.GetHash(); uint256 hash = block.GetHash();
if (hash != chainparams.GetConsensus().hashGenesisBlock && mapBlockIndex.find(block.hashPrevBlock) == mapBlockIndex.end()) { if (hash != chainparams.GetConsensus().hashGenesisBlock && mapBlockIndex.find(block.hashPrevBlock) == mapBlockIndex.end()) {
@@ -6426,6 +6428,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(mapBlockIndex.count(hash)!=0?mapBlockIndex[hash]->GetHeight():0,block, it->second,1)) if (ReadBlockFromDisk(mapBlockIndex.count(hash)!=0?mapBlockIndex[hash]->GetHeight():0,block, it->second,1))
{ {
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(),

View File

@@ -803,12 +803,17 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
//fprintf(stderr,"check validity\n"); //fprintf(stderr,"check validity\n");
if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) // invokes CC checks if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) // invokes CC checks
{ {
if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) )
{
LEAVE_CRITICAL_SECTION(cs_main);
LEAVE_CRITICAL_SECTION(mempool.cs);
}
throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed");
} }
//fprintf(stderr,"valid\n"); //fprintf(stderr,"valid\n");
} }
} }
if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) ) if ( ASSETCHAINS_SYMBOL[0] == 0 || (ASSETCHAINS_SYMBOL[0] != 0 && !isStake) )
{ {
LEAVE_CRITICAL_SECTION(cs_main); LEAVE_CRITICAL_SECTION(cs_main);
LEAVE_CRITICAL_SECTION(mempool.cs); LEAVE_CRITICAL_SECTION(mempool.cs);