Merge pull request #351 from jl777/dev

Dev
This commit is contained in:
jl777
2017-03-23 04:45:36 +02:00
committed by GitHub
4 changed files with 38 additions and 10 deletions

View File

@@ -520,8 +520,8 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
} }
if ( ASSETCHAINS_SYMBOL[0] != 0 && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) ) if ( ASSETCHAINS_SYMBOL[0] != 0 && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) )
{ {
if ( pax->height > 214700 || strcmp(ASSETCHAINS_SYMBOL,symbol) == 0 ) //if ( pax->height > 214700 || strcmp(ASSETCHAINS_SYMBOL,symbol) == 0 )
printf("miner.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed)); // printf("miner.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed));
continue; continue;
} }
/*printf("pax.%s marked.%d %.8f -> %.8f ready.%d validated.%d\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->ready!=0,pax->validated!=0); /*printf("pax.%s marked.%d %.8f -> %.8f ready.%d validated.%d\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->ready!=0,pax->validated!=0);
@@ -1213,7 +1213,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
{ {
basesp->withdrawn += value; basesp->withdrawn += value;
didstats = 1; didstats = 1;
if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 )
printf("########### %p withdrawn %s += %.8f check %.8f\n",basesp,base,dstr(value),dstr(checktoshis)); printf("########### %p withdrawn %s += %.8f check %.8f\n",basesp,base,dstr(value),dstr(checktoshis));
} }
if ( 0 && strcmp(base,"RUB") == 0 && (pax == 0 || pax->approved == 0) ) if ( 0 && strcmp(base,"RUB") == 0 && (pax == 0 || pax->approved == 0) )

View File

@@ -741,11 +741,12 @@ int32_t komodo_validate_interest(const CTransaction& tx,uint32_t txblocktime)
// komodo_validate_interest reject.0 locktime 1490193206/0 vs nBlockTime 1490202625 txheighttime.1490202625 tiptime.0 // komodo_validate_interest reject.0 locktime 1490193206/0 vs nBlockTime 1490202625 txheighttime.1490202625 tiptime.0
//static uint32_t counter; //static uint32_t counter;
//if ( counter++ < 100 ) //if ( counter++ < 100 )
if ( tx.nLockTime != 1477258935 )
fprintf(stderr,"komodo_validate_interest reject.%d locktime %u/%u vs nBlockTime %u txheighttime.%u tiptime.%u txb.%u cmp.%u\n",txheight,(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,txheighttime,tiptime,txblocktime,cmptime); fprintf(stderr,"komodo_validate_interest reject.%d locktime %u/%u vs nBlockTime %u txheighttime.%u tiptime.%u txb.%u cmp.%u\n",txheight,(uint32_t)tx.nLockTime,locktime,(uint32_t)chainActive.Tip()->nTime,txheighttime,tiptime,txblocktime,cmptime);
return(-1); return(-1);
} else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs txheighttime.%u tiptime.%u txb.%u cmp.%u\n",(int32_t)txheight,tx.nLockTime,txheighttime,tiptime,txblocktime,cmptime); } else fprintf(stderr,"validateinterest grandfather.%d locktime %u vs txheighttime.%u tiptime.%u txb.%u cmp.%u\n",(int32_t)txheight,tx.nLockTime,txheighttime,tiptime,txblocktime,cmptime);
} }
fprintf(stderr,"validateinterest accept.%d locktime %u/%u vs txheighttime.%u tiptime.%u txb.%u cmp.%u\n",(int32_t)txheight,(int32_t)tx.nLockTime,locktime,txheighttime,tiptime,txblocktime,cmptime); fprintf(stderr,"validateinterest accept.%d tip.%d locktime %u/%u vs txheighttime.%u tiptime.%u txb.%u cmp.%u\n",(int32_t)txheight,(int32_t)chainActive.Tip()->nHeight,(int32_t)tx.nLockTime,locktime,txheighttime,tiptime,txblocktime,cmptime);
} }
return(0); return(0);
} }
@@ -1610,9 +1611,9 @@ bool IsInitialBlockDownload()
else if ( pindexBestHeader != 0 && pindexBestHeader->nHeight > ptr->nHeight ) else if ( pindexBestHeader != 0 && pindexBestHeader->nHeight > ptr->nHeight )
ptr = pindexBestHeader; ptr = pindexBestHeader;
if ( ASSETCHAINS_SYMBOL[0] == 0 ) if ( ASSETCHAINS_SYMBOL[0] == 0 )
state = ((chainActive.Height() < ptr->nHeight - 24*6) || state = ((chainActive.Height() < ptr->nHeight - 24*60) ||
ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge())); ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge()));
else state = (chainActive.Height() < ptr->nHeight - 100); else state = (chainActive.Height() < ptr->nHeight - 3);
//fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge())); //fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge()));
if (!state) if (!state)
{ {
@@ -2948,7 +2949,7 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) {
} }
// Notify external listeners about the new tip. // Notify external listeners about the new tip.
uiInterface.NotifyBlockTip(hashNewTip); uiInterface.NotifyBlockTip(hashNewTip);
} } //else fprintf(stderr,"initial download skips propagation\n");
} while(pindexMostWork != chainActive.Tip()); } while(pindexMostWork != chainActive.Tip());
CheckBlockIndex(); CheckBlockIndex();
@@ -3199,6 +3200,21 @@ bool CheckBlockHeader(int32_t height,CBlockIndex *pindex, const CBlockHeader& bl
{ {
uint8_t pubkey33[33]; uint8_t pubkey33[33];
// Check timestamp // Check timestamp
if ( 0 )
{
uint256 hash; int32_t i;
hash = blockhdr.GetHash();
for (i=31; i>=0; i--)
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
fprintf(stderr," <- CheckBlockHeader\n");
if ( chainActive.Tip() != 0 )
{
hash = chainActive.Tip()->GetBlockHash();
for (i=31; i>=0; i--)
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
fprintf(stderr," <- chainTip\n");
}
}
if (blockhdr.GetBlockTime() > GetAdjustedTime() + 60) if (blockhdr.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");
// Check block version // Check block version
@@ -3267,7 +3283,7 @@ bool CheckBlock(int32_t height,CBlockIndex *pindex,const CBlock& block, CValidat
{ {
if ( komodo_validate_interest(tx,block.nTime) < 0 ) if ( komodo_validate_interest(tx,block.nTime) < 0 )
{ {
fprintf(stderr,"CheckBlock(): komodo_validate_interest failure\n"); fprintf(stderr,"CheckBlock(%d:%d) %d, %u: komodo_validate_interest failure blocksize.%d\n",height,komodo_block2height((CBlock *)&block),pindex!=0?(int32_t)pindex->nHeight:0,pindex!=0?(int32_t)pindex->nTime:0,(int32_t)block.vtx.size());
return error("CheckBlock: komodo_validate_interest failed"); return error("CheckBlock: komodo_validate_interest failed");
} }
if (!CheckTransaction(tx, state, verifier)) if (!CheckTransaction(tx, state, verifier))

View File

@@ -511,7 +511,19 @@ static bool ProcessBlockFound(CBlock* pblock, CWallet& wallet, CReserveKey& rese
{ {
LOCK(cs_main); LOCK(cs_main);
if (pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash()) if (pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash())
{
uint256 hash; int32_t i;
hash = pblock->hashPrevBlock;
for (i=31; i>=0; i--)
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
fprintf(stderr," <- prev (stale)\n");
hash = chainActive.Tip()->GetBlockHash();
for (i=31; i>=0; i--)
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
fprintf(stderr," <- chainTip (stale)\n");
return error("KomodoMiner: generated block is stale"); return error("KomodoMiner: generated block is stale");
}
} }
// Remove key from key pool // Remove key from key pool
@@ -677,7 +689,7 @@ void static BitcoinMiner(CWallet *pwallet)
if ( externalflag == 0 && i != 66 ) if ( externalflag == 0 && i != 66 )
printf("VIOLATION at %d\n",i); printf("VIOLATION at %d\n",i);
for (i=0; i<66; i++) for (i=0; i<66; i++)
{break; { break;
for (j=0; j<33; j++) for (j=0; j<33; j++)
printf("%02x",pubkeys[i][j]); printf("%02x",pubkeys[i][j]);
printf(" p%d -> %d\n",i,komodo_minerid(pindexPrev->nHeight-i,pubkeys[i])); printf(" p%d -> %d\n",i,komodo_minerid(pindexPrev->nHeight-i,pubkeys[i]));