Merge pull request #57 from jl777/acspeed

Acspeed
This commit is contained in:
jl777
2016-11-21 20:10:24 -03:00
committed by GitHub
10 changed files with 104 additions and 48 deletions

33
src/assetfunds Executable file
View File

@@ -0,0 +1,33 @@
#!/bin/bash
./komodo-cli paxdeposit $1 aud 0.01
./komodo-cli paxdeposit $1 bgn 0.01
./komodo-cli paxdeposit $1 cad 0.01
./komodo-cli paxdeposit $1 chf 0.01
./komodo-cli paxdeposit $1 cny 0.01
./komodo-cli paxdeposit $1 czk 0.01
./komodo-cli paxdeposit $1 dkk 0.01
./komodo-cli paxdeposit $1 eur 0.01
./komodo-cli paxdeposit $1 gbp 0.01
./komodo-cli paxdeposit $1 hkd 0.01
./komodo-cli paxdeposit $1 hrk 0.01
./komodo-cli paxdeposit $1 huf 0.01
./komodo-cli paxdeposit $1 idr 0.01
./komodo-cli paxdeposit $1 ils 0.01
./komodo-cli paxdeposit $1 inr 0.01
./komodo-cli paxdeposit $1 jpy 0.01
./komodo-cli paxdeposit $1 krw 0.01
./komodo-cli paxdeposit $1 mxn 0.01
./komodo-cli paxdeposit $1 myr 0.01
./komodo-cli paxdeposit $1 nok 0.01
./komodo-cli paxdeposit $1 nzd 0.01
./komodo-cli paxdeposit $1 php 0.01
./komodo-cli paxdeposit $1 pln 0.01
./komodo-cli paxdeposit $1 brl 0.01
./komodo-cli paxdeposit $1 ron 0.01
./komodo-cli paxdeposit $1 rub 0.01
./komodo-cli paxdeposit $1 sek 0.01
./komodo-cli paxdeposit $1 sgd 0.01
./komodo-cli paxdeposit $1 thb 0.01
./komodo-cli paxdeposit $1 try 0.01
./komodo-cli paxdeposit $1 usd 0.01
./komodo-cli paxdeposit $1 zar 0.01

View File

@@ -99,7 +99,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char
errs++;
if ( fread(&notarized_desttxid,1,sizeof(notarized_desttxid),fp) != sizeof(notarized_desttxid) )
errs++;
if ( 0 && sp != 0 )
//if ( 0 && sp != 0 )
printf("%s %p %p[%d] load[%s] NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,sp,sp->NPOINTS,sp->NUM_NPOINTS,symbol,notarized_height,notarized_hash.ToString().c_str());
//if ( matched != 0 ) global independent states -> inside *sp
komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height);
@@ -139,7 +139,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char
}
else if ( func == 'R' )
{
uint16_t olen,v; uint64_t ovalue; uint256 txid; uint8_t opret[10000];
uint16_t olen,v; uint64_t ovalue; uint256 txid; uint8_t opret[16384];
if ( fread(&txid,1,sizeof(txid),fp) != sizeof(txid) )
errs++;
if ( fread(&v,1,sizeof(v),fp) != sizeof(v) )
@@ -152,7 +152,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char
{
if ( fread(opret,1,olen,fp) != olen )
errs++;
if ( matched != 0 )
//if ( matched != 0 )
{
int32_t i; for (i=0; i<olen; i++)
printf("%02x",opret[i]);
@@ -177,7 +177,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char
//printf("load pvals ht.%d numpvals.%d\n",ht,numpvals);
} else printf("error loading pvals[%d]\n",numpvals);
}
else printf("illegal func.(%d %c)\n",func,func);
else printf("[%s] %s illegal func.(%d %c)\n",ASSETCHAINS_SYMBOL,symbol,func,func);
return(func);
} else return(-1);
}
@@ -379,7 +379,10 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
sp->NOTARIZED_DESTTXID = desttxid;
komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0);
if ( opretlen > len && scriptbuf[len] == 'A' )
{
printf("Found extradata.[%d]\n",opretlen-len);
komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len,j);
}
} else printf("notarized.%d %llx reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",notarized,(long long)signedmask,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]);
}
else if ( i == 0 && j == 1 && opretlen == 149 )
@@ -444,8 +447,12 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
int32_t i,j,k,numnotaries,notarized,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count;
memset(&zero,0,sizeof(zero));
komodo_init(pindex->nHeight);
KOMODO_INITDONE = (uint32_t)time(NULL);
if ( (sp= komodo_stateptr(symbol,dest)) == 0 )
{
fprintf(stderr,"unexpected null komodostateptr.[%s]\n",ASSETCHAINS_SYMBOL);
return;
}
numnotaries = komodo_notaries(pubkeys,pindex->nHeight);
calc_rmd160_sha256(rmd160,pubkeys[0],33);
if ( pindex->nHeight > hwmheight )
@@ -457,15 +464,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
komodo_stateupdate(pindex->nHeight,0,0,0,zero,0,0,0,0,-pindex->nHeight,pindex->nTime,0,0,0,0);
}
komodo_currentheight_set(chainActive.Tip()->nHeight);
if ( ASSETCHAINS_SYMBOL[0] != 0 )
{
while ( KOMODO_PASSPORT_INITDONE == 0 )
{
fprintf(stderr,"komodo_connect.(%s) waiting for KOMODO_PASSPORT_INITDONE.%u\n",ASSETCHAINS_SYMBOL,KOMODO_PASSPORT_INITDONE);
sleep(3);
}
}
//KOMODO_INITDONE = (uint32_t)time(NULL);
printf("HWM.%d connect.%d\n",chainActive.Tip()->nHeight,pindex->nHeight);
if ( pindex != 0 )
{
height = pindex->nHeight;
@@ -487,9 +486,10 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
}
}
numvalid = bitweight(signedmask);
printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts);
if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) )
{
//printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts);
printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts);
notarized = 1;
}
for (j=0; j<numvouts; j++)
@@ -549,7 +549,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
}
if ( pindex->nHeight == hwmheight )
komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0);
} else printf("komodo_connectblock: unexpected null pindex\n");
} else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n");
//KOMODO_INITDONE = (uint32_t)time(NULL);
}

View File

@@ -535,7 +535,7 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33])
komodo_chosennotary(&notaryid,height,pubkey33);
if ( height >= 34000 && notaryid >= 0 )
{
for (i=1; i<64; i++)
for (i=1; i<60; i++)
{
if ( komodo_minerid(height-i) == notaryid )
{
@@ -550,12 +550,14 @@ int32_t komodo_is_special(int32_t height,uint8_t pubkey33[33])
int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 hash)
{
int32_t notarized_height; uint256 notarized_hash,notarized_desttxid; CBlockIndex *notary;
notarized_height = komodo_notarizeddata(chainActive.Tip()->nHeight,&notarized_hash,&notarized_desttxid);
int32_t notarized_height; uint256 notarized_hash,notarized_desttxid; CBlockIndex *notary; CBlockIndex *pindex;
if ( (pindex= chainActive.Tip()) == 0 )
return(-1);
notarized_height = komodo_notarizeddata(pindex->nHeight,&notarized_hash,&notarized_desttxid);
*notarized_heightp = notarized_height;
if ( notarized_height >= 0 && notarized_height <= chainActive.Tip()->nHeight && (notary= mapBlockIndex[notarized_hash]) != 0 )
if ( notarized_height >= 0 && notarized_height <= pindex->nHeight && (notary= mapBlockIndex[notarized_hash]) != 0 )
{
//printf("nHeight.%d -> (%d %s)\n",chainActive.Tip()->nHeight,notarized_height,notarized_hash.ToString().c_str());
//printf("nHeight.%d -> (%d %s)\n",pindex->Tip()->nHeight,notarized_height,notarized_hash.ToString().c_str());
if ( notary->nHeight == notarized_height ) // if notarized_hash not in chain, reorg
{
if ( nHeight < notarized_height )
@@ -570,7 +572,7 @@ int32_t komodo_checkpoint(int32_t *notarized_heightp,int32_t nHeight,uint256 has
}
} else fprintf(stderr,"unexpected error notary_hash %s ht.%d at ht.%d\n",notarized_hash.ToString().c_str(),notarized_height,notary->nHeight);
} else if ( notarized_height > 0 && notarized_height != 73880 )
fprintf(stderr,"[%s] couldnt find notarized.(%s %d) ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height,chainActive.Tip()->nHeight);
fprintf(stderr,"[%s] couldnt find notarized.(%s %d) ht.%d\n",ASSETCHAINS_SYMBOL,notarized_hash.ToString().c_str(),notarized_height,pindex->nHeight);
return(0);
}
@@ -611,11 +613,11 @@ uint64_t komodo_accrued_interest(int32_t *txheightp,uint32_t *locktimep,uint256
int32_t komodo_isrealtime(int32_t *kmdheightp)
{
struct komodo_state *sp;
struct komodo_state *sp; CBlockIndex *pindex;
if ( (sp= komodo_stateptrget((char *)"KMD")) != 0 )
*kmdheightp = sp->CURRENT_HEIGHT;
else *kmdheightp = 0;
if ( chainActive.Tip()->nHeight == (int32_t)komodo_longestchain() )
if ( (pindex= chainActive.Tip()) != 0 && pindex->nHeight == (int32_t)komodo_longestchain() )
return(1);
else return(0);
}

View File

@@ -74,7 +74,7 @@ void komodo_eventadd_pricefeed(struct komodo_state *sp,char *symbol,int32_t heig
void komodo_eventadd_opreturn(struct komodo_state *sp,char *symbol,int32_t height,uint256 txid,uint64_t value,uint16_t vout,uint8_t *buf,uint16_t opretlen)
{
struct komodo_event_opreturn O; uint8_t opret[10000];
struct komodo_event_opreturn O; uint8_t opret[16384];
memset(&O,0,sizeof(O));
O.txid = txid;
O.value = value;

View File

@@ -163,17 +163,21 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t
uint64_t komodo_paxtotal()
{
struct pax_transaction *pax,*tmp; int32_t ht; uint64_t total = 0;
struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; int32_t ht; uint64_t total = 0;
if ( komodo_isrealtime(&ht) == 0 )
return(0);
komodo_stateptr(symbol,dest);
HASH_ITER(hh,PAX,pax,tmp)
{
//printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis));
if ( pax->marked == 0 )
if ( strcmp(symbol,pax->symbol) == 0 )
{
if ( komodo_is_issuer() != 0 )
total += pax->fiatoshis;
else total += pax->komodoshis;
if ( pax->marked == 0 )
{
if ( komodo_is_issuer() != 0 )
total += pax->fiatoshis;
else total += pax->komodoshis;
}
}
}
//printf("paxtotal %.8f\n",dstr(total));
@@ -182,7 +186,7 @@ uint64_t komodo_paxtotal()
int32_t komodo_pending_withdraws(char *opretstr)
{
struct pax_transaction *pax,*tmp; uint8_t opretbuf[10000]; int32_t ht,len=0; uint64_t total = 0;
struct pax_transaction *pax,*tmp; uint8_t opretbuf[16384]; int32_t ht,len=0; uint64_t total = 0;
if ( komodo_isrealtime(&ht) == 0 || ASSETCHAINS_SYMBOL[0] != 0 )
return(0);
HASH_ITER(hh,PAX,pax,tmp)
@@ -204,7 +208,7 @@ int32_t komodo_pending_withdraws(char *opretstr)
int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t tokomodo)
{
struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[10000],data[10000]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t 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 mask;
sp = komodo_stateptr(symbol,dest);
strcpy(symbol,base);
PENDING_KOMODO_TX = 0;
@@ -392,7 +396,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
for (i=0; i<33; i++)
printf("%02x",pubkey33[i]);
printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height);
if ( value == checktoshis )//value >= checktoshis || (seed == 0 && diff < .01) )
if ( value >= checktoshis-(checktoshis >> 10) )
{
if ( komodo_paxfind(&space,txid,vout) == 0 )
{
@@ -412,7 +416,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value);
typestr = "withdraw";
printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr);
if ( checktoshis == komodoshis )
if ( checktoshis <= komodoshis+(komodoshis >> 10) )
{
if ( (pax= komodo_paxfind(&space,txid,vout)) == 0 )
{
@@ -423,6 +427,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
}
else if ( tokomodo != 0 && opretbuf[0] == 'A' )
{
printf("extra 'A' opret[%d]\n",opretlen);
if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 )
{
for (i=0; i<n; i++)
@@ -431,11 +436,16 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3
{
bitcoin_address(coinaddr,60,&rmd160s[i*20],20);
komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]]);
}
printf("i.%d (%s) <- %.8f\n",i,coinaddr,dstr(values[i]));
} else printf("i.%d pax.%p baseids[] %d\n",i,pax,baseids[i]);
if ( (pax= komodo_paxfind(&space,txids[i],vouts[i])) != 0 )
{
pax->approved = kmdheights[i];
printf("i.%d approved.%d\n",i,kmdheights[i]);
}
}
}
printf("extra.[%d]\n",n);
}
else if ( tokomodo == 0 && opretbuf[0] == 'I' )
{

View File

@@ -676,14 +676,18 @@ bool IsStandardTx(const CTransaction& tx, string& reason)
txnouttype whichType;
BOOST_FOREACH(const CTxOut& txout, tx.vout)
{
if (!::IsStandard(txout.scriptPubKey, whichType)) {
if (!::IsStandard(txout.scriptPubKey, whichType))
{
reason = "scriptpubkey";
fprintf(stderr,"vout.%d nDataout.%d\n",v,nDataOut);
fprintf(stderr,">>>>>>>>>>>>>>> vout.%d nDataout.%d\n",v,nDataOut);
return false;
}
if (whichType == TX_NULL_DATA)
{
nDataOut++;
//fprintf(stderr,"is OP_RETURN\n");
}
else if ((whichType == TX_MULTISIG) && (!fIsBareMultisigStd)) {
reason = "bare-multisig";
return false;

View File

@@ -550,8 +550,8 @@ void static BitcoinMiner(CWallet *pwallet)
{
if (chainparams.MiningRequiresPeers())
{
if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 )
break;
//if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 )
// break;
// Busy-wait for the network to come online so we don't waste time mining
// on an obsolete chain. In regtest mode we expect to fly solo.
//fprintf(stderr,"Wait for peers...\n");
@@ -569,6 +569,11 @@ void static BitcoinMiner(CWallet *pwallet)
} while (true);
//fprintf(stderr,"%s Found peers\n",ASSETCHAINS_SYMBOL);
}
/*while ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight < 100 )
{
fprintf(stderr,"%s waiting for block 100, ht.%d\n",ASSETCHAINS_SYMBOL,chainActive.Tip()->nHeight);
sleep(3);
}*/
//
// Create new block
//
@@ -652,10 +657,6 @@ void static BitcoinMiner(CWallet *pwallet)
cancelSolver = false;
}
KOMODO_CHOSEN_ONE = 0;
int32_t i; uint256 hash = pblock->GetHash();
for (i=0; i<32; i++)
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
fprintf(stderr," <- %s Block found %d\n",ASSETCHAINS_SYMBOL,Mining_height);
SetThreadPriority(THREAD_PRIORITY_LOWEST);
// In regression test mode, stop mining after a block is found.
if (chainparams.MineBlocksOnDemand()) {
@@ -709,6 +710,10 @@ void static BitcoinMiner(CWallet *pwallet)
bool found = EhOptimisedSolve(n, k, curr_state, validBlock, cancelled);
ehSolverRuns.increment();
if (found) {
int32_t i; uint256 hash = pblock->GetHash();
for (i=0; i<32; i++)
fprintf(stderr,"%02x",((uint8_t *)&hash)[i]);
fprintf(stderr," <- %s Block found %d\n",ASSETCHAINS_SYMBOL,Mining_height);
break;
}
} catch (EhSolverCancelledException&) {

View File

@@ -135,8 +135,8 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in
special2 = komodo_is_special(height,pubkey33);
if ( special2 == -2 )
printf("height.%d special2.%d special.%d\n",height,special2,special);
if ( special2 == -2 || (height < 70000 && (special != 0 || special2 > 0)) ||
(height >= 70000 && special2 > 0) )
if ( special2 == -2 || (height < 80000 && (special != 0 || special2 > 0)) ||
(height >= 80000 && special2 > 0) )
{
bnTarget.SetCompact(KOMODO_MINDIFF_NBITS,&fNegative,&fOverflow);
flag = 1;

View File

@@ -398,9 +398,9 @@ Value notaries(const Array& params, bool fHelp)
if ( height < 0 )
height = 0;
//fprintf(stderr,"notaries as of height.%d\n",height);
if ( height > chainActive.Height()+20000 )
throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
else
//if ( height > chainActive.Height()+20000 )
// throw JSONRPCError(RPC_INVALID_PARAMETER, "Block height out of range");
//else
{
if ( (n= komodo_notaries(pubkeys,height)) > 0 )
{

View File

@@ -144,7 +144,10 @@ bool Solver(const CScript& scriptPubKey, txnouttype& typeRet, vector<vector<unsi
{
// small pushdata, <= nMaxDatacarrierBytes
if (vch1.size() > nMaxDatacarrierBytes)
{
fprintf(stderr,"size.%d > nMaxDatacarrier.%d\n",(int32_t)vch1.size(),(int32_t)nMaxDatacarrierBytes);
break;
}
}
else if (opcode1 != opcode2 || vch1 != vch2)
{
@@ -202,7 +205,6 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType)
if (m < 1 || m > n)
return false;
}
return whichType != TX_NONSTANDARD;
}