Merge pull request #49 from jl777/jl777

Fix strange data bug
This commit is contained in:
blackjok3rtt
2019-04-01 16:28:15 +08:00
committed by GitHub
2 changed files with 7 additions and 12 deletions

View File

@@ -1665,7 +1665,7 @@ CScript komodo_mineropret(int32_t nHeight)
memcpy(pricebits,Mineropret.data(),Mineropret.size()); memcpy(pricebits,Mineropret.data(),Mineropret.size());
if ( komodo_pricecmp(0,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 ) if ( komodo_pricecmp(0,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 )
{ {
// if the new prices are not within tolerance, update Mineropret with clipped prices // if the new prices are outside tolerance, update Mineropret with clamped prices
komodo_priceclamp(n,pricebits,prevbits,PRICES_MAXCHANGE); komodo_priceclamp(n,pricebits,prevbits,PRICES_MAXCHANGE);
fprintf(stderr,"update Mineropret to clamped prices\n"); fprintf(stderr,"update Mineropret to clamped prices\n");
memcpy(Mineropret.data(),pricebits,Mineropret.size()); memcpy(Mineropret.data(),pricebits,Mineropret.size());
@@ -1722,17 +1722,10 @@ int32_t komodo_opretvalidate(int32_t nHeight,CScript scriptPubKey)
for (i=1; i<n; i++) for (i=1; i<n; i++)
fprintf(stderr,"%.4f ",(double)pricebits[i]/10000); fprintf(stderr,"%.4f ",(double)pricebits[i]/10000);
fprintf(stderr," newprices.%d\n",nHeight); fprintf(stderr," newprices.%d\n",nHeight);
sleep(3);
memcpy(pricebits,vopret.data(),Mineropret.size()); fprintf(stderr,"vs prev maxflag.%d cmp error\n",maxflag);
if ( komodo_heightpricebits(prevbits,nHeight-1) == 0 )
{
if ( komodo_pricecmp(nHeight,n,&maxflag,pricebits,prevbits,PRICES_MAXCHANGE) < 0 )
{
fprintf(stderr,"vs prev maxflag.%d cmp error\n",maxflag);
return(-1); return(-1);
} } // else this is the good case we hope to happen
}
}
} else return(-1); } else return(-1);
if ( lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() >= PRICES_SIZEBIT0 ) if ( lag < ASSETCHAINS_BLOCKTIME && Mineropret.size() >= PRICES_SIZEBIT0 )
{ {
@@ -2030,6 +2023,8 @@ int32_t get_btcusd(uint32_t pricebits[4])
} }
// komodo_cbopretupdate() obtains the external price data and encodes it into Mineropret, which will then be used by the miner and validation // komodo_cbopretupdate() obtains the external price data and encodes it into Mineropret, which will then be used by the miner and validation
// save history, use new data to approve past rejection, where is the auto-reconsiderblock?
// 51% correlation, smoothing
void komodo_cbopretupdate() void komodo_cbopretupdate()
{ {

View File

@@ -2067,7 +2067,7 @@ void komodo_args(char *argv0)
if ( ASSETCHAINS_CBOPRET != 0 ) if ( ASSETCHAINS_CBOPRET != 0 )
{ {
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBOPRET),(void *)&ASSETCHAINS_CBOPRET); extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_CBOPRET),(void *)&ASSETCHAINS_CBOPRET);
//komodo_cbopretupdate(); // will set Mineropret komodo_cbopretupdate(); // will set Mineropret
fprintf(stderr,"This blockchain uses data produced from CoinDesk Bitcoin Price Index\n"); fprintf(stderr,"This blockchain uses data produced from CoinDesk Bitcoin Price Index\n");
} }
} }