Merge branch 'FSM' of https://github.com/jl777/komodo into noStreamer
a
This commit is contained in:
2
src/ac/zex
Executable file
2
src/ac/zex
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=ZEX $1 $2 $3 $4 $5 $6
|
||||
@@ -1,14 +1,134 @@
|
||||
[
|
||||
{
|
||||
"ac_name": "CFEK",
|
||||
"ac_supply": "100000",
|
||||
"ac_reward": "10000000000000",
|
||||
"ac_staked": "51",
|
||||
"ac_cc": "102",
|
||||
"addnode": [
|
||||
"195.201.137.5",
|
||||
"195.201.20.230"
|
||||
]
|
||||
"ac_name": "REVS",
|
||||
"ac_supply": "1300000"
|
||||
},
|
||||
{
|
||||
"ac_name": "SUPERNET",
|
||||
"ac_supply": "816061"
|
||||
},
|
||||
{
|
||||
"ac_name": "DEX",
|
||||
"ac_supply": "999999"
|
||||
},
|
||||
{
|
||||
"ac_name": "PANGEA",
|
||||
"ac_supply": "999999"
|
||||
},
|
||||
{
|
||||
"ac_name": "JUMBLR",
|
||||
"ac_supply": "999999"
|
||||
},
|
||||
{
|
||||
"ac_name": "BET",
|
||||
"ac_supply": "999999"
|
||||
},
|
||||
{
|
||||
"ac_name": "CRYPTO",
|
||||
"ac_supply": "999999"
|
||||
},
|
||||
{
|
||||
"ac_name": "HODL",
|
||||
"ac_supply": "9999999"
|
||||
},
|
||||
{
|
||||
"ac_name": "MSHARK",
|
||||
"ac_supply": "1400000"
|
||||
},
|
||||
{
|
||||
"ac_name": "BOTS",
|
||||
"ac_supply": "999999"
|
||||
},
|
||||
{
|
||||
"ac_name": "MGW",
|
||||
"ac_supply": "999999"
|
||||
},
|
||||
{
|
||||
"ac_name": "COQUI",
|
||||
"ac_supply": "72000000",
|
||||
"ac_ccactivate": "200000"
|
||||
},
|
||||
{
|
||||
"ac_name": "WLC",
|
||||
"ac_supply": "210000000"
|
||||
},
|
||||
{
|
||||
"ac_name": "KV",
|
||||
"ac_supply": "1000000"
|
||||
},
|
||||
{
|
||||
"ac_name": "CEAL",
|
||||
"ac_supply": "366666666"
|
||||
},
|
||||
{
|
||||
"ac_name": "MESH",
|
||||
"ac_supply": "1000007"
|
||||
},
|
||||
{
|
||||
"ac_name": "MNZ",
|
||||
"ac_supply": "257142858"
|
||||
},
|
||||
{
|
||||
"ac_name": "AXO",
|
||||
"ac_supply": "200000000"
|
||||
},
|
||||
{
|
||||
"ac_name": "ETOMIC",
|
||||
"ac_supply": "100000000"
|
||||
},
|
||||
{
|
||||
"ac_name": "BTCH",
|
||||
"ac_supply": "20998641"
|
||||
},
|
||||
{
|
||||
"ac_name": "PIZZA",
|
||||
"ac_supply": "100000000"
|
||||
},
|
||||
{
|
||||
"ac_name": "BEER",
|
||||
"ac_supply": "100000000"
|
||||
},
|
||||
{
|
||||
"ac_name": "NINJA",
|
||||
"ac_supply": "100000000"
|
||||
},
|
||||
{
|
||||
"ac_name": "OOT",
|
||||
"ac_supply": "216000000"
|
||||
},
|
||||
{
|
||||
"ac_name": "BNTN",
|
||||
"ac_supply": "500000000"
|
||||
},
|
||||
{
|
||||
"ac_name": "CHAIN",
|
||||
"ac_supply": "999999"
|
||||
},
|
||||
{
|
||||
"ac_name": "PRLPAY",
|
||||
"ac_supply": "500000000"
|
||||
},
|
||||
{
|
||||
"ac_name": "DSEC",
|
||||
"ac_supply": "7000000"
|
||||
},
|
||||
{
|
||||
"ac_name": "GLXT",
|
||||
"ac_supply": "10000000000"
|
||||
},
|
||||
{
|
||||
"ac_name": "EQL",
|
||||
"ac_supply": "500000000",
|
||||
"ac_ccactivate": "205000"
|
||||
},
|
||||
{
|
||||
"ac_name": "ZILLA",
|
||||
"ac_supply": "11000000"
|
||||
},
|
||||
{
|
||||
"ac_name": "RFOX",
|
||||
"ac_supply": "1000000000",
|
||||
"ac_reward": "100000000"
|
||||
},
|
||||
{
|
||||
"ac_name": "CFEKED",
|
||||
@@ -76,5 +196,28 @@
|
||||
"addnode": [
|
||||
"51.75.124.34"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ac_name": "KMDICE",
|
||||
"ac_supply": "10500000",
|
||||
"ac_reward": "2500000000",
|
||||
"ac_halving": "210000",
|
||||
"ac_cc": "2",
|
||||
"addressindex": "1",
|
||||
"spentindex": "1",
|
||||
"addnode": [
|
||||
"144.76.217.232"
|
||||
]
|
||||
},
|
||||
{
|
||||
"ac_name": "ZEX",
|
||||
"ac_founders": "1",
|
||||
"ac_reward": "13000000000",
|
||||
"ac_halving": "525600",
|
||||
"ac_cc": "2",
|
||||
"ac_pubkey": "039d4a50cc70d1184e462a22edb3b66385da97cc8059196f8305c184a3e21440af",
|
||||
"addnode": [
|
||||
"5.9.102.210"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
@@ -33,7 +33,7 @@ echo $pubkey
|
||||
./komodod -pubkey=$pubkey -ac_name=PRLPAY -ac_supply=500000000 -addnode=13.250.226.125 &
|
||||
./komodod -pubkey=$pubkey -ac_name=DSEC -ac_supply=7000000 -addnode=185.148.147.30 &
|
||||
./komodod -pubkey=$pubkey -ac_name=GLXT -ac_supply=10000000000 -addnode=13.230.224.15 &
|
||||
./komodod -pubkey=$pubkey -ac_name=EQL -ac_supply=500000000 -addnode=46.101.124.153 &
|
||||
./komodod -pubkey=$pubkey -ac_name=EQL -ac_supply=500000000 -ac_ccactivate=205000 -addnode=46.101.124.153 &
|
||||
./komodod -pubkey=$pubkey -ac_name=ZILLA -ac_supply=11000000 -addnode=54.39.23.248 &
|
||||
./komodod -pubkey=$pubkey -ac_name=RFOX -ac_supply=1000000000 -ac_reward=100000000 -addnode=78.47.196.146 &
|
||||
~/VerusCoin/src/komodod -pubkey=$pubkey -ac_name=VRSC -ac_algo=verushash -ac_cc=1 -ac_veruspos=50 -ac_supply=0 -ac_eras=3 -ac_reward=0,38400000000,2400000000 -ac_halving=1,43200,1051920 -ac_decay=100000000,0,0 -ac_end=10080,226080,0 -ac_timelockgte=19200000000 -ac_timeunlockfrom=129600 -ac_timeunlockto=1180800 -addnode=185.25.48.236 -addnode=185.64.105.111 &
|
||||
@@ -44,3 +44,4 @@ echo $pubkey
|
||||
./komodod -pubkey=$pubkey -ac_name=PGT -ac_supply=10000000 -ac_end=1 -addnode=190.114.254.104 &
|
||||
./komodod -pubkey=$pubkey -ac_name=KMDICE -ac_supply=10500000 -ac_reward=2500000000 -ac_halving=210000 -ac_cc=2 -addressindex=1 -spentindex=1 -addnode=144.76.217.232 &
|
||||
./komodod -pubkey=$pubkey -ac_name=DION -ac_supply=3900000000 -ac_reward=22260000000 -ac_staked=100 -ac_cc=1 -ac_end=4300000000 -addnode=51.75.124.34 &
|
||||
./komodod -pubkey=$pubkey -ac_name=ZEX -ac_cc=2 -ac_founders=1 -ac_halving=525600 -ac_reward=13000000000 -ac_pubkey=039d4a50cc70d1184e462a22edb3b66385da97cc8059196f8305c184a3e21440af -addnode=5.9.102.210 &
|
||||
|
||||
@@ -178,6 +178,7 @@ std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTr
|
||||
void SetCCunspents(std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > &unspentOutputs,char *coinaddr);
|
||||
void SetCCtxids(std::vector<std::pair<CAddressIndexKey, CAmount> > &addressIndex,char *coinaddr);
|
||||
int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs);
|
||||
int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs);
|
||||
int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout);
|
||||
|
||||
// curve25519 and sha256
|
||||
|
||||
@@ -431,3 +431,92 @@ int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int3
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs)
|
||||
{
|
||||
int32_t abovei,belowi,ind,vout,i,n = 0,maxutxos=64; int64_t sum,threshold,above,below; int64_t remains,nValue,totalinputs = 0; char coinaddr[64]; uint256 txid,hashBlock; CTransaction tx; struct CC_utxo *utxos,*up;
|
||||
std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> > unspentOutputs;
|
||||
utxos = (struct CC_utxo *)calloc(maxutxos,sizeof(*utxos));
|
||||
threshold = total/(maxinputs+1);
|
||||
if ( maxinputs > maxutxos )
|
||||
maxutxos = maxinputs;
|
||||
sum = 0;
|
||||
Getscriptaddress(coinaddr,CScript() << Mypubkey() << OP_CHECKSIG);
|
||||
SetCCunspents(unspentOutputs,coinaddr);
|
||||
for (std::vector<std::pair<CAddressUnspentKey, CAddressUnspentValue> >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++)
|
||||
{
|
||||
txid = it->first.txhash;
|
||||
vout = (int32_t)it->first.index;
|
||||
if ( it->second.satoshis < threshold )
|
||||
continue;
|
||||
if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && vout < tx.vout.size() && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() == 0 )
|
||||
{
|
||||
//fprintf(stderr,"check %.8f to vins array.%d of %d %s/v%d\n",(double)out.tx->vout[out.i].nValue/COIN,n,maxutxos,txid.GetHex().c_str(),(int32_t)vout);
|
||||
if ( mtx.vin.size() > 0 )
|
||||
{
|
||||
for (i=0; i<mtx.vin.size(); i++)
|
||||
if ( txid == mtx.vin[i].prevout.hash && vout == mtx.vin[i].prevout.n )
|
||||
break;
|
||||
if ( i != mtx.vin.size() )
|
||||
continue;
|
||||
}
|
||||
if ( n > 0 )
|
||||
{
|
||||
for (i=0; i<n; i++)
|
||||
if ( txid == utxos[i].txid && vout == utxos[i].vout )
|
||||
break;
|
||||
if ( i != n )
|
||||
continue;
|
||||
}
|
||||
if ( myIsutxo_spentinmempool(txid,vout) == 0 )
|
||||
{
|
||||
up = &utxos[n++];
|
||||
up->txid = txid;
|
||||
up->nValue = it->second.satoshis;
|
||||
up->vout = vout;
|
||||
sum += up->nValue;
|
||||
//fprintf(stderr,"add %.8f to vins array.%d of %d\n",(double)up->nValue/COIN,n,maxutxos);
|
||||
if ( n >= maxutxos || sum >= total )
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
remains = total;
|
||||
for (i=0; i<maxinputs && n>0; i++)
|
||||
{
|
||||
below = above = 0;
|
||||
abovei = belowi = -1;
|
||||
if ( CC_vinselect(&abovei,&above,&belowi,&below,utxos,n,remains) < 0 )
|
||||
{
|
||||
printf("error finding unspent i.%d of %d, %.8f vs %.8f\n",i,n,(double)remains/COIN,(double)total/COIN);
|
||||
free(utxos);
|
||||
return(0);
|
||||
}
|
||||
if ( belowi < 0 || abovei >= 0 )
|
||||
ind = abovei;
|
||||
else ind = belowi;
|
||||
if ( ind < 0 )
|
||||
{
|
||||
printf("error finding unspent i.%d of %d, %.8f vs %.8f, abovei.%d belowi.%d ind.%d\n",i,n,(double)remains/COIN,(double)total/COIN,abovei,belowi,ind);
|
||||
free(utxos);
|
||||
return(0);
|
||||
}
|
||||
up = &utxos[ind];
|
||||
mtx.vin.push_back(CTxIn(up->txid,up->vout,CScript()));
|
||||
totalinputs += up->nValue;
|
||||
remains -= up->nValue;
|
||||
utxos[ind] = utxos[--n];
|
||||
memset(&utxos[n],0,sizeof(utxos[n]));
|
||||
//fprintf(stderr,"totalinputs %.8f vs total %.8f i.%d vs max.%d\n",(double)totalinputs/COIN,(double)total/COIN,i,maxinputs);
|
||||
if ( totalinputs >= total || (i+1) >= maxinputs )
|
||||
break;
|
||||
}
|
||||
free(utxos);
|
||||
if ( totalinputs >= total )
|
||||
{
|
||||
//fprintf(stderr,"return totalinputs %.8f\n",(double)totalinputs/COIN);
|
||||
return(totalinputs);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -1395,7 +1395,7 @@ std::string DiceAddfunding(uint64_t txfee,char *planstr,uint256 fundingtxid,int6
|
||||
}
|
||||
if ( scriptPubKey == fundingPubKey )
|
||||
{
|
||||
if ( AddNormalinputs(mtx,mypk,amount+2*txfee,60) > 0 )
|
||||
if ( AddNormalinputs2(mtx,amount+2*txfee,60) > 0 )
|
||||
{
|
||||
hentropy = DiceHashEntropy(entropy,mtx.vin[0].prevout.hash,mtx.vin[0].prevout.n,1);
|
||||
mtx.vout.push_back(MakeCC1vout(cp->evalcode,amount,dicepk));
|
||||
@@ -1509,7 +1509,7 @@ std::string DiceBetFinish(uint8_t &funcid,uint256 &entropyused,int32_t &entropyv
|
||||
{
|
||||
if ( vin0txid == zeroid || vin0vout < 0 )
|
||||
{
|
||||
if ( AddNormalinputs(mtx,mypk,2*txfee,3) == 0 ) // must be a single vin!!
|
||||
if ( AddNormalinputs2(mtx,2*txfee,3) == 0 ) // must be a single vin!!
|
||||
{
|
||||
CCerror = "no txfee inputs for win/lose";
|
||||
fprintf(stderr,"%s\n", CCerror.c_str() );
|
||||
@@ -1656,22 +1656,32 @@ static uint256 dealer0_fundingtxid;
|
||||
void *dealer0_loop(void *_arg)
|
||||
{
|
||||
char *planstr = (char *)_arg;
|
||||
CTransaction tx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 entropytxid; int32_t entropytxs,i,n,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000;
|
||||
CTransaction tx,*entropytxs,entropytx; CPubKey mypk,dicepk; uint64_t entropyval; uint256 hashBlock,entropytxid,txid; int32_t height,lastht,numentropytxs,i,n,m,num; CScript fundingPubKey; struct CCcontract_info *cp,C; char coinaddr[64]; std::string res; int64_t minbet,maxbet,maxodds,timeoutblocks; uint64_t refsbits,txfee = 10000;
|
||||
if ( (cp= Diceinit(fundingPubKey,dealer0_fundingtxid,&C,planstr,txfee,mypk,dicepk,refsbits,minbet,maxbet,maxodds,timeoutblocks)) == 0 )
|
||||
{
|
||||
fprintf(stderr,"error initializing dealer0_loop\n");
|
||||
exit(-1);
|
||||
}
|
||||
fprintf(stderr,"dealer0 node running\n");
|
||||
height = lastht = 0;
|
||||
entropytxs = (CTransaction *)calloc(sizeof(*entropytxs),DICE_MINUTXOS);
|
||||
while ( 1 )
|
||||
{
|
||||
DicePlanFunds(entropyval,entropytxid,refsbits,cp,dicepk,dealer0_fundingtxid,entropytxs,false);
|
||||
if ( entropytxs < DICE_MINUTXOS )
|
||||
while ( KOMODO_INSYNC == 0 || (height= KOMODO_INSYNC) == lastht )
|
||||
{
|
||||
n = sqrt(DICE_MINUTXOS - entropytxs) + 10;
|
||||
for (i=0; i<DICE_MINUTXOS - entropytxs && i<n; i++)
|
||||
sleep(3);
|
||||
}
|
||||
lastht = height;
|
||||
fprintf(stderr,"New height.%d\n",height);
|
||||
DicePlanFunds(entropyval,entropytxid,refsbits,cp,dicepk,dealer0_fundingtxid,numentropytxs,false);
|
||||
if ( numentropytxs < DICE_MINUTXOS )
|
||||
{
|
||||
n = sqrt(DICE_MINUTXOS - numentropytxs);
|
||||
//if ( n > 10 )
|
||||
// n = 10;
|
||||
for (i=m=0; i<DICE_MINUTXOS - numentropytxs && i<n; i++)
|
||||
{
|
||||
res = DiceAddfunding(txfee,planstr,dealer0_fundingtxid,1000*COIN);///100);
|
||||
res = DiceAddfunding(txfee,planstr,dealer0_fundingtxid,COIN);
|
||||
if ( res.empty() == 0 && res.size() > 64 && is_hexstr((char *)res.c_str(),0) > 64 )
|
||||
{
|
||||
if ( DecodeHexTx(tx,res) != 0 )
|
||||
@@ -1679,12 +1689,37 @@ void *dealer0_loop(void *_arg)
|
||||
LOCK(cs_main);
|
||||
if ( myAddtomempool(tx) != 0 )
|
||||
{
|
||||
fprintf(stderr,"ENTROPY %s: %d of %d, %d\n",tx.GetHash().GetHex().c_str(),i,n,DICE_MINUTXOS - entropytxs);
|
||||
fprintf(stderr,"ENTROPY %s: %d of %d, %d\n",tx.GetHash().GetHex().c_str(),i,n,DICE_MINUTXOS - numentropytxs);
|
||||
RelayTransaction(tx);
|
||||
entropytxs[m++] = tx;
|
||||
} else break;
|
||||
} else break;
|
||||
} else break;
|
||||
}
|
||||
for (i=0; i<m; i++)
|
||||
{
|
||||
tx = entropytxs[i];
|
||||
txid = tx.GetHash();
|
||||
fprintf(stderr,"check %d of %d: %s\n",i,m,txid.GetHex().c_str());
|
||||
while ( 1 )
|
||||
{
|
||||
if ( myGetTransaction(txid,entropytx,hashBlock) == 0 || hashBlock == zeroid )
|
||||
{
|
||||
LOCK(cs_main);
|
||||
if ( myAddtomempool(tx) != 0 )
|
||||
{
|
||||
fprintf(stderr,"resend ENTROPY %s: %d of %d\n",txid.GetHex().c_str(),i,m);
|
||||
RelayTransaction(tx);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(stderr,"found %s in %s\n",txid.GetHex().c_str(),hashBlock.GetHex().c_str());
|
||||
break;
|
||||
}
|
||||
sleep(10);
|
||||
}
|
||||
}
|
||||
}
|
||||
pubkey2addr(coinaddr,Mypubkey().data());
|
||||
dicefinish_utxosget(num,0,0,coinaddr);
|
||||
|
||||
2
src/fiat/zex
Executable file
2
src/fiat/zex
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=ZEX $1 $2 $3 $4 $5 $6
|
||||
@@ -1767,12 +1767,12 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
||||
{
|
||||
if ( (is_PoSblock= komodo_is_PoSblock(slowflag,height,pblock,bnTarget,bhash)) == 0 )
|
||||
{
|
||||
if ( slowflag == 0 ) // need all past 100 blocks to calculate PoW target
|
||||
return(0);
|
||||
if ( ASSETCHAINS_STAKED == 100 && height > 100 ) // only PoS allowed! POSTEST64
|
||||
return(-1);
|
||||
else
|
||||
{
|
||||
if ( slowflag == 0 ) // need all past 100 blocks to calculate PoW target
|
||||
return(0);
|
||||
if ( slowflag != 0 )
|
||||
bnTarget = komodo_PoWtarget(&PoSperc,bnTarget,height,ASSETCHAINS_STAKED);
|
||||
if ( bhash > bnTarget )
|
||||
@@ -1792,6 +1792,8 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
||||
fprintf(stderr,"unexpected negative is_PoSblock.%d\n",is_PoSblock);
|
||||
return(-1);
|
||||
}
|
||||
else if ( ASSETCHAINS_STAKED != 0 )
|
||||
failed = 0;
|
||||
}
|
||||
if ( failed == 0 && ASSETCHAINS_COMMISSION != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
||||
{
|
||||
@@ -1820,7 +1822,7 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
//fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed);
|
||||
//fprintf(stderr,"komodo_checkPOW possible.%d slowflag.%d ht.%d notaryid.%d failed.%d\n",possible,slowflag,height,notaryid,failed);
|
||||
if ( failed != 0 && possible == 0 && notaryid < 0 )
|
||||
return(-1);
|
||||
else return(0);
|
||||
|
||||
@@ -2013,6 +2013,7 @@ bool myAddtomempool(CTransaction &tx, CValidationState *pstate)
|
||||
|
||||
bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock)
|
||||
{
|
||||
memset(&hashBlock,0,sizeof(hashBlock));
|
||||
// need a GetTransaction without lock so the validation code for assets can run without deadlock
|
||||
{
|
||||
//fprintf(stderr,"check mempool\n");
|
||||
@@ -2056,6 +2057,7 @@ bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlo
|
||||
bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow)
|
||||
{
|
||||
CBlockIndex *pindexSlow = NULL;
|
||||
memset(&hashBlock,0,sizeof(hashBlock));
|
||||
|
||||
LOCK(cs_main);
|
||||
|
||||
|
||||
@@ -491,8 +491,6 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
||||
uint64_t txfees,utxovalue; uint32_t txtime; uint256 utxotxid; int32_t i,siglen,numsigs,utxovout; uint8_t utxosig[128],*ptr;
|
||||
CMutableTransaction txStaked = CreateNewContextualCMutableTransaction(Params().GetConsensus(), stakeHeight);
|
||||
|
||||
//if ( blocktime > pindexPrev->GetMedianTimePast()+60 )
|
||||
// blocktime = pindexPrev->GetMedianTimePast() + 60;
|
||||
if (ASSETCHAINS_LWMAPOS != 0)
|
||||
{
|
||||
uint32_t nBitsPOS;
|
||||
@@ -507,6 +505,9 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
|
||||
}
|
||||
else
|
||||
{
|
||||
blocktime = GetAdjustedTime();
|
||||
//if ( blocktime > pindexPrev->GetMedianTimePast()+60 )
|
||||
// blocktime = pindexPrev->GetMedianTimePast() + 60;
|
||||
siglen = komodo_staked(txStaked, pblock->nBits, &blocktime, &txtime, &utxotxid, &utxovout, &utxovalue, utxosig);
|
||||
}
|
||||
|
||||
|
||||
@@ -5185,8 +5185,10 @@ struct komodo_staking *komodo_addutxo(struct komodo_staking *array,int32_t *numk
|
||||
{
|
||||
*maxkp += 1000;
|
||||
array = (struct komodo_staking *)realloc(array,sizeof(*array) * (*maxkp));
|
||||
//fprintf(stderr,"realloc max.%d array.%p\n",*maxkp,array);
|
||||
}
|
||||
kp = &array[(*numkp)++];
|
||||
//fprintf(stderr,"kp.%p num.%d\n",kp,*numkp);
|
||||
memset(kp,0,sizeof(*kp));
|
||||
strcpy(kp->address,address);
|
||||
kp->txid = txid;
|
||||
@@ -5209,15 +5211,11 @@ arith_uint256 _komodo_eligible(struct komodo_staking *kp,arith_uint256 ratio,uin
|
||||
diff = 3600*24*30;
|
||||
if ( iter > 0 )
|
||||
diff += segid*2;
|
||||
coinage = ((uint64_t)kp->nValue/COIN * diff);
|
||||
coinage = ((uint64_t)kp->nValue * diff);
|
||||
if ( blocktime+iter+segid*2 > prevtime+480 )
|
||||
coinage *= ((blocktime+iter+segid*2) - (prevtime+400));
|
||||
//if ( nHeight >= 2500 && blocktime+iter+segid*2 > prevtime+180 )
|
||||
// coinage *= ((blocktime+iter+segid*2) - (prevtime+60));
|
||||
coinage256 = arith_uint256(coinage+1);
|
||||
hashval = ratio * (kp->hashval / coinage256);
|
||||
//if ( nHeight >= 900 && nHeight < 916 )
|
||||
// hashval = (hashval / coinage256);
|
||||
return(hashval);
|
||||
}
|
||||
|
||||
@@ -5247,7 +5245,7 @@ uint32_t komodo_eligible(arith_uint256 bnTarget,arith_uint256 ratio,struct komod
|
||||
return(blocktime);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else fprintf(stderr,"maxiters is not good enough\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -5274,10 +5272,10 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
||||
if ( (minage= nHeight*3) > 6000 ) // about 100 blocks
|
||||
minage = 6000;
|
||||
komodo_segids(hashbuf,nHeight-101,100);
|
||||
if ( *blocktimep > tipindex->nTime+60 )
|
||||
if ( *blocktimep < tipindex->nTime+60 )
|
||||
*blocktimep = tipindex->nTime+60;
|
||||
//fprintf(stderr,"Start scan of utxo for staking %u ht.%d\n",(uint32_t)time(NULL),nHeight);
|
||||
if ( time(NULL) > lasttime+600 )
|
||||
if ( time(NULL) > lasttime+600 || array == 0 )
|
||||
{
|
||||
if ( array != 0 )
|
||||
{
|
||||
@@ -5296,7 +5294,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
||||
counter++;
|
||||
if ( out.nDepth < nMinDepth || out.nDepth > nMaxDepth )
|
||||
{
|
||||
//fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth);
|
||||
fprintf(stderr,"komodo_staked invalid depth %d\n",(int32_t)out.nDepth);
|
||||
continue;
|
||||
}
|
||||
CAmount nValue = out.tx->vout[out.i].nValue;
|
||||
@@ -5310,12 +5308,14 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
||||
if ( GetTransaction(out.tx->GetHash(),tx,hashBlock,true) != 0 && (pindex= komodo_getblockindex(hashBlock)) != 0 )
|
||||
{
|
||||
array = komodo_addutxo(array,&numkp,&maxkp,(uint32_t)pindex->nTime,(uint64_t)nValue,out.tx->GetHash(),out.i,(char *)CBitcoinAddress(address).ToString().c_str(),hashbuf,(CScript)pk);
|
||||
//fprintf(stderr,"addutxo numkp.%d vs max.%d\n",numkp,maxkp);
|
||||
}
|
||||
}
|
||||
}
|
||||
lasttime = (uint32_t)time(NULL);
|
||||
//fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp);
|
||||
//fprintf(stderr,"finished kp data of utxo for staking %u ht.%d numkp.%d maxkp.%d\n",(uint32_t)time(NULL),nHeight,numkp,maxkp);
|
||||
}
|
||||
//fprintf(stderr,"numkp.%d blocktime.%u\n",numkp,*blocktimep);
|
||||
block_from_future_rejecttime = (uint32_t)GetAdjustedTime() + 57;
|
||||
for (i=winners=0; i<numkp; i++)
|
||||
{
|
||||
@@ -5328,7 +5328,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
||||
if ( (eligible2= komodo_eligible(bnTarget,ratio,kp,nHeight,*blocktimep,(uint32_t)tipindex->nTime+27,minage,hashbuf)) == 0 )
|
||||
continue;
|
||||
eligible = komodo_stake(0,bnTarget,nHeight,kp->txid,kp->vout,0,(uint32_t)tipindex->nTime+27,kp->address);
|
||||
//fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible);
|
||||
//fprintf(stderr,"i.%d %u vs %u\n",i,eligible2,eligible);
|
||||
if ( eligible > 0 )
|
||||
{
|
||||
besttime = m = 0;
|
||||
@@ -5341,7 +5341,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
||||
if ( eligible < block_from_future_rejecttime ) // nothing gained by going earlier
|
||||
break;
|
||||
m++;
|
||||
//fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u test prior\n",m,nHeight,*blocktimep,(double)kp->nValue/COIN,eligible);
|
||||
//fprintf(stderr,"m.%d ht.%d validated winning blocktime %u -> %.8f eligible.%u test prior\n",m,nHeight,*blocktimep,(double)kp->nValue/COIN,eligible);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -5351,7 +5351,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
||||
}
|
||||
eligible = besttime;
|
||||
winners++;
|
||||
//fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",nHeight,(int32_t)(eligible - tipindex->nTime),(double)kp->nValue/COIN,eligible);
|
||||
//fprintf(stderr,"ht.%d validated winning [%d] -> %.8f eligible.%u test prior\n",nHeight,(int32_t)(eligible - tipindex->nTime),(double)kp->nValue/COIN,eligible);
|
||||
if ( earliest == 0 || eligible < earliest || (eligible == earliest && (*utxovaluep == 0 || kp->nValue < *utxovaluep)) )
|
||||
{
|
||||
earliest = eligible;
|
||||
@@ -5364,7 +5364,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
||||
fprintf(stderr,"ht.%d earliest.%u [%d].%d (%s) nValue %.8f locktime.%u counter.%d winners.%d\n",nHeight,earliest,(int32_t)(earliest - tipindex->nTime),m,kp->address,(double)kp->nValue/COIN,*txtimep,counter,winners);
|
||||
}
|
||||
} //else fprintf(stderr,"utxo not eligible\n");
|
||||
} //else fprintf(stderr,"no tipindex\n");
|
||||
}
|
||||
if ( numkp < 10000 && array != 0 )
|
||||
{
|
||||
free(array);
|
||||
@@ -5399,7 +5399,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt
|
||||
for (i=0; i<siglen; i++)
|
||||
utxosig[i] = ptr[i];//, fprintf(stderr,"%02x",ptr[i]);
|
||||
//fprintf(stderr," siglen.%d\n",siglen);
|
||||
//fprintf(stderr,"best %u from %u, gap %d lag.%d\n",earliest,*blocktimep,(int32_t)(earliest - *blocktimep),(int32_t)(time(NULL) - *blocktimep));
|
||||
//fprintf(stderr,"best %u from %u, gap %d lag.%d\n",earliest,*blocktimep,(int32_t)(earliest - *blocktimep),(int32_t)(time(NULL) - *blocktimep));
|
||||
*blocktimep = earliest;
|
||||
}
|
||||
} //else fprintf(stderr,"no earliest utxo for staking\n");
|
||||
|
||||
Reference in New Issue
Block a user