Merge remote-tracking branch 'jl/jl777' into momo
This commit is contained in:
@@ -57,3 +57,4 @@ komodo_asset PRLPAY 500000000
|
||||
komodo_asset DSEC 7000000
|
||||
komodo_asset GLXT 100000000
|
||||
komodo_asset EQL 500000000
|
||||
komodo_asset ZILLA 11000000
|
||||
|
||||
@@ -34,5 +34,7 @@ echo $pubkey
|
||||
./komodod -pubkey=$pubkey -ac_name=DSEC -ac_supply=7000000 -addnode=185.148.147.30 &
|
||||
./komodod -pubkey=$pubkey -ac_name=GLXT -ac_supply=100000000 -addnode=13.230.224.15 &
|
||||
./komodod -pubkey=$pubkey -ac_name=EQL -ac_supply=500000000 -addnode=46.101.124.153 &
|
||||
./komodod -pubkey=$pubkey -ac_name=ZILLA -ac_supply=11000000 -addnode=54.39.23.248 &
|
||||
~/VerusCoin/src/komodod -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 &
|
||||
|
||||
|
||||
|
||||
@@ -173,6 +173,8 @@ public:
|
||||
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x88)(0xAD)(0xE4).convert_to_container<std::vector<unsigned char> >();
|
||||
// guarantees the first two characters, when base58 encoded, are "zc"
|
||||
base58Prefixes[ZCPAYMENT_ADDRRESS] = {22,154};
|
||||
// guarantees the first 4 characters, when base58 encoded, are "ZiVK"
|
||||
base58Prefixes[ZCVIEWING_KEY] = {0xA8,0xAB,0xD3};
|
||||
// guarantees the first two characters, when base58 encoded, are "SK"
|
||||
base58Prefixes[ZCSPENDING_KEY] = {171,54};
|
||||
|
||||
@@ -467,6 +469,8 @@ public:
|
||||
base58Prefixes[EXT_PUBLIC_KEY] = boost::assign::list_of(0x04)(0x35)(0x87)(0xCF).convert_to_container<std::vector<unsigned char> >();
|
||||
base58Prefixes[EXT_SECRET_KEY] = boost::assign::list_of(0x04)(0x35)(0x83)(0x94).convert_to_container<std::vector<unsigned char> >();
|
||||
base58Prefixes[ZCPAYMENT_ADDRRESS] = {20,81};
|
||||
// guarantees the first 4 characters, when base58 encoded, are "ZiVt"
|
||||
base58Prefixes[ZCVIEWING_KEY] = {0xA8,0xAC,0x0C};
|
||||
base58Prefixes[ZCSPENDING_KEY] = {177,235};
|
||||
|
||||
vFixedSeeds = std::vector<SeedSpec6>(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test));
|
||||
|
||||
@@ -33,6 +33,6 @@ curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dp
|
||||
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"DSEC\",\"pubkey\":\"$pubkey\"}"
|
||||
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GLXT\",\"pubkey\":\"$pubkey\"}"
|
||||
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"EQL\",\"pubkey\":\"$pubkey\"}"
|
||||
|
||||
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"ZILLA\",\"pubkey\":\"$pubkey\"}"
|
||||
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"CHIPS\",\"pubkey\":\"$pubkey\"}"
|
||||
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"GAME\",\"freq\":5,\"pubkey\":\"$pubkey\"}"
|
||||
|
||||
@@ -30,3 +30,4 @@ echo prlpay; fiat/prlpay $1 $2 $3 $4
|
||||
echo dsec; fiat/dsec $1 $2 $3 $4
|
||||
echo glxt; fiat/glxt $1 $2 $3 $4
|
||||
echo eql; fiat/eql $1 $2 $3 $4
|
||||
echo zilla; fiat/zilla $1 $2 $3 $4
|
||||
|
||||
2
src/fiat/zilla
Normal file
2
src/fiat/zilla
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
./komodo-cli -ac_name=ZILLA $1 $2 $3 $4 $5 $6
|
||||
11
src/komodo.h
11
src/komodo.h
@@ -598,14 +598,15 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( scriptbuf[len] == 'K' )
|
||||
{
|
||||
fprintf(stderr,"i.%d j.%d KV OPRET len.%d %.8f\n",i,j,opretlen,dstr(value));
|
||||
komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j,zero,0);
|
||||
return(-1);
|
||||
}
|
||||
if ( strcmp(ASSETCHAINS_SYMBOL,(char *)&scriptbuf[len+32*2+4]) == 0 )
|
||||
matched = 1;
|
||||
}
|
||||
if ( scriptbuf[len] == 'K' )
|
||||
{
|
||||
fprintf(stderr,"i.%d j.%d KV OPRET len.%d %.8f\n",i,j,opretlen,dstr(value));
|
||||
return(-1);
|
||||
}
|
||||
offset = 32 * (1 + matched) + 4;
|
||||
nameoffset = (int32_t)strlen((char *)&scriptbuf[len+offset]);
|
||||
nameoffset++;
|
||||
|
||||
@@ -1024,9 +1024,8 @@ int32_t komodo_isrealtime(int32_t *kmdheightp)
|
||||
else return(0);
|
||||
}
|
||||
|
||||
int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t nTime,int32_t dispflag)
|
||||
int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_t cmptime,int32_t dispflag)
|
||||
{
|
||||
uint32_t cmptime = nTime;
|
||||
if ( KOMODO_REWIND == 0 && ASSETCHAINS_SYMBOL[0] == 0 && (int64_t)tx.nLockTime >= LOCKTIME_THRESHOLD ) //1473793441 )
|
||||
{
|
||||
if ( txheight > 246748 )
|
||||
@@ -1080,6 +1079,13 @@ uint64_t komodo_commission(const CBlock *pblock)
|
||||
return(commission);
|
||||
}
|
||||
|
||||
uint32_t komodo_segid32(char *coinaddr)
|
||||
{
|
||||
bits256 addrhash;
|
||||
vcalc_sha256(0,(uint8_t *)&addrhash,(uint8_t *)coinaddr,(int32_t)strlen(coinaddr));
|
||||
return(addrhash.uints[0]);
|
||||
}
|
||||
|
||||
uint32_t komodo_stake(int32_t validateflag,arith_uint256 bnTarget,int32_t nHeight,uint256 txid,int32_t vout,uint32_t blocktime,uint32_t prevtime,char *destaddr)
|
||||
{
|
||||
CBlockIndex *pindex; uint8_t hashbuf[128]; char address[64]; bits256 addrhash; arith_uint256 hashval; uint256 hash,pasthash; int64_t diff=0; int32_t segid,minage,i,iter=0; uint32_t txtime,winner = 0; uint64_t value,coinage,supply = ASSETCHAINS_SUPPLY + nHeight*ASSETCHAINS_REWARD/SATOSHIDEN;
|
||||
@@ -1197,7 +1203,7 @@ arith_uint256 komodo_PoWtarget(int32_t *percPoSp,arith_uint256 target,int32_t he
|
||||
} else return(target);
|
||||
if ( percPoS < goalperc ) // increase PoW diff -> lower bnTarget
|
||||
{
|
||||
bnTarget = (ave * arith_uint256(percPoS * percPoS)) / arith_uint256((goalperc) * (goalperc));
|
||||
bnTarget = (ave * arith_uint256(percPoS * percPoS)) / arith_uint256(goalperc * goalperc * goalperc);
|
||||
if ( 1 )
|
||||
{
|
||||
for (i=31; i>=24; i--)
|
||||
|
||||
@@ -747,17 +747,22 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim
|
||||
if ( ASSETCHAINS_COMMISSION != 0 && height > 1 )
|
||||
{
|
||||
if ( (checktoshis= komodo_checkcommission((CBlock *)&block,height)) < 0 )
|
||||
return(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( overflow != 0 || total > checktoshis || strangeout != 0 )
|
||||
{
|
||||
if ( strangeout != 0 )
|
||||
fprintf(stderr,">>>>>>>>>>>>> %s DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",ASSETCHAINS_SYMBOL,height,strangeout,notmatched);
|
||||
fprintf(stderr,"ht.%d checktoshis %.8f overflow.%d total %.8f strangeout.%d\n",height,dstr(checktoshis),overflow,dstr(total),strangeout);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
if ( height > 1 && checktoshis == 0 )
|
||||
{
|
||||
checktoshis = ((uint64_t)GetBlockSubsidy(height, Params().GetConsensus()) - block.vtx[0].vout[0].nValue);
|
||||
}
|
||||
if ( height >= 2 && (overflow != 0 || total > checktoshis || strangeout != 0) )
|
||||
{
|
||||
fprintf(stderr,"checkdeposit: ht.%d checktoshis %.8f overflow.%d total %.8f strangeout.%d\n",height,dstr(checktoshis),overflow,dstr(total),strangeout);
|
||||
if ( strangeout != 0 )
|
||||
fprintf(stderr,">>>>>>>>>>>>> %s DUST ht.%d strangout.%d notmatched.%d <<<<<<<<<\n",ASSETCHAINS_SYMBOL,height,strangeout,notmatched);
|
||||
return(-1);
|
||||
}
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ void komodo_kvupdate(uint8_t *opretbuf,int32_t opretlen,uint64_t value)
|
||||
if ( keylen+13 > opretlen )
|
||||
{
|
||||
static uint32_t counter;
|
||||
if ( ++counter < 100 )
|
||||
if ( ++counter < 1 )
|
||||
fprintf(stderr,"komodo_kvupdate: keylen.%d + 13 > opretlen.%d, this can be ignored\n",keylen,opretlen);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -826,7 +826,7 @@ uint16_t komodo_calcport(char *name,uint64_t supply,uint64_t endsubsidy,uint64_t
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
uint16_t rpcport; int32_t i,j,offset=0,num = 1; uint64_t supply=10,commission=0,endsubsidy,reward,halving,decay; uint8_t *allocated=0,staked=0; uint32_t cc = 1;
|
||||
uint16_t rpcport; int32_t i,j,offset=0,jsonflag=0,num = 1; uint64_t supply=10,commission=0,endsubsidy,reward,halving,decay; uint8_t *allocated=0,staked=0; uint32_t cc = 3;
|
||||
endsubsidy = reward = halving = decay = 0;
|
||||
if ( argc < 2 )
|
||||
{
|
||||
@@ -835,9 +835,11 @@ int main(int argc, char * argv[])
|
||||
printf("%s -gen num name supply endsubsidy reward halving decay\n",argv[0]);
|
||||
return(-1);
|
||||
}
|
||||
if ( strcmp(argv[1],"-gen") == 0 )
|
||||
if ( strncmp(argv[1],"-gen",3) == 0 )
|
||||
{
|
||||
num = atoi(argv[2]);
|
||||
if ( strcmp(argv[1],"-genjson") == 0 )
|
||||
jsonflag = 1;
|
||||
offset = 2;
|
||||
allocated = calloc(1,1 << 16);
|
||||
}
|
||||
@@ -852,7 +854,7 @@ int main(int argc, char * argv[])
|
||||
if ( argc > offset + 6 )
|
||||
decay = (long long)atof(argv[offset + 6]);
|
||||
rpcport = 1 + komodo_calcport(argv[offset + 1],supply,endsubsidy,reward,halving,decay,commission,staked,cc);
|
||||
printf("./komodod -ac_name=%s -ac_cc=%u -ac_supply=%llu -ac_end=%llu -ac_reward=%llu -ac_halving=%llu -ac_decay=%llu & # rpcport %u\n",argv[offset + 1],cc,(long long)supply,(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,rpcport);
|
||||
printf("./komodod -ac_name=%s -ac_cc=%u -ac_supply=%llu -ac_end=%llu -ac_reward=%llu -ac_halving=%llu -ac_decay=%llu & # rpcport %u\n[",argv[offset + 1],cc,(long long)supply,(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,rpcport);
|
||||
if ( allocated != 0 )
|
||||
{
|
||||
char name[64],newname[64];
|
||||
@@ -868,7 +870,14 @@ int main(int argc, char * argv[])
|
||||
rpcport = 1 + komodo_calcport(newname,supply+j,endsubsidy,reward,halving,decay,commission,staked,cc);
|
||||
if ( allocated[rpcport] == 0 && allocated[rpcport-1] == 0 )
|
||||
{
|
||||
printf("./komodod -ac_name=%s -ac_cc=%u -ac_supply=%llu -ac_end=%llu -ac_reward=%llu -ac_halving=%llu -ac_decay=%llu & # rpcport %u\n",newname,cc,(long long)supply+j,(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,rpcport);
|
||||
if ( jsonflag == 0 )
|
||||
{
|
||||
printf("./komodod -ac_name=%s -ac_cc=%u -ac_supply=%llu -ac_end=%llu -ac_reward=%llu -ac_halving=%llu -ac_decay=%llu & # rpcport %u\n",newname,cc,(long long)supply+j,(long long)endsubsidy,(long long)reward,(long long)halving,(long long)decay,rpcport);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("{ \"assetname\": \"%s\", \"p2p\": %u, \"rpc\": %u, \"supply\": %llu, \"ac_cc\": %u, \"ac_reward\": %llu, \"notarize\": %s }%s ",newname,rpcport-1,rpcport,(long long)supply+j,cc,(long long)reward,i<64?"true":"false",i<num-1?",":"");
|
||||
}
|
||||
allocated[rpcport] = 1;
|
||||
allocated[rpcport-1] = 1;
|
||||
break;
|
||||
@@ -878,5 +887,6 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
free(allocated);
|
||||
}
|
||||
printf("]\n");
|
||||
return(0);
|
||||
}
|
||||
|
||||
11
src/main.cpp
11
src/main.cpp
@@ -588,6 +588,15 @@ CBlockTreeDB *pblocktree = NULL;
|
||||
#define KOMODO_ZCASH
|
||||
#include "komodo.h"
|
||||
|
||||
int64_t komodo_snapshot()
|
||||
{
|
||||
int64_t total = -1;
|
||||
if ( pblocktree != 0 )
|
||||
total = pblocktree->Snapshot();
|
||||
else fprintf(stderr,"null pblocktree start with -addressindex=true\n");
|
||||
return(total);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// mapOrphanTransactions
|
||||
@@ -3852,7 +3861,7 @@ bool CheckBlockHeader(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,
|
||||
{
|
||||
if (blockhdr.GetBlockTime() < GetAdjustedTime() + 600)
|
||||
*futureblockp = 1;
|
||||
LogPrintf("CheckBlockHeader block from future %d error",blockhdr.GetBlockTime() - GetAdjustedTime());
|
||||
//LogPrintf("CheckBlockHeader block from future %d error",blockhdr.GetBlockTime() - GetAdjustedTime());
|
||||
return false; //state.Invalid(error("CheckBlockHeader(): block timestamp too far in the future"),REJECT_INVALID, "time-too-new");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,9 +110,11 @@ extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOS
|
||||
extern uint64_t ASSETCHAINS_REWARD,ASSETCHAINS_COMMISSION,ASSETCHAINS_STAKED;
|
||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
extern std::string NOTARY_PUBKEY,ASSETCHAINS_OVERRIDE_PUBKEY;
|
||||
void vcalc_sha256(char deprecated[(256 >> 3) * 2 + 1],uint8_t hash[256 >> 3],uint8_t *src,int32_t len);
|
||||
|
||||
extern uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33];
|
||||
uint32_t Mining_start,Mining_height;
|
||||
int32_t My_notaryid = -1;
|
||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,uint32_t timestamp);
|
||||
int32_t komodo_pax_opreturn(int32_t height,uint8_t *opret,int32_t maxsize);
|
||||
//uint64_t komodo_paxtotal();
|
||||
@@ -125,10 +127,12 @@ uint64_t komodo_commission(const CBlock *block);
|
||||
int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blocktimep,uint32_t *txtimep,uint256 *utxotxidp,int32_t *utxovoutp,uint64_t *utxovaluep,uint8_t *utxosig);
|
||||
int32_t komodo_notaryvin(CMutableTransaction &txNew,uint8_t *notarypub33);
|
||||
|
||||
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount)
|
||||
{
|
||||
uint64_t deposits; int32_t isrealtime,kmdheight; uint32_t blocktime; const CChainParams& chainparams = Params();
|
||||
// Create new block
|
||||
if ( gpucount < 0 )
|
||||
gpucount = KOMODO_MAXGPUCOUNT;
|
||||
std::unique_ptr<CBlockTemplate> pblocktemplate(new CBlockTemplate());
|
||||
if(!pblocktemplate.get())
|
||||
{
|
||||
@@ -478,11 +482,22 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
|
||||
}
|
||||
pblock->nSolution.clear();
|
||||
pblocktemplate->vTxSigOps[0] = GetLegacySigOpCount(pblock->vtx[0]);
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 )
|
||||
if ( ASSETCHAINS_SYMBOL[0] == 0 && NOTARY_PUBKEY33[0] != 0 && My_notaryid >= 0 )
|
||||
{
|
||||
uint32_t r;
|
||||
CMutableTransaction txNotary = CreateNewContextualCMutableTransaction(Params().GetConsensus(), chainActive.Height() + 1);
|
||||
if ( pblock->nTime < pindexPrev->nTime+65 )
|
||||
pblock->nTime = pindexPrev->nTime + 65;
|
||||
if ( pblock->nTime < pindexPrev->nTime+60 )
|
||||
pblock->nTime = pindexPrev->nTime + 60;
|
||||
if ( gpucount < 33 )
|
||||
{
|
||||
uint8_t tmpbuffer[40]; uint32_t r; int32_t n=0; uint256 randvals;
|
||||
memcpy(&tmpbuffer[n],&My_notaryid,sizeof(My_notaryid)), n += sizeof(My_notaryid);
|
||||
memcpy(&tmpbuffer[n],&Mining_height,sizeof(Mining_height)), n += sizeof(Mining_height);
|
||||
memcpy(&tmpbuffer[n],&pblock->hashPrevBlock,sizeof(pblock->hashPrevBlock)), n += sizeof(pblock->hashPrevBlock);
|
||||
vcalc_sha256(0,(uint8_t *)&randvals,tmpbuffer,n);
|
||||
memcpy(&r,&randvals,sizeof(r));
|
||||
pblock->nTime += (r % (33 - gpucount)*(33 - gpucount));
|
||||
}
|
||||
if ( komodo_notaryvin(txNotary,NOTARY_PUBKEY33) > 0 )
|
||||
{
|
||||
CAmount txfees = 5000;
|
||||
@@ -591,7 +606,7 @@ void IncrementExtraNonce(CBlock* pblock, CBlockIndex* pindexPrev, unsigned int&
|
||||
// Internal miner
|
||||
//
|
||||
|
||||
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight)
|
||||
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,int32_t gpucount)
|
||||
{
|
||||
CPubKey pubkey; CScript scriptPubKey; uint8_t *script,*ptr; int32_t i;
|
||||
if ( nHeight == 1 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
|
||||
@@ -618,7 +633,7 @@ CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight)
|
||||
script[34] = OP_CHECKSIG;
|
||||
//scriptPubKey = CScript() << ToByteVector(pubkey) << OP_CHECKSIG;
|
||||
}
|
||||
return CreateNewBlock(scriptPubKey);
|
||||
return CreateNewBlock(scriptPubKey,gpucount);
|
||||
}
|
||||
|
||||
void komodo_broadcast(CBlock *pblock,int32_t limit)
|
||||
@@ -725,7 +740,7 @@ void static BitcoinMiner()
|
||||
|
||||
unsigned int n = chainparams.EquihashN();
|
||||
unsigned int k = chainparams.EquihashK();
|
||||
uint8_t *script; uint64_t total,checktoshis; int32_t i,j,notaryid = -1;
|
||||
uint8_t *script; uint64_t total,checktoshis; int32_t i,j,gpucount=KOMODO_MAXGPUCOUNT,notaryid = -1;
|
||||
while ( (ASSETCHAIN_INIT == 0 || KOMODO_INITDONE == 0) ) //chainActive.Tip()->nHeight != 235300 &&
|
||||
{
|
||||
sleep(1);
|
||||
@@ -733,7 +748,8 @@ void static BitcoinMiner()
|
||||
break;
|
||||
}
|
||||
komodo_chosennotary(¬aryid,chainActive.Tip()->nHeight,NOTARY_PUBKEY33,(uint32_t)chainActive.Tip()->GetBlockTime());
|
||||
|
||||
if ( notaryid != My_notaryid )
|
||||
My_notaryid = notaryid;
|
||||
std::string solver;
|
||||
//if ( notaryid >= 0 || ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
solver = "tromp";
|
||||
@@ -779,11 +795,6 @@ void static BitcoinMiner()
|
||||
//fprintf(stderr,"%s Found peers\n",ASSETCHAINS_SYMBOL);
|
||||
miningTimer.start();
|
||||
}
|
||||
/*while ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight < ASSETCHAINS_MINHEIGHT )
|
||||
{
|
||||
fprintf(stderr,"%s waiting for block 100, ht.%d\n",ASSETCHAINS_SYMBOL,chainActive.Tip()->nHeight);
|
||||
sleep(3);
|
||||
}*/
|
||||
//
|
||||
// Create new block
|
||||
//
|
||||
@@ -800,7 +811,7 @@ void static BitcoinMiner()
|
||||
sleep(3);
|
||||
}
|
||||
#ifdef ENABLE_WALLET
|
||||
CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey,pindexPrev->nHeight+1);
|
||||
CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey,pindexPrev->nHeight+1,gpucount);
|
||||
#else
|
||||
CBlockTemplate *ptr = CreateNewBlockWithKey();
|
||||
#endif
|
||||
@@ -843,7 +854,7 @@ void static BitcoinMiner()
|
||||
//
|
||||
// Search
|
||||
//
|
||||
uint8_t pubkeys[66][33]; uint32_t blocktimes[66]; int mids[256],gpucount,nonzpkeys,i,j,externalflag; uint32_t savebits; int64_t nStart = GetTime();
|
||||
uint8_t pubkeys[66][33]; uint32_t blocktimes[66]; int mids[256],nonzpkeys,i,j,externalflag; uint32_t savebits; int64_t nStart = GetTime();
|
||||
savebits = pblock->nBits;
|
||||
HASHTarget = arith_uint256().SetCompact(pblock->nBits);
|
||||
roundrobin_delay = ROUNDROBIN_DELAY;
|
||||
@@ -882,18 +893,8 @@ void static BitcoinMiner()
|
||||
if ( mids[j] == -1 )
|
||||
gpucount++;
|
||||
}
|
||||
if ( gpucount > j/2 )
|
||||
{
|
||||
double delta;
|
||||
if ( notaryid < 0 )
|
||||
i = (rand() % 64);
|
||||
else i = ((Mining_height + notaryid) % 64);
|
||||
delta = sqrt((double)gpucount - j/2) / 2.;
|
||||
roundrobin_delay += ((delta * i) / 64) - delta;
|
||||
//fprintf(stderr,"delta.%f %f %f\n",delta,(double)(gpucount - j/3) / 2,(delta * i) / 64);
|
||||
}
|
||||
if ( dispflag != 0 )
|
||||
fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%% t.%u %d\n",pindexPrev->nHeight,notaryid,gpucount,100.*(double)gpucount/j,(uint32_t)time(NULL),roundrobin_delay);
|
||||
fprintf(stderr," <- prev minerids from ht.%d notary.%d gpucount.%d %.2f%% t.%u\n",pindexPrev->nHeight,notaryid,gpucount,100.*(double)gpucount/j,(uint32_t)time(NULL));
|
||||
}
|
||||
for (j=0; j<65; j++)
|
||||
if ( mids[j] == notaryid )
|
||||
|
||||
@@ -25,12 +25,13 @@ struct CBlockTemplate
|
||||
std::vector<CAmount> vTxFees;
|
||||
std::vector<int64_t> vTxSigOps;
|
||||
};
|
||||
#define KOMODO_MAXGPUCOUNT 65
|
||||
|
||||
/** Generate a new block, without valid proof-of-work */
|
||||
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn);
|
||||
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn,int32_t gpucount);
|
||||
#ifdef ENABLE_WALLET
|
||||
boost::optional<CScript> GetMinerScriptPubKey(CReserveKey& reservekey);
|
||||
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight);
|
||||
CBlockTemplate* CreateNewBlockWithKey(CReserveKey& reservekey,int32_t nHeight,int32_t gpucount);
|
||||
#else
|
||||
boost::optional<CScript> GetMinerScriptPubKey();
|
||||
CBlockTemplate* CreateNewBlockWithKey();
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
||||
/**
|
||||
* Return average network hashes per second based on the last 'lookup' blocks,
|
||||
* or over the difficulty averaging window if 'lookup' is nonpositive.
|
||||
@@ -214,7 +215,7 @@ UniValue generate(const UniValue& params, bool fHelp)
|
||||
lastTime = GetTime();
|
||||
|
||||
#ifdef ENABLE_WALLET
|
||||
std::unique_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey,nHeight));
|
||||
std::unique_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey(reservekey,nHeight,KOMODO_MAXGPUCOUNT));
|
||||
#else
|
||||
std::unique_ptr<CBlockTemplate> pblocktemplate(CreateNewBlockWithKey());
|
||||
#endif
|
||||
@@ -639,7 +640,7 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
}
|
||||
#ifdef ENABLE_WALLET
|
||||
CReserveKey reservekey(pwalletMain);
|
||||
pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.Tip()->nHeight+1);
|
||||
pblocktemplate = CreateNewBlockWithKey(reservekey,chainActive.Tip()->nHeight+1,KOMODO_MAXGPUCOUNT);
|
||||
#else
|
||||
pblocktemplate = CreateNewBlockWithKey();
|
||||
#endif
|
||||
@@ -692,7 +693,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp)
|
||||
// Correct this if GetBlockTemplate changes the order
|
||||
// entry.push_back(Pair("foundersreward", (int64_t)tx.vout[1].nValue));
|
||||
//}
|
||||
entry.push_back(Pair("coinbasevalue", 3*COIN));
|
||||
CAmount nReward = GetBlockSubsidy(chainActive.Tip()->nHeight+1, Params().GetConsensus());
|
||||
entry.push_back(Pair("coinbasevalue", nReward));
|
||||
entry.push_back(Pair("required", true));
|
||||
txCoinbase = entry;
|
||||
} else
|
||||
|
||||
@@ -52,6 +52,7 @@ int32_t komodo_whoami(char *pubkeystr,int32_t height,uint32_t timestamp);
|
||||
extern uint64_t KOMODO_INTERESTSUM,KOMODO_WALLETBALANCE;
|
||||
extern int32_t KOMODO_LASTMINED,JUMBLR_PAUSE,KOMODO_LONGESTCHAIN;
|
||||
extern char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN];
|
||||
uint32_t komodo_segid32(char *coinaddr);
|
||||
int32_t notarizedtxid_height(char *dest,char *txidstr,int32_t *kmdnotarized_heightp);
|
||||
#define KOMODO_VERSION "0.1.1"
|
||||
extern uint16_t ASSETCHAINS_P2PPORT,ASSETCHAINS_RPCPORT;
|
||||
@@ -326,7 +327,7 @@ UniValue validateaddress(const UniValue& params, bool fHelp)
|
||||
|
||||
CScript scriptPubKey = GetScriptForDestination(dest);
|
||||
ret.push_back(Pair("scriptPubKey", HexStr(scriptPubKey.begin(), scriptPubKey.end())));
|
||||
|
||||
ret.push_back(Pair("segid", (int32_t)komodo_segid32((char *)params[0].get_str().c_str()) & 0x3f));
|
||||
#ifdef ENABLE_WALLET
|
||||
isminetype mine = pwalletMain ? IsMine(*pwalletMain, dest) : ISMINE_NO;
|
||||
ret.push_back(Pair("ismine", (mine & ISMINE_SPENDABLE) ? true : false));
|
||||
@@ -633,12 +634,12 @@ bool getAddressesFromParams(const UniValue& params, std::vector<std::pair<uint16
|
||||
uint160 hashBytes;
|
||||
int type = 0;
|
||||
if (!address.GetIndexKey(hashBytes, type)) {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addresses");
|
||||
}
|
||||
addresses.push_back(std::make_pair(hashBytes, type));
|
||||
}
|
||||
} else {
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid address");
|
||||
throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid addresse");
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -681,8 +682,8 @@ UniValue getaddressmempool(const UniValue& params, bool fHelp)
|
||||
" }\n"
|
||||
"]\n"
|
||||
"\nExamples:\n"
|
||||
+ HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
|
||||
+ HelpExampleRpc("getaddressmempool", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
|
||||
+ HelpExampleCli("getaddressmempool", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'")
|
||||
+ HelpExampleRpc("getaddressmempool", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}")
|
||||
);
|
||||
|
||||
std::vector<std::pair<uint160, int> > addresses;
|
||||
@@ -752,8 +753,8 @@ UniValue getaddressutxos(const UniValue& params, bool fHelp)
|
||||
" }\n"
|
||||
"]\n"
|
||||
"\nExamples:\n"
|
||||
+ HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
|
||||
+ HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
|
||||
+ HelpExampleCli("getaddressutxos", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'")
|
||||
+ HelpExampleRpc("getaddressutxos", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}")
|
||||
);
|
||||
|
||||
bool includeChainInfo = false;
|
||||
@@ -839,8 +840,8 @@ UniValue getaddressdeltas(const UniValue& params, bool fHelp)
|
||||
" }\n"
|
||||
"]\n"
|
||||
"\nExamples:\n"
|
||||
+ HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
|
||||
+ HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
|
||||
+ HelpExampleCli("getaddressdeltas", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'")
|
||||
+ HelpExampleRpc("getaddressdeltas", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}")
|
||||
);
|
||||
|
||||
|
||||
@@ -956,8 +957,8 @@ UniValue getaddressbalance(const UniValue& params, bool fHelp)
|
||||
" \"received\" (string) The total number of satoshis received (including change)\n"
|
||||
"}\n"
|
||||
"\nExamples:\n"
|
||||
+ HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
|
||||
+ HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
|
||||
+ HelpExampleCli("getaddressbalance", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'")
|
||||
+ HelpExampleRpc("getaddressbalance", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}")
|
||||
);
|
||||
|
||||
std::vector<std::pair<uint160, int> > addresses;
|
||||
@@ -992,6 +993,23 @@ UniValue getaddressbalance(const UniValue& params, bool fHelp)
|
||||
|
||||
}
|
||||
|
||||
int32_t komodo_snapshot();
|
||||
|
||||
UniValue getsnapshot(const UniValue& params, bool fHelp)
|
||||
{
|
||||
UniValue result(UniValue::VOBJ); int64_t total;
|
||||
if ( fHelp || params.size() > 0 )
|
||||
{
|
||||
throw runtime_error(
|
||||
"getsnapshot\n"
|
||||
);
|
||||
}
|
||||
if ( (total= komodo_snapshot()) >= 0 )
|
||||
result.push_back(Pair("total", (double)total/COIN));
|
||||
else result.push_back(Pair("error", "no addressindex"));
|
||||
return(result);
|
||||
}
|
||||
|
||||
UniValue getaddresstxids(const UniValue& params, bool fHelp)
|
||||
{
|
||||
if (fHelp || params.size() != 1)
|
||||
@@ -1014,8 +1032,8 @@ UniValue getaddresstxids(const UniValue& params, bool fHelp)
|
||||
" ,...\n"
|
||||
"]\n"
|
||||
"\nExamples:\n"
|
||||
+ HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}'")
|
||||
+ HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX\"]}")
|
||||
+ HelpExampleCli("getaddresstxids", "'{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}'")
|
||||
+ HelpExampleRpc("getaddresstxids", "{\"addresses\": [\"RY5LccmGiX9bUHYGtSWQouNy1yFhc5rM87\"]}")
|
||||
);
|
||||
|
||||
std::vector<std::pair<uint160, int> > addresses;
|
||||
|
||||
@@ -350,6 +350,7 @@ static const CRPCCommand vRPCCommands[] =
|
||||
{ "addressindex", "getaddressdeltas", &getaddressdeltas, false },
|
||||
{ "addressindex", "getaddresstxids", &getaddresstxids, false },
|
||||
{ "addressindex", "getaddressbalance", &getaddressbalance, false },
|
||||
{ "addressindex", "getsnapshot", &getsnapshot, false },
|
||||
|
||||
/* Utility functions */
|
||||
{ "util", "createmultisig", &createmultisig, true },
|
||||
|
||||
@@ -177,6 +177,7 @@ extern UniValue getaddressmempool(const UniValue& params, bool fHelp);
|
||||
extern UniValue getaddressutxos(const UniValue& params, bool fHelp);
|
||||
extern UniValue getaddressdeltas(const UniValue& params, bool fHelp);
|
||||
extern UniValue getaddresstxids(const UniValue& params, bool fHelp);
|
||||
extern UniValue getsnapshot(const UniValue& params, bool fHelp);
|
||||
extern UniValue getaddressbalance(const UniValue& params, bool fHelp);
|
||||
extern UniValue getpeerinfo(const UniValue& params, bool fHelp);
|
||||
extern UniValue ping(const UniValue& params, bool fHelp);
|
||||
|
||||
@@ -158,7 +158,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
for (unsigned int i = 0; i < sizeof(blockinfo)/sizeof(*blockinfo); ++i)
|
||||
{
|
||||
// Simple block creation, nothing special yet:
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
||||
|
||||
CBlock *pblock = &pblocktemplate->block; // pointer for convenience
|
||||
pblock->nVersion = 4;
|
||||
@@ -270,7 +270,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
}
|
||||
|
||||
// Just to make sure we can still make simple blocks
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
||||
delete pblocktemplate;
|
||||
|
||||
// block sigops > limit: 1000 CHECKMULTISIG + 1
|
||||
@@ -289,7 +289,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
|
||||
tx.vin[0].prevout.hash = hash;
|
||||
}
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
||||
delete pblocktemplate;
|
||||
mempool.clear();
|
||||
|
||||
@@ -310,14 +310,14 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(spendsCoinbase).FromTx(tx));
|
||||
tx.vin[0].prevout.hash = hash;
|
||||
}
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
||||
delete pblocktemplate;
|
||||
mempool.clear();
|
||||
|
||||
// orphan in mempool
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).FromTx(tx));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
||||
delete pblocktemplate;
|
||||
mempool.clear();
|
||||
|
||||
@@ -335,7 +335,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
tx.vout[0].nValue = 49000LL;
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
||||
delete pblocktemplate;
|
||||
mempool.clear();
|
||||
|
||||
@@ -346,7 +346,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
tx.vout[0].nValue = 0;
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
||||
delete pblocktemplate;
|
||||
mempool.clear();
|
||||
|
||||
@@ -364,7 +364,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
tx.vout[0].nValue -= 10000;
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(false).FromTx(tx));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
||||
delete pblocktemplate;
|
||||
mempool.clear();
|
||||
|
||||
@@ -378,17 +378,17 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
tx.vout[0].scriptPubKey = CScript() << OP_2;
|
||||
hash = tx.GetHash();
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(true).FromTx(tx));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
||||
delete pblocktemplate;
|
||||
mempool.clear();
|
||||
|
||||
// subsidy changing
|
||||
int nHeight = chainActive.Height();
|
||||
chainActive.Tip()->nHeight = 209999;
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
||||
delete pblocktemplate;
|
||||
chainActive.Tip()->nHeight = 210000;
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
||||
delete pblocktemplate;
|
||||
chainActive.Tip()->nHeight = nHeight;
|
||||
|
||||
@@ -420,7 +420,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
mempool.addUnchecked(hash, entry.Time(GetTime()).SpendsCoinbase(true).FromTx(tx2));
|
||||
BOOST_CHECK(!CheckFinalTx(tx2, LOCKTIME_MEDIAN_TIME_PAST));
|
||||
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
||||
|
||||
// Neither tx should have made it into the template.
|
||||
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 1);
|
||||
@@ -435,7 +435,7 @@ BOOST_AUTO_TEST_CASE(CreateNewBlock_validity)
|
||||
//BOOST_CHECK(CheckFinalTx(tx));
|
||||
//BOOST_CHECK(CheckFinalTx(tx2));
|
||||
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey));
|
||||
BOOST_CHECK(pblocktemplate = CreateNewBlock(scriptPubKey,-1));
|
||||
BOOST_CHECK_EQUAL(pblocktemplate->block.vtx.size(), 2);
|
||||
delete pblocktemplate;
|
||||
|
||||
|
||||
44
src/txdb.cpp
44
src/txdb.cpp
@@ -396,6 +396,50 @@ bool CBlockTreeDB::ReadAddressIndex(uint160 addressHash, int type,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool getAddressFromIndex(const int &type, const uint160 &hash, std::string &address);
|
||||
|
||||
int64_t CBlockTreeDB::Snapshot()
|
||||
{
|
||||
char chType; int64_t total = -1; std::string address;
|
||||
boost::scoped_ptr<leveldb::Iterator> pcursor(NewIterator());
|
||||
pcursor->SeekToFirst();
|
||||
fprintf(stderr,"pcursor iterate\n");
|
||||
while (pcursor->Valid())
|
||||
{
|
||||
boost::this_thread::interruption_point();
|
||||
try
|
||||
{
|
||||
leveldb::Slice slKey = pcursor->key();
|
||||
CDataStream ssKey(slKey.data(), slKey.data()+slKey.size(), SER_DISK, CLIENT_VERSION);
|
||||
CAddressIndexKey indexKey;
|
||||
ssKey >> chType;
|
||||
ssKey >> indexKey;
|
||||
fprintf(stderr,"chType.%d\n",chType);
|
||||
if ( chType == DB_ADDRESSINDEX )
|
||||
{
|
||||
try {
|
||||
leveldb::Slice slValue = pcursor->value();
|
||||
CDataStream ssValue(slValue.data(), slValue.data()+slValue.size(), SER_DISK, CLIENT_VERSION);
|
||||
CAmount nValue;
|
||||
ssValue >> nValue;
|
||||
getAddressFromIndex(indexKey.type, indexKey.hashBytes, address);
|
||||
fprintf(stderr,"{\"%s\", %.8f},\n",address.c_str(),(double)nValue/COIN);
|
||||
if ( total < 0 )
|
||||
total = (int64_t)nValue;
|
||||
else total += (int64_t)nValue;
|
||||
//addressIndex.push_back(make_pair(indexKey, nValue));
|
||||
pcursor->Next();
|
||||
} catch (const std::exception& e) {
|
||||
return error("failed to get address index value");
|
||||
}
|
||||
} else { break; }
|
||||
} catch (const std::exception& e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return(total);
|
||||
}
|
||||
|
||||
bool CBlockTreeDB::WriteTimestampIndex(const CTimestampIndexKey ×tampIndex) {
|
||||
CLevelDBBatch batch;
|
||||
batch.Write(make_pair(DB_TIMESTAMPINDEX, timestampIndex), 0);
|
||||
|
||||
@@ -94,6 +94,7 @@ public:
|
||||
bool ReadFlag(const std::string &name, bool &fValue);
|
||||
bool LoadBlockIndexGuts();
|
||||
bool blockOnchainActive(const uint256 &hash);
|
||||
int64_t Snapshot();
|
||||
};
|
||||
|
||||
#endif // BITCOIN_TXDB_H
|
||||
|
||||
@@ -2697,32 +2697,34 @@ UniValue listunspent(const UniValue& params, bool fHelp)
|
||||
uint64_t komodo_interestsum()
|
||||
{
|
||||
#ifdef ENABLE_WALLET
|
||||
uint64_t interest,sum = 0; int32_t txheight; uint32_t locktime;
|
||||
vector<COutput> vecOutputs;
|
||||
assert(pwalletMain != NULL);
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
pwalletMain->AvailableCoins(vecOutputs, false, NULL, true);
|
||||
BOOST_FOREACH(const COutput& out,vecOutputs)
|
||||
if ( GetBoolArg("-disablewallet", false) == 0 )
|
||||
{
|
||||
CAmount nValue = out.tx->vout[out.i].nValue;
|
||||
if ( out.tx->nLockTime != 0 && out.fSpendable != 0 )
|
||||
uint64_t interest,sum = 0; int32_t txheight; uint32_t locktime;
|
||||
vector<COutput> vecOutputs;
|
||||
assert(pwalletMain != NULL);
|
||||
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||
pwalletMain->AvailableCoins(vecOutputs, false, NULL, true);
|
||||
BOOST_FOREACH(const COutput& out,vecOutputs)
|
||||
{
|
||||
BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
|
||||
CBlockIndex *tipindex,*pindex = it->second;
|
||||
if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 )
|
||||
CAmount nValue = out.tx->vout[out.i].nValue;
|
||||
if ( out.tx->nLockTime != 0 && out.fSpendable != 0 )
|
||||
{
|
||||
interest = komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,0,nValue,(int32_t)tipindex->nHeight);
|
||||
//interest = komodo_interest(pindex->nHeight,nValue,out.tx->nLockTime,tipindex->nTime);
|
||||
sum += interest;
|
||||
BlockMap::iterator it = mapBlockIndex.find(pcoinsTip->GetBestBlock());
|
||||
CBlockIndex *tipindex,*pindex = it->second;
|
||||
if ( pindex != 0 && (tipindex= chainActive.Tip()) != 0 )
|
||||
{
|
||||
interest = komodo_accrued_interest(&txheight,&locktime,out.tx->GetHash(),out.i,0,nValue,(int32_t)tipindex->nHeight);
|
||||
//interest = komodo_interest(pindex->nHeight,nValue,out.tx->nLockTime,tipindex->nTime);
|
||||
sum += interest;
|
||||
}
|
||||
}
|
||||
}
|
||||
KOMODO_INTERESTSUM = sum;
|
||||
KOMODO_WALLETBALANCE = pwalletMain->GetBalance();
|
||||
return(sum);
|
||||
}
|
||||
KOMODO_INTERESTSUM = sum;
|
||||
KOMODO_WALLETBALANCE = pwalletMain->GetBalance();
|
||||
return(sum);
|
||||
#else
|
||||
return(0);
|
||||
#endif
|
||||
return(0);
|
||||
}
|
||||
|
||||
UniValue fundrawtransaction(const UniValue& params, bool fHelp)
|
||||
|
||||
Reference in New Issue
Block a user