Skip to content

Commit 3bcb934

Browse files
author
blackjok3rtt
authored
Merge pull request #24 from jl777/FSM
Fsm
2 parents 1d66838 + ab70094 commit 3bcb934

File tree

4 files changed

+34
-25
lines changed

4 files changed

+34
-25
lines changed

src/komodo_bitcoind.h

+9-9
Original file line numberDiff line numberDiff line change
@@ -889,9 +889,9 @@ int32_t komodo_eligiblenotary(uint8_t pubkeys[66][33],int32_t *mids,uint32_t blo
889889

890890
int32_t komodo_minerids(uint8_t *minerids,int32_t height,int32_t width)
891891
{
892-
int32_t i,j,n,nonz,numnotaries; CBlock block; CBlockIndex *pindex; uint8_t notarypubs33[64][33],pubkey33[33];
892+
int32_t i,j,nonz,numnotaries; CBlock block; CBlockIndex *pindex; uint8_t notarypubs33[64][33],pubkey33[33];
893893
numnotaries = komodo_notaries(notarypubs33,height,0);
894-
for (i=nonz=0; i<width; i++,n++)
894+
for (i=nonz=0; i<width; i++)
895895
{
896896
if ( height-i <= 0 )
897897
continue;
@@ -1112,7 +1112,6 @@ int32_t komodo_validate_interest(const CTransaction &tx,int32_t txheight,uint32_
11121112
commission must be in coinbase.vout[1] and must be >= 10000 sats
11131113
PoS stake must be without txfee and in the last tx in the block at vout[0]
11141114
*/
1115-
extern int32_t ASSETCHAINS_FOUNDERS_PERIOD;
11161115

11171116
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
11181117

@@ -1125,12 +1124,11 @@ uint64_t komodo_commission(const CBlock *pblock,int32_t height)
11251124
nSubsidy = GetBlockSubsidy(height,Params().GetConsensus());
11261125
//fprintf(stderr,"ht.%d nSubsidy %.8f prod %llu\n",height,(double)nSubsidy/COIN,(long long)(nSubsidy * ASSETCHAINS_COMMISSION));
11271126
commission = ((nSubsidy * ASSETCHAINS_COMMISSION) / COIN);
1128-
if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 )
1127+
if ( ASSETCHAINS_FOUNDERS > 1 )
11291128
{
1130-
if ( height % ASSETCHAINS_FOUNDERS_PERIOD == 0 )
1131-
commission = commission * ASSETCHAINS_FOUNDERS_PERIOD;
1132-
else
1133-
commission = 0;
1129+
if ( (height % ASSETCHAINS_FOUNDERS) == 0 )
1130+
commission = commission * ASSETCHAINS_FOUNDERS;
1131+
else commission = 0;
11341132
}
11351133
}
11361134
else
@@ -1809,7 +1807,9 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
18091807
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
18101808
{
18111809
int32_t scriptlen; uint8_t scripthex[10000];
1812-
if ( ASSETCHAINS_SCRIPTPUB.size()/2 == pblock->vtx[0].vout[0].scriptPubKey.size() && scriptlen < sizeof(scripthex) )
1810+
script = (uint8_t *)&pblock->vtx[0].vout[0].scriptPubKey[0];
1811+
scriptlen = (int32_t)pblock->vtx[0].vout[0].scriptPubKey.size();
1812+
if ( ASSETCHAINS_SCRIPTPUB.size()/2 == scriptlen && scriptlen < sizeof(scripthex) )
18131813
{
18141814
decode_hex(scripthex,scriptlen,(char *)ASSETCHAINS_SCRIPTPUB.c_str());
18151815
if ( memcmp(scripthex,script,scriptlen) != 0 )

src/komodo_globals.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ struct komodo_state KOMODO_STATES[34];
4545
#define _COINBASE_MATURITY 100
4646
int COINBASE_MATURITY = _COINBASE_MATURITY;//100;
4747

48-
int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS_PERIOD;
48+
int32_t KOMODO_MININGTHREADS = -1,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET,KOMODO_REWIND,KOMODO_CONNECTING = -1,KOMODO_DEALERNODE,KOMODO_EXTRASATOSHI,ASSETCHAINS_FOUNDERS;
4949
int32_t KOMODO_INSYNC,KOMODO_LASTMINED,prevKOMODO_LASTMINED,KOMODO_CCACTIVATE,JUMBLR_PAUSE = 1;
5050
std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES,ASSETCHAINS_OVERRIDE_PUBKEY,DONATION_PUBKEY,ASSETCHAINS_SCRIPTPUB;
51-
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW,ASSETCHAINS_FOUNDERS;
51+
uint8_t NOTARY_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEY33[33],ASSETCHAINS_OVERRIDE_PUBKEYHASH[20],ASSETCHAINS_PUBLIC,ASSETCHAINS_PRIVATE,ASSETCHAINS_TXPOW;
5252
bool VERUS_MINTBLOCKS;
5353

5454
char ASSETCHAINS_SYMBOL[KOMODO_ASSETCHAIN_MAXLEN],ASSETCHAINS_USERPASS[4096];

src/komodo_utils.h

+22-13
Original file line numberDiff line numberDiff line change
@@ -1500,6 +1500,9 @@ uint32_t komodo_assetmagic(char *symbol,uint64_t supply,uint8_t *extraptr,int32_
15001500
{
15011501
vcalc_sha256(0,hash.bytes,extraptr,extralen);
15021502
crc0 = hash.uints[0];
1503+
int32_t i; for (i=0; i<extralen; i++)
1504+
fprintf(stderr,"%02x",extraptr[i]);
1505+
fprintf(stderr," extralen.%d crc0.%x\n",extralen,crc0);
15031506
}
15041507
return(calc_crc32(crc0,buf,len));
15051508
}
@@ -1765,12 +1768,12 @@ void komodo_args(char *argv0)
17651768

17661769
MAX_BLOCK_SIGOPS = 60000;
17671770
ASSETCHAINS_TXPOW = GetArg("-ac_txpow",0) & 3;
1768-
ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0) & 1;
1771+
ASSETCHAINS_FOUNDERS = GetArg("-ac_founders",0);// & 1;
17691772
ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10);
17701773
ASSETCHAINS_COMMISSION = GetArg("-ac_perc",0);
17711774
ASSETCHAINS_OVERRIDE_PUBKEY = GetArg("-ac_pubkey","");
17721775
ASSETCHAINS_SCRIPTPUB = GetArg("-ac_script","");
1773-
ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0);
1776+
//ASSETCHAINS_FOUNDERS_PERIOD = GetArg("-ac_period",0);
17741777

17751778
if ( (ASSETCHAINS_STAKED= GetArg("-ac_staked",0)) > 100 )
17761779
ASSETCHAINS_STAKED = 100;
@@ -1825,7 +1828,7 @@ void komodo_args(char *argv0)
18251828
}
18261829
if ( ASSETCHAINS_ENDSUBSIDY[0] != 0 || ASSETCHAINS_REWARD[0] != 0 || ASSETCHAINS_HALVING[0] != 0 || ASSETCHAINS_DECAY[0] != 0 || ASSETCHAINS_COMMISSION != 0 || ASSETCHAINS_PUBLIC != 0 || ASSETCHAINS_PRIVATE != 0 || ASSETCHAINS_TXPOW != 0 || ASSETCHAINS_FOUNDERS != 0 || ASSETCHAINS_SCRIPTPUB.size() > 1 )
18271830
{
1828-
fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...]\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2]);
1831+
fprintf(stderr,"perc %.4f%% ac_pub=[%02x%02x%02x...] acsize.%d\n",dstr(ASSETCHAINS_COMMISSION)*100,ASSETCHAINS_OVERRIDE_PUBKEY33[0],ASSETCHAINS_OVERRIDE_PUBKEY33[1],ASSETCHAINS_OVERRIDE_PUBKEY33[2],(int32_t)ASSETCHAINS_SCRIPTPUB.size());
18291832
extraptr = extrabuf;
18301833
memcpy(extraptr,ASSETCHAINS_OVERRIDE_PUBKEY33,33), extralen = 33;
18311834

@@ -1872,13 +1875,19 @@ void komodo_args(char *argv0)
18721875
val = ASSETCHAINS_COMMISSION | (((uint64_t)ASSETCHAINS_STAKED & 0xff) << 32) | (((uint64_t)ASSETCHAINS_CC & 0xffff) << 40) | ((ASSETCHAINS_PUBLIC != 0) << 7) | ((ASSETCHAINS_PRIVATE != 0) << 6) | ASSETCHAINS_TXPOW;
18731876
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(val),(void *)&val);
18741877
if ( ASSETCHAINS_FOUNDERS != 0 )
1875-
{
1876-
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS);
1877-
if ( ASSETCHAINS_FOUNDERS_PERIOD != 0 )
1878-
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS_PERIOD),(void *)&ASSETCHAINS_FOUNDERS_PERIOD);
1879-
}
1878+
{
1879+
uint8_t tmp = 1;
1880+
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(tmp),(void *)&tmp);
1881+
if ( ASSETCHAINS_FOUNDERS > 1 )
1882+
extralen += iguana_rwnum(1,&extraptr[extralen],sizeof(ASSETCHAINS_FOUNDERS),(void *)&ASSETCHAINS_FOUNDERS);
1883+
}
18801884
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
1881-
extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str());
1885+
{
1886+
decode_hex(&extraptr[extralen],ASSETCHAINS_SCRIPTPUB.size()/2,(char *)ASSETCHAINS_SCRIPTPUB.c_str());
1887+
extralen += ASSETCHAINS_SCRIPTPUB.size()/2;
1888+
//extralen += iguana_rwnum(1,&extraptr[extralen],(int32_t)ASSETCHAINS_SCRIPTPUB.size(),(void *)ASSETCHAINS_SCRIPTPUB.c_str());
1889+
fprintf(stderr,"append ac_script %s\n",ASSETCHAINS_SCRIPTPUB.c_str());
1890+
}
18821891
}
18831892

18841893
addn = GetArg("-seednode","");
@@ -1905,11 +1914,11 @@ void komodo_args(char *argv0)
19051914
while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 )
19061915
{
19071916
fprintf(stderr,"waiting for datadir\n");
1908-
#ifndef _WIN32
1917+
#ifndef _WIN32
19091918
sleep(3);
1910-
#else
1911-
boost::this_thread::sleep(boost::posix_time::milliseconds(3000));
1912-
#endif
1919+
#else
1920+
boost::this_thread::sleep(boost::posix_time::milliseconds(3000));
1921+
#endif
19131922
}
19141923
//fprintf(stderr,"Got datadir.(%s)\n",dirname);
19151924
if ( ASSETCHAINS_SYMBOL[0] != 0 )

src/miner.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ CBlockTemplate* CreateNewBlock(const CScript& _scriptPubKeyIn, int32_t gpucount,
148148
CPubKey pk = CPubKey();
149149
std::vector<std::vector<unsigned char>> vAddrs;
150150
txnouttype txT;
151-
if (Solver(scriptPubKeyIn, txT, vAddrs))
151+
if ( scriptPubKeyIn.size() > 0 && Solver(scriptPubKeyIn, txT, vAddrs))
152152
{
153153
if (txT == TX_PUBKEY)
154154
pk = CPubKey(vAddrs[0]);

0 commit comments

Comments
 (0)