test
This commit is contained in:
@@ -214,7 +214,7 @@ void komodo_gateway_deposits(CMutableTransaction *txNew,int32_t shortflag,char *
|
||||
|
||||
int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing
|
||||
{
|
||||
int32_t i,j,n,num,opretlen,offset=1; uint256 hash,txids[64]; uint8_t shortflag; char symbol[16],base[16]; uint16_t vouts[64]; uint8_t *script,opcode; struct pax_transaction *pax,space;
|
||||
int32_t i,j,n,num,opretlen,offset=1,errs=0,matched=0; uint256 hash,txids[64]; uint8_t shortflag; char symbol[16],base[16]; uint16_t vouts[64]; uint8_t *script,opcode; struct pax_transaction *pax,space;
|
||||
n = block.vtx[0].vout.size();
|
||||
script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data();
|
||||
if ( n <= 2 || script[0] != 0x6a )
|
||||
@@ -239,18 +239,26 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above
|
||||
{
|
||||
if ( (pax= komodo_paxfind(&space,txids[i-1],vouts[i-1])) != 0 && ((opcode == 'I' && pax->fiatoshis == block.vtx[0].vout[i].nValue) || (opcode == 'X' && pax->komodoshis == block.vtx[0].vout[i].nValue)) )
|
||||
{
|
||||
//printf("i.%d match %.8f == %.8f\n",i,dstr(pax != 0 ? pax->fiatoshis:-1),dstr(block.vtx[0].vout[i].nValue));
|
||||
if ( pax->marked != 0 )
|
||||
errs++;
|
||||
else matched++;
|
||||
printf("errs.%d i.%d match %.8f == %.8f\n",errs,i,dstr(pax != 0 ? pax->fiatoshis:-1),dstr(block.vtx[0].vout[i].nValue));
|
||||
komodo_paxmark(height,&space,txids[i-1],vouts[i-1],height);
|
||||
}
|
||||
else
|
||||
{
|
||||
hash = block.GetHash();
|
||||
//for (j=0; j<32; j++)
|
||||
// printf("%02x",((uint8_t *)&hash)[j]);
|
||||
//printf(" ht.%d blockhash couldnt find vout.[%d]\n",height,i);
|
||||
for (j=0; j<32; j++)
|
||||
printf("%02x",((uint8_t *)&hash)[j]);
|
||||
printf(" ht.%d blockhash couldnt find vout.[%d]\n",height,i);
|
||||
komodo_paxmark(height,&space,txids[i-1],vouts[i-1],height);
|
||||
}
|
||||
}
|
||||
if ( matched != num )
|
||||
{
|
||||
printf("matched.%d vs num.%d\n",matched,num);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
//printf("opretlen.%d num.%d\n",opretlen,num);
|
||||
}
|
||||
@@ -318,14 +326,14 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
|
||||
}
|
||||
else if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 )
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
{
|
||||
for (i=0; i<opretlen; i++)
|
||||
printf("%02x",opretbuf[i]);
|
||||
printf(" opret[%c] else path tokomodo.%d\n",opretbuf[0],tokomodo);
|
||||
}
|
||||
if ( tokomodo == 0 && opretbuf[0] == 'I' ) // assetchain coinbase
|
||||
{
|
||||
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
{
|
||||
for (i=0; i<opretlen; i++)
|
||||
printf("%02x",opretbuf[i]);
|
||||
printf(" opret[%c] tokomodo.%d\n",opretbuf[0],tokomodo);
|
||||
}
|
||||
if ( (n= komodo_issued_opreturn(&shortflag,base,txids,vouts,opretbuf,opretlen)) > 0 && shortflag == ASSETCHAINS_SHORTFLAG )
|
||||
{
|
||||
for (i=0; i<n; i++)
|
||||
|
||||
@@ -119,13 +119,11 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
while ( chainActive.Tip()->nHeight > ASSETCHAINS_MINHEIGHT && mempool.GetTotalTxSize() <= 0 )
|
||||
{
|
||||
deposits = komodo_paxtotal();
|
||||
sleep(10);
|
||||
if ( KOMODO_INITDONE == 0 || time(NULL) < KOMODO_INITDONE+60 )
|
||||
continue;
|
||||
if ( deposits != 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
sleep(10);
|
||||
}
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("miner KOMODO_DEPOSIT %llu pblock->nHeight %d mempool.GetTotalTxSize(%d)\n",(long long)komodo_paxtotal(),(int32_t)chainActive.Tip()->nHeight,(int32_t)mempool.GetTotalTxSize());
|
||||
@@ -446,8 +444,6 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33)
|
||||
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey)
|
||||
{
|
||||
CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i;
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
fprintf(stderr,"%s createnewblockwith key\n",ASSETCHAINS_SYMBOL);
|
||||
if ( USE_EXTERNAL_PUBKEY != 0 )
|
||||
{
|
||||
//fprintf(stderr,"use notary pubkey\n");
|
||||
@@ -562,8 +558,8 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
} while (true);
|
||||
//fprintf(stderr,"%s Found peers\n",ASSETCHAINS_SYMBOL);
|
||||
}
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
fprintf(stderr,"%s create new block\n",ASSETCHAINS_SYMBOL);
|
||||
//if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
// fprintf(stderr,"%s create new block\n",ASSETCHAINS_SYMBOL);
|
||||
//
|
||||
// Create new block
|
||||
//
|
||||
@@ -595,7 +591,7 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
Mining_height = pindexPrev->nHeight+1;
|
||||
while (true)
|
||||
{
|
||||
fprintf(stderr,"%s start mining loop\n",ASSETCHAINS_SYMBOL);
|
||||
//fprintf(stderr,"%s start mining loop\n",ASSETCHAINS_SYMBOL);
|
||||
// Hash state
|
||||
crypto_generichash_blake2b_state state;
|
||||
EhInitialiseState(n, k, state);
|
||||
@@ -621,8 +617,8 @@ void static BitcoinMiner(CWallet *pwallet)
|
||||
solutionTargetChecks.increment();
|
||||
if ( UintToArith256(pblock->GetHash()) > hashTarget )
|
||||
{
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
printf("missed target\n");
|
||||
//if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
// printf("missed target\n");
|
||||
return false;
|
||||
}
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && Mining_start != 0 && time(NULL) < Mining_start+20 )
|
||||
|
||||
Reference in New Issue
Block a user