Merge pull request #646 from jl777/jl777

fixed rpc latency when notary mining
This commit is contained in:
jl777
2018-05-01 14:37:45 +03:00
committed by GitHub
3 changed files with 27 additions and 24 deletions

View File

@@ -680,7 +680,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
else
{
komodo_rwccdata(ASSETCHAINS_SYMBOL,1,&ccdata,&MoMoMdata);
printf("[%s] matched.%d VALID (%s) MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth);
if ( matched != 0 )
printf("[%s] matched.%d VALID (%s) MoM.%s [%d]\n",ASSETCHAINS_SYMBOL,matched,ccdata.symbol,MoM.ToString().c_str(),MoMdepth);
}
if ( MoMoMdata.pairs != 0 )
free(MoMoMdata.pairs);

View File

@@ -41,9 +41,9 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig
{
static uint32_t counter; int32_t verified=0; char *coin; struct komodo_event_notarized N;
coin = (ASSETCHAINS_SYMBOL[0] == 0) ? (char *)"KMD" : ASSETCHAINS_SYMBOL;
if ( (ASSETCHAINS_SYMBOL[0] == 0 && height > 800000) && NOTARY_PUBKEY33[0] != 0 && (verified= komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 )
if ( (ASSETCHAINS_SYMBOL[0] == 0 && height > 814000) && NOTARY_PUBKEY33[0] != 0 && (verified= komodo_verifynotarization(symbol,dest,height,notarizedheight,notarized_hash,notarized_desttxid)) < 0 )
{
if ( ASSETCHAINS_SYMBOL[0] == 0 && height > 800000 && counter++ < 10 )
if ( ASSETCHAINS_SYMBOL[0] == 0 && height > 814000 && counter++ < 10 )
printf("[%s] error validating notarization ht.%d notarized_height.%d, if on a pruned %s node this can be ignored\n",ASSETCHAINS_SYMBOL,height,notarizedheight,dest);
}
else if ( strcmp(symbol,coin) == 0 )

View File

@@ -476,23 +476,25 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
UpdateTime(pblock, Params().GetConsensus(), pindexPrev);
pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, Params().GetConsensus());
}
pblock->nSolution.clear();
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && pblock->nTime < pindexPrev->nTime+60 )
{
pblock->nTime = pindexPrev->nTime + 60;
while ( pblock->GetBlockTime() > GetAdjustedTime() + 10 )
sleep(1);
//while ( pblock->GetBlockTime() > GetAdjustedTime() + 10 )
// sleep(1);
//fprintf(stderr,"block.nTime %u vs prev.%u, gettime.%u vs adjusted.%u\n",(uint32_t)pblock->nTime,(uint32_t)(pindexPrev->nTime + 60),(uint32_t)pblock->GetBlockTime(),(uint32_t)(GetAdjustedTime() + 60));
}
pblock->nSolution.clear();
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
CValidationState state;
if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false))
else
{
//static uint32_t counter;
//if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 )
// fprintf(stderr,"warning: miner testblockvalidity failed\n");
return(0);
CValidationState state;
if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false))
{
//static uint32_t counter;
//if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 )
// fprintf(stderr,"warning: miner testblockvalidity failed\n");
return(0);
}
}
}
@@ -788,7 +790,7 @@ void static BitcoinMiner()
static uint32_t counter;
if ( counter++ < 100 && ASSETCHAINS_STAKED == 0 )
fprintf(stderr,"created illegal block, retry\n");
sleep(3);
sleep(1);
continue;
}
unique_ptr<CBlockTemplate> pblocktemplate(ptr);
@@ -953,15 +955,6 @@ void static BitcoinMiner()
for (z=31; z>=16; z--)
fprintf(stderr,"%02x",((uint8_t *)&HASHTarget_POW)[z]);
fprintf(stderr," POW\n");*/
CValidationState state;
if ( !TestBlockValidity(state,B, chainActive.Tip(), true, false))
{
h = UintToArith256(B.GetHash());
for (z=31; z>=0; z--)
fprintf(stderr,"%02x",((uint8_t *)&h)[z]);
fprintf(stderr," Invalid block mined, try again\n");
return(false);
}
if ( ASSETCHAINS_STAKED == 0 )
{
if ( Mining_start != 0 && time(NULL) < Mining_start+roundrobin_delay )
@@ -993,6 +986,15 @@ void static BitcoinMiner()
fprintf(stderr," mined block!\n");
}
}
CValidationState state;
if ( !TestBlockValidity(state,B, chainActive.Tip(), true, false))
{
h = UintToArith256(B.GetHash());
for (z=31; z>=0; z--)
fprintf(stderr,"%02x",((uint8_t *)&h)[z]);
fprintf(stderr," Invalid block mined, try again\n");
return(false);
}
KOMODO_CHOSEN_ONE = 1;
// Found a solution
SetThreadPriority(THREAD_PRIORITY_NORMAL);