Browse Source

DPoW updates

pull/305/head
Duke Leto 4 years ago
parent
commit
461c10db0e
  1. 2
      src/komodo_defs.h
  2. 47
      src/komodo_notary.h
  3. 6
      src/komodo_utils.h
  4. 2
      src/rpc/blockchain.cpp

2
src/komodo_defs.h

@ -461,7 +461,7 @@ extern std::vector<std::string> vWhiteListAddress;
extern std::map <std::int8_t, int32_t> mapHeightEvalActivate;
void komodo_netevent(std::vector<uint8_t> payload);
int32_t getacseason(uint32_t timestamp);
int32_t getkmdseason(int32_t height);
int32_t gethushseason(int32_t height);
#define IGUANA_MAXSCRIPTSIZE 10001
#define KOMODO_KVDURATION 1440

47
src/komodo_notary.h

@ -61,7 +61,7 @@ const char *Notaries_genesis[][2] =
#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9"
int32_t getkmdseason(int32_t height)
int32_t gethushseason(int32_t height)
{
if ( height <= KMD_SEASON_HEIGHTS[0] )
return(1);
@ -90,42 +90,36 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp;
static uint8_t kmd_pubkeys[NUM_KMD_SEASONS][64][33],didinit[NUM_KMD_SEASONS];
if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 )
if ( timestamp == 0 && ASSETCHAINS_SYMBOL[0] != 0 ) {
timestamp = komodo_heightstamp(height);
else if ( ASSETCHAINS_SYMBOL[0] == 0 )
} else if ( ASSETCHAINS_SYMBOL[0] == 0 ) {
timestamp = 0;
}
// If this chain is not a staked chain, use the normal Komodo logic to determine notaries. This allows KMD to still sync and use its proper pubkeys for dPoW.
if ( is_STAKED(ASSETCHAINS_SYMBOL) == 0 )
int32_t hush_season = 0;
bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false;
hush_season = ishush3 ? gethushseason(height) : getacseason(timestamp);
if ( hush_season != 0 )
{
int32_t kmd_season = 0;
bool ishush3 = strncmp(ASSETCHAINS_SYMBOL, "HUSH3",5) == 0 ? true : false;
if ( ishush3 ) {
// This is HUSH, use block heights to determine the notary season..
kmd_season = getkmdseason(height);
} else {
// Use timestamp to detemine notary pubkeys.
kmd_season = getacseason(timestamp);
}
if ( kmd_season != 0 )
if ( didinit[hush_season-1] == 0 )
{
if ( didinit[kmd_season-1] == 0 )
for (i=0; i<NUM_KMD_NOTARIES; i++)
decode_hex(kmd_pubkeys[hush_season-1][i],33,(char *)notaries_elected[hush_season-1][i][1]);
if ( ASSETCHAINS_PRIVATE != 0 )
{
for (i=0; i<NUM_KMD_NOTARIES; i++)
decode_hex(kmd_pubkeys[kmd_season-1][i],33,(char *)notaries_elected[kmd_season-1][i][1]);
if ( ASSETCHAINS_PRIVATE != 0 )
{
// we need to populate the address array for the notary exemptions.
for (i = 0; i<NUM_KMD_NOTARIES; i++)
pubkey2addr((char *)NOTARY_ADDRESSES[kmd_season-1][i],(uint8_t *)kmd_pubkeys[kmd_season-1][i]);
}
didinit[kmd_season-1] = 1;
// we need to populate the address array for the notary exemptions.
for (i = 0; i<NUM_KMD_NOTARIES; i++)
pubkey2addr((char *)NOTARY_ADDRESSES[hush_season-1][i],(uint8_t *)kmd_pubkeys[hush_season-1][i]);
}
memcpy(pubkeys,kmd_pubkeys[kmd_season-1],NUM_KMD_NOTARIES * 33);
return(NUM_KMD_NOTARIES);
didinit[hush_season-1] = 1;
}
memcpy(pubkeys,kmd_pubkeys[hush_season-1],NUM_KMD_NOTARIES * 33);
return(NUM_KMD_NOTARIES);
}
//TODO: delete staked chain junk
/*
htind = height / KOMODO_ELECTION_GAP;
if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP )
htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1;
@ -151,6 +145,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
return(n);
printf("error retrieving notaries ht.%d got mask.%llx for n.%d\n",height,(long long)mask,n);
return(-1);
*/
}
int32_t komodo_electednotary(int32_t *numnotariesp,uint8_t *pubkey33,int32_t height,uint32_t timestamp)

6
src/komodo_utils.h

@ -1790,16 +1790,16 @@ void komodo_args(char *argv0)
{
// We dont have any chain data yet, so use system clock to guess.
// I think on season change should reccomend notaries to use -notary to avoid needing this.
int32_t kmd_season = getacseason(time(NULL));
int32_t hush_season = getacseason(time(NULL));
for (i=0; i<64; i++)
{
if ( strcmp(NOTARY_PUBKEY.c_str(),notaries_elected[kmd_season-1][i][1]) == 0 )
if ( strcmp(NOTARY_PUBKEY.c_str(),notaries_elected[hush_season-1][i][1]) == 0 )
{
IS_KOMODO_NOTARY = 1;
KOMODO_MININGTHREADS = 1;
mapArgs ["-genproclimit"] = itostr(KOMODO_MININGTHREADS);
IS_STAKED_NOTARY = -1;
fprintf(stderr,"running as notary.%d %s\n",i,notaries_elected[kmd_season-1][i][0]);
fprintf(stderr,"running as notary.%d %s\n",i,notaries_elected[hush_season-1][i][0]);
break;
}
}

2
src/rpc/blockchain.cpp

@ -1439,7 +1439,7 @@ UniValue gettxout(const UniValue& params, bool fHelp, const CPubKey& mypk)
" \"hex\" : \"hex\", (string) \n"
" \"reqSigs\" : n, (numeric) Number of required signatures\n"
" \"type\" : \"pubkeyhash\", (string) The type, eg pubkeyhash\n"
" \"addresses\" : [ (array of string) array of Komodo addresses\n"
" \"addresses\" : [ (array of string) array of Hush addresses\n"
" \"hushaddress\" (string) Hush address\n"
" ,...\n"
" ]\n"

Loading…
Cancel
Save