diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 945f0b71b..93767844d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -707,7 +707,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim { if ( overflow != 0 || total > COIN/10 ) { - //fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); + fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); if ( height >= activation ) return(-1); } diff --git a/src/main.cpp b/src/main.cpp index 008bd3197..014efac2d 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2593,6 +2593,12 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // verify that the view's current state corresponds to the previous block uint256 hashPrevBlock = pindex->pprev == NULL ? uint256() : pindex->pprev->GetBlockHash(); + if ( hashPrevBlock != view.GetBestBlock() ) + { + fprintf(stderr,"ConnectBlock(): hashPrevBlock != view.GetBestBlock()\n"); + return state.DoS(1, error("ConnectBlock(): hashPrevBlock != view.GetBestBlock()"), + REJECT_INVALID, "hashPrevBlock-not-bestblock"); + } assert(hashPrevBlock == view.GetBestBlock()); // Special case for the genesis block, skipping connection of its transactions @@ -3545,7 +3551,7 @@ CBlockIndex* AddToBlockIndex(const CBlockHeader& block) if (it != mapBlockIndex.end()) { //if ( ASSETCHAINS_STAKED == 0 || it->second != 0 ) // change behavior to allow komodo_ensure to work - if ( vNodes.size() >= KOMODO_LIMITED_NETWORKSIZE || it->second != 0 ) // change behavior to allow komodo_ensure to work + if ( it->second != 0 ) // vNodes.size() >= KOMODO_LIMITED_NETWORKSIZE, change behavior to allow komodo_ensure to work { // this is the strange case where somehow the hash is in the mapBlockIndex via as yet undetermined process, but the pindex for the hash is not there. Theoretically it is due to processing the block headers, but I have seen it get this case without having received it from the block headers or anywhere else... jl777 //fprintf(stderr,"addtoblockindex already there %p\n",it->second); @@ -4156,7 +4162,7 @@ bool ProcessNewBlock(bool from_miner,int32_t height,CValidationState &state, CNo } // Store to disk CBlockIndex *pindex = NULL; - if ( vNodes.size() < KOMODO_LIMITED_NETWORKSIZE ) //ASSETCHAINS_STAKED != 0 )// + //if ( vNodes.size() < KOMODO_LIMITED_NETWORKSIZE ) //ASSETCHAINS_STAKED != 0 )// { // without the komodo_ensure call, it is quite possible to get a non-error but null pindex returned from AcceptBlockHeader. In a 2 node network, it will be a long time before that block is reprocessed. Even though restarting makes it rescan, it seems much better to keep the nodes in sync komodo_ensure(pblock,hash); diff --git a/src/miner.cpp b/src/miner.cpp index 3bd4b1c66..a8569980d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -214,7 +214,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) continue; if ( komodo_validate_interest(tx,nHeight,(uint32_t)pblock->nTime,0) < 0 ) { - fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure\n"); + //fprintf(stderr,"CreateNewBlock: komodo_validate_interest failure nHeight.%d nTime.%u vs locktime.%u\n",nHeight,(uint32_t)pblock->nTime,(uint32_t)tx.nLockTime); continue; } COrphan* porphan = NULL; @@ -635,7 +635,7 @@ static bool ProcessBlockFound(CBlock* pblock) return error("KomodoMiner: ProcessNewBlock, block not accepted"); TrackMinedBlock(pblock->GetHash()); - if ( vNodes.size() < KOMODO_LIMITED_NETWORKSIZE*2 ) + //if ( vNodes.size() < KOMODO_LIMITED_NETWORKSIZE*2 ) { int32_t n = 1; //fprintf(stderr,"broadcast new block t.%u\n",(uint32_t)time(NULL)); @@ -648,7 +648,8 @@ static bool ProcessBlockFound(CBlock* pblock) if ( (rand() % n) == 0 ) { pnode->PushMessage("block", *pblock); - n++; + if ( n++ > 8 ) + break; } } }