here we go :D
This commit is contained in:
@@ -22,11 +22,6 @@
|
||||
|
||||
#define KOMODO_MAINNET_START 178999
|
||||
|
||||
extern char NOTARYADDRS[18][64];
|
||||
|
||||
//extern const char *notaries_STAKED[][2];
|
||||
//extern const int num_notaries_STAKED;
|
||||
|
||||
const char *Notaries_genesis[][2] =
|
||||
{
|
||||
{ "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" },
|
||||
@@ -206,8 +201,6 @@ const char *Notaries_elected1[][2] =
|
||||
};
|
||||
#define CRYPTO777_PUBSECPSTR "020e46e79a2a8d12b9b5d12c7a91adb4e454edfae43c0a0cb805427d2ac7613fd9"
|
||||
|
||||
bool pubkey2addr(char *destaddr,uint8_t *pubkey33);
|
||||
|
||||
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestamp)
|
||||
{
|
||||
static uint8_t elected_pubkeys0[64][33],elected_pubkeys1[64][33],did0,did1; static int32_t n0,n1;
|
||||
@@ -220,6 +213,7 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
|
||||
timestamp = komodo_heightstamp(height);
|
||||
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)
|
||||
{
|
||||
@@ -232,11 +226,6 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
|
||||
n0 = (int32_t)(sizeof(Notaries_elected0)/sizeof(*Notaries_elected0));
|
||||
for (i=0; i<n0; i++) {
|
||||
decode_hex(elected_pubkeys0[i],33,(char *)Notaries_elected0[i][1]);
|
||||
#ifdef SERVER
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)elected_pubkeys0[i]);
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
#endif
|
||||
}
|
||||
did0 = 1;
|
||||
}
|
||||
@@ -252,11 +241,6 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
|
||||
n1 = (int32_t)(sizeof(Notaries_elected1)/sizeof(*Notaries_elected1));
|
||||
for (i=0; i<n1; i++) {
|
||||
decode_hex(elected_pubkeys1[i],33,(char *)Notaries_elected1[i][1]);
|
||||
#ifdef SERVER
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)elected_pubkeys1[i]);
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
#endif
|
||||
}
|
||||
if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
fprintf(stderr,"%s height.%d t.%u elected.%d notaries2\n",ASSETCHAINS_SYMBOL,height,timestamp,n1);
|
||||
@@ -274,42 +258,28 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
|
||||
staked_era = STAKED_era(timestamp);
|
||||
if (staked_era == 1)
|
||||
{
|
||||
if (didstaked1 == 0)
|
||||
{
|
||||
ns1 = num_notaries_STAKED1;
|
||||
for (i=0; i<ns1; i++) {
|
||||
decode_hex(staked_pubkeys1[i],33,(char *)notaries_STAKED1[i][1]);
|
||||
#ifdef SERVER
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys1[i]);
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
#endif
|
||||
if (didstaked1 == 0)
|
||||
{
|
||||
ns1 = num_notaries_STAKED1;
|
||||
for (i=0; i<ns1; i++)
|
||||
decode_hex(staked_pubkeys1[i],33,(char *)notaries_STAKED1[i][1]);
|
||||
didstaked1 = 1;
|
||||
didstaked2 = 0;
|
||||
didstaked3 = 0;
|
||||
didstaked4 = 0;
|
||||
}
|
||||
didstaked1 = 1;
|
||||
didstaked2 = 0;
|
||||
didstaked3 = 0;
|
||||
didstaked4 = 0;
|
||||
printf("%s IS A STAKED CHAIN and is era 1 \n",ASSETCHAINS_SYMBOL);
|
||||
}
|
||||
memcpy(pubkeys,staked_pubkeys1,ns1 * 33);
|
||||
return(ns1);
|
||||
memcpy(pubkeys,staked_pubkeys1,ns1 * 33);
|
||||
return(ns1);
|
||||
} else if (staked_era == 2)
|
||||
{
|
||||
if (didstaked2 == 0)
|
||||
{
|
||||
ns2 = num_notaries_STAKED2;
|
||||
for (i=0; i<ns2; i++) {
|
||||
for (i=0; i<ns2; i++)
|
||||
decode_hex(staked_pubkeys2[i],33,(char *)notaries_STAKED2[i][1]);
|
||||
#ifdef SERVER
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys2[i]);
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
#endif
|
||||
}
|
||||
didstaked2 = 1;
|
||||
didstaked3 = 0;
|
||||
didstaked4 = 0;
|
||||
printf("%s IS A STAKED CHAIN and is era 2 \n",ASSETCHAINS_SYMBOL);
|
||||
}
|
||||
memcpy(pubkeys,staked_pubkeys2,ns2 * 33);
|
||||
return(ns2);
|
||||
@@ -318,17 +288,10 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
|
||||
if (didstaked3 == 0)
|
||||
{
|
||||
ns3 = num_notaries_STAKED3;
|
||||
for (i=0; i<ns3; i++) {
|
||||
for (i=0; i<ns3; i++)
|
||||
decode_hex(staked_pubkeys3[i],33,(char *)notaries_STAKED3[i][1]);
|
||||
#ifdef SERVER
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys3[i]);
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
#endif
|
||||
}
|
||||
didstaked3 = 1;
|
||||
didstaked4 = 0;
|
||||
printf("%s IS A STAKED CHAIN and is era 3 \n",ASSETCHAINS_SYMBOL);
|
||||
}
|
||||
memcpy(pubkeys,staked_pubkeys3,ns3 * 33);
|
||||
return(ns3);
|
||||
@@ -337,16 +300,9 @@ int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height,uint32_t timestam
|
||||
if (didstaked4 == 0)
|
||||
{
|
||||
ns4 = num_notaries_STAKED4;
|
||||
for (i=0; i<ns4; i++) {
|
||||
for (i=0; i<ns4; i++)
|
||||
decode_hex(staked_pubkeys4[i],33,(char *)notaries_STAKED4[i][1]);
|
||||
#ifdef SERVER
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys4[i]);
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
#endif
|
||||
}
|
||||
didstaked4 = 1;
|
||||
printf("%s IS A STAKED CHAIN and is era 4 \n",ASSETCHAINS_SYMBOL);
|
||||
}
|
||||
memcpy(pubkeys,staked_pubkeys4,ns4 * 33);
|
||||
return(ns4);
|
||||
|
||||
@@ -1507,8 +1507,12 @@ void komodo_args(char *argv0)
|
||||
extern int64_t MAX_MONEY;
|
||||
extern const char *Notaries_elected1[][2];
|
||||
std::string name,addn; char *dirname,fname[512],arg0str[64],magicstr[9]; uint8_t magic[4],extrabuf[256],*extraptr=0; FILE *fp; uint64_t val; uint16_t port; int32_t i,baseid,len,n,extralen = 0;
|
||||
IS_KOMODO_NOTARY = GetBoolArg("-notary", false);
|
||||
IS_STAKED_NOTARY = GetArg("-stakednotary", -1);
|
||||
IS_KOMODO_NOTARY = GetBoolArg("-notary", false);
|
||||
if ( IS_STAKED_NOTARY != -1 && IS_KOMODO_NOTARY == true ) {
|
||||
fprintf(stderr, "Cannot be STAKED and KMD notary at he same time!\n");
|
||||
exit(0);
|
||||
}
|
||||
if ( GetBoolArg("-gen", false) != 0 )
|
||||
KOMODO_MININGTHREADS = GetArg("-genproclimit",1);
|
||||
else KOMODO_MININGTHREADS = -1;
|
||||
@@ -1516,7 +1520,7 @@ void komodo_args(char *argv0)
|
||||
fprintf(stderr,"KOMODO_EXCHANGEWALLET mode active\n");
|
||||
DONATION_PUBKEY = GetArg("-donation", "");
|
||||
NOTARY_PUBKEY = GetArg("-pubkey", "");
|
||||
if ( strlen(NOTARY_PUBKEY.c_str()) == 66 )
|
||||
if ( strlen(NOTARY_PUBKEY.c_str()) == 66 )
|
||||
{
|
||||
USE_EXTERNAL_PUBKEY = 1;
|
||||
if ( IS_KOMODO_NOTARY == 0 )
|
||||
@@ -1530,9 +1534,8 @@ void komodo_args(char *argv0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
//KOMODO_PAX = 1;
|
||||
} //else KOMODO_PAX = GetArg("-pax",0);
|
||||
name = GetArg("-ac_name","");
|
||||
}
|
||||
name = GetArg("-ac_name","");
|
||||
if ( argv0 != 0 )
|
||||
{
|
||||
len = (int32_t)strlen(argv0);
|
||||
|
||||
@@ -122,12 +122,10 @@ int is_STAKED(const char *chain_name) {
|
||||
int8_t updateStakedNotary() {
|
||||
std::string notaryname;
|
||||
char Raddress[18]; uint8_t pubkey33[33];
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
decode_hex(pubkey33,33,(char *)NOTARY_PUBKEY.c_str());
|
||||
pubkey2addr((char *)Raddress,(uint8_t *)pubkey33);
|
||||
NOTARY_ADDRESS.clear();
|
||||
NOTARY_ADDRESS.assign(Raddress);
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
return(StakedNotaryID(notaryname,Raddress));
|
||||
}
|
||||
#else
|
||||
@@ -150,39 +148,105 @@ int STAKED_era(int timestamp)
|
||||
era = 4;
|
||||
else
|
||||
era = 0;
|
||||
// if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP.
|
||||
// if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP.
|
||||
|
||||
//fprintf(stderr, "era.%d stakedEra.%d didea.%d\n",era,STAKED_ERA,didera);
|
||||
if ( era > STAKED_ERA || didera == 0 )
|
||||
{
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
STAKED_ERA = era;
|
||||
if ( NOTARY_PUBKEY33[0] != 0 && NOTARYADDRS[0][0] != 0 )
|
||||
if ( NOTARY_PUBKEY33[0] != 0 )
|
||||
{
|
||||
if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 )
|
||||
if ( (IS_STAKED_NOTARY= updateStakedNotary()) > -1 )
|
||||
{
|
||||
IS_KOMODO_NOTARY = 0;
|
||||
fprintf(stderr, "INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera);
|
||||
fprintf(stderr, "Staked Notary Protection Active! INIT.%d RADD.%s ERA.%d didera.%d\n",IS_STAKED_NOTARY,NOTARY_ADDRESS.c_str(),era,didera);
|
||||
}
|
||||
didera++;
|
||||
}
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
}
|
||||
return(era);
|
||||
};
|
||||
|
||||
int8_t StakedNotaryID(std::string ¬aryname, char *Raddress) {
|
||||
int8_t notaryID = -1;
|
||||
static uint8_t staked_pubkeys1[64][33],staked_pubkeys2[64][33],didstaked1,didstaked2;
|
||||
static uint8_t staked_pubkeys3[64][33],staked_pubkeys4[64][33],didstaked3,didstaked4;
|
||||
static char ChainName[65];
|
||||
|
||||
if ( ChainName[0] == 0 ) {
|
||||
if ( ASSETCHAINS_SYMBOL[0] != 0 )
|
||||
strcpy(ChainName,"KMD");
|
||||
else
|
||||
strcpy(ChainName,ASSETCHAINS_SYMBOL);
|
||||
}
|
||||
|
||||
if ( STAKED_ERA != 0 ) {
|
||||
switch (STAKED_ERA) {
|
||||
case 1:
|
||||
if ( didstaked1 == 0 ) {
|
||||
for (i=0; i<num_notaries_STAKED1; i++) {
|
||||
decode_hex(staked_pubkeys1[i],33,(char *)notaries_STAKED1[i][1]);
|
||||
#ifdef SERVER
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys1[i]);
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
#endif
|
||||
}
|
||||
didstaked1 = 1;
|
||||
didstaked2 = 0;
|
||||
didstaked3 = 0;
|
||||
didstaked4 = 0;
|
||||
printf("%s is a STAKED chain in era 1 \n",ChainName);
|
||||
}
|
||||
notaryID = ScanStakedArray(notaries_STAKED1,num_notaries_STAKED1,Raddress,notaryname);
|
||||
break;
|
||||
case 2:
|
||||
if ( didstaked2 == 0 ) {
|
||||
for (i=0; i<num_notaries_STAKED2; i++) {
|
||||
decode_hex(staked_pubkeys2[i],33,(char *)notaries_STAKED2[i][1]);
|
||||
#ifdef SERVER
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys2[i]);
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
#endif
|
||||
}
|
||||
didstaked2 = 1;
|
||||
didstaked3 = 0;
|
||||
didstaked4 = 0;
|
||||
printf("%s is a STAKED chain in era 2 \n",ChainName);
|
||||
}
|
||||
notaryID = ScanStakedArray(notaries_STAKED2,num_notaries_STAKED2,Raddress,notaryname);
|
||||
break;
|
||||
case 3:
|
||||
if ( didstaked3 == 0 ) {
|
||||
for (i=0; i<num_notaries_STAKED3; i++) {
|
||||
decode_hex(staked_pubkeys3[i],33,(char *)notaries_STAKED3[i][1]);
|
||||
#ifdef SERVER
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys3[i]);
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
#endif
|
||||
}
|
||||
didstaked3 = 1;
|
||||
didstaked4 = 0;
|
||||
printf("%s is a STAKED chain in era 3 \n",ChainName);
|
||||
}
|
||||
notaryID = ScanStakedArray(notaries_STAKED3,num_notaries_STAKED3,Raddress,notaryname);
|
||||
break;
|
||||
case 4:
|
||||
if ( didstaked4 == 0 ) {
|
||||
for (i=0; i<num_notaries_STAKED4; i++) {
|
||||
decode_hex(staked_pubkeys4[i],33,(char *)notaries_STAKED4[i][1]);
|
||||
#ifdef SERVER
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
pubkey2addr((char *)NOTARYADDRS[i],(uint8_t *)staked_pubkeys4[i]);
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
#endif
|
||||
}
|
||||
didstaked4 = 1;
|
||||
printf("%s is a STAKED chain in era 4 \n",ChainName);
|
||||
}
|
||||
notaryID = ScanStakedArray(notaries_STAKED4,num_notaries_STAKED4,Raddress,notaryname);
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user