Merge pull request #85 from jl777/dev

rebased, fixed paxpending, new mining effective 110000
This commit is contained in:
jl777
2016-12-13 10:12:58 +02:00
committed by GitHub
2 changed files with 33 additions and 20 deletions

View File

@@ -344,14 +344,17 @@ int32_t komodo_pending_withdraws(char *opretstr)
return(0); return(0);
HASH_ITER(hh,PAX,pax,tmp) HASH_ITER(hh,PAX,pax,tmp)
{ {
printf("pax %s marked.%u approved.%u\n",pax->symbol,pax->marked,pax->approved); if ( pax->type == 'W' )
if ( pax->marked == 0 && strcmp((char *)"KMD",pax->symbol) == 0 && pax->approved == 0 && pax->validated != 0 )
{ {
// add 'A' opreturn entry //printf("pax %s marked.%u approved.%u validated.%llu\n",pax->symbol,pax->marked,pax->approved,(long long)pax->validated);
if ( len == 0 ) if ( pax->marked == 0 && strcmp((char *)"KMD",pax->symbol) == 0 && pax->approved == 0 && pax->validated != 0 )
opretbuf[len++] = 'A'; {
len += komodo_rwapproval(1,&opretbuf[len],pax); // add 'A' opreturn entry
//printf("%s.(marked.%u approved.%d) %p\n",pax->source,pax->marked,pax->approved,pax); if ( len == 0 )
opretbuf[len++] = 'A';
len += komodo_rwapproval(1,&opretbuf[len],pax);
//printf("%s.(marked.%u approved.%d) %p\n",pax->source,pax->marked,pax->approved,pax);
}
} }
} }
if ( len > 0 ) if ( len > 0 )
@@ -366,7 +369,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[16384],data[16384]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t available,deposited,issued,withdrawn,approved,redeemed,mask; struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[16384],data[16384]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t available,deposited,issued,withdrawn,approved,redeemed,mask;
sp = komodo_stateptr(symbol,dest); sp = komodo_stateptr(symbol,dest);
strcpy(symbol,base); strcpy(symbol,base);
if ( komodo_baseid(base) < 0 ) if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) < 0 )
return(0); return(0);
PENDING_KOMODO_TX = 0; PENDING_KOMODO_TX = 0;
if ( tokomodo == 0 ) if ( tokomodo == 0 )
@@ -400,7 +403,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
//printf("pax->symbol.%s != %s or null pax->validated %.8f\n",pax->symbol,symbol,dstr(pax->validated)); //printf("pax->symbol.%s != %s or null pax->validated %.8f\n",pax->symbol,symbol,dstr(pax->validated));
continue; continue;
} }
//if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis));
txNew->vout.resize(numvouts+1); txNew->vout.resize(numvouts+1);
txNew->vout[numvouts].nValue = (opcode == 'I') ? pax->fiatoshis : pax->komodoshis; txNew->vout[numvouts].nValue = (opcode == 'I') ? pax->fiatoshis : pax->komodoshis;
@@ -566,10 +569,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
{ {
uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff;
const char *typestr = "unknown"; const char *typestr = "unknown";
if ( ASSETCHAINS_SYMBOL[0] == 0 ) if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) < 0 )
return("komodo"); {
else if ( komodo_baseid(ASSETCHAINS_SYMBOL) < 0 ) //printf("komodo_opreturn skip %s\n",ASSETCHAINS_SYMBOL);
return("assetchain"); return("assetchain");
}
memset(baseids,0xff,sizeof(baseids)); memset(baseids,0xff,sizeof(baseids));
memset(values,0,sizeof(values)); memset(values,0,sizeof(values));
memset(srcvalues,0,sizeof(srcvalues)); memset(srcvalues,0,sizeof(srcvalues));
@@ -577,7 +581,6 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
memset(kmdheights,0,sizeof(kmdheights)); memset(kmdheights,0,sizeof(kmdheights));
memset(otherheights,0,sizeof(otherheights)); memset(otherheights,0,sizeof(otherheights));
tokomodo = (komodo_is_issuer() == 0); tokomodo = (komodo_is_issuer() == 0);
printf("OPRETURN[%c]\n",opretbuf[0]);
if ( opretbuf[0] == 'D' ) if ( opretbuf[0] == 'D' )
{ {
tokomodo = 0; tokomodo = 0;
@@ -733,7 +736,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
if ( (pax= komodo_paxfind(txid,vout,'W')) != 0 ) if ( (pax= komodo_paxfind(txid,vout,'W')) != 0 )
{ {
pax->type = opretbuf[0]; pax->type = opretbuf[0];
strcpy(pax->symbol,base); strcpy(pax->source,base);
strcpy(pax->symbol,"KMD");
pax->height = kmdheight; pax->height = kmdheight;
pax->otherheight = height; pax->otherheight = height;
pax->komodoshis = komodoshis; pax->komodoshis = komodoshis;
@@ -879,7 +883,7 @@ void komodo_passport_iteration()
printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]);
} //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp));
fclose(fp); fclose(fp);
} } else printf("error.(%s) %p\n",fname,sp);
komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime"); komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime");
if ( (fp= fopen(fname,"rb")) != 0 ) if ( (fp= fopen(fname,"rb")) != 0 )
{ {

View File

@@ -130,15 +130,24 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
if ( nonz == 0 ) if ( nonz == 0 )
return(true); // will come back via different path with pubkey set return(true); // will come back via different path with pubkey set
special2 = komodo_is_special(height,pubkey33); special2 = komodo_is_special(height,pubkey33);
if ( notaryid >= 0 && ((height >= 64000 && height <= 90065) || (height % KOMODO_ELECTION_GAP) > 64) ) /*if ( notaryid >= 0 && ((height >= 64000 && height <= 90065) || (height % KOMODO_ELECTION_GAP) > 64) )
{ {
//if ( special2 == -2 )
// printf("height.%d special2.%d special.%d\n",height,special2,special);
if ( (height >= 64000 && height <= 90065) || (height % KOMODO_ELECTION_GAP) == 0 || (height < 80000 && (special != 0 || special2 > 0)) || (height >= 80000 && special2 > 0) ) if ( (height >= 64000 && height <= 90065) || (height % KOMODO_ELECTION_GAP) == 0 || (height < 80000 && (special != 0 || special2 > 0)) || (height >= 80000 && special2 > 0) )
{ {
bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow); bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
flag = 1; flag = 1;
} }
}*/
if ( notaryid >= 0 )
{
if ( height < 80000 && (special != 0 || special2 > 0) )
flag = 1;
else if ( height >= 80000 && height < 108000 && special2 > 0 )
flag = 1;
else if ( height >= 108000 && special2 > 0 )
flag = ((height % KOMODO_ELECTION_GAP) > 64 || (height % KOMODO_ELECTION_GAP) == 0);
if ( flag != 0 )
bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
} }
} }
if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit)) if (fNegative || bnTarget == 0 || fOverflow || bnTarget > UintToArith256(params.powLimit))
@@ -146,7 +155,6 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
// Check proof of work matches claimed amount // Check proof of work matches claimed amount
if ( UintToArith256(hash) > bnTarget ) if ( UintToArith256(hash) > bnTarget )
{ {
if ( height > 110000 )
{ {
int32_t i; int32_t i;
for (i=31; i>=0; i--) for (i=31; i>=0; i--)
@@ -155,7 +163,8 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
for (i=31; i>=0; i--) for (i=31; i>=0; i--)
printf("%02x",((uint8_t *)&bnTarget)[i]); printf("%02x",((uint8_t *)&bnTarget)[i]);
printf(" ht.%d REWIND.%d special.%d notaryid.%d ht.%d mod.%d error\n",height,KOMODO_REWIND,special,notaryid,height,(height % 35)); printf(" ht.%d REWIND.%d special.%d notaryid.%d ht.%d mod.%d error\n",height,KOMODO_REWIND,special,notaryid,height,(height % 35));
return error("CheckProofOfWork(): hash doesn't match nBits"); if ( height < 90000 || height > 110000 )
return error("CheckProofOfWork(): hash doesn't match nBits");
} }
} }
return true; return true;