Browse Source

add getiguanajson RPC, for ERA2 only at this stage.

pull/27/head
blackjok3r 6 years ago
parent
commit
7d13c2e5a0
  1. 24
      src/notaries_staked.cpp
  2. 11
      src/notaries_staked.h
  3. 45
      src/rpcmisc.cpp

24
src/notaries_staked.cpp

@ -10,6 +10,18 @@ extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY;
extern pthread_mutex_t staked_mutex;
extern uint8_t NOTARY_PUBKEY33[33],NUM_NOTARIES;
const char *iguanaSeeds[8][1] =
{
{"80.240.17.222"},
{"103.6.12.112"},
{"18.224.176.46"},
{"45.76.120.247"},
{"103.6.12.112"},
{"103.6.12.112"},
{"103.6.12.112"},
{"103.6.12.112"},
};
// Era 1 set of pubkeys
const char *notaries_STAKED1[][2] =
{
@ -113,9 +125,9 @@ int num_notaries_STAKED4 = (sizeof(notaries_STAKED4)/sizeof(*notaries_STAKED4));
int8_t is_STAKED(const char *chain_name) {
int STAKED = 0;
if ( (strcmp(chain_name, "STAKED") == 0) || (strncmp(chain_name, "STAKED", 6) == 0) )
if ( (strcmp(chain_name, "LABS") == 0) || (strncmp(chain_name, "LABS", 4) == 0) )
STAKED = 1;
else if ( (strcmp(chain_name, "STKD") == 0) || (strncmp(chain_name, "STKD", 4) == 0) )
else if ( (strcmp(chain_name, "LAB") == 0) || (strncmp(chain_name, "LAB", 3) == 0) )
STAKED = 2;
else if ( (strcmp(chain_name, "CFEK") == 0) || (strncmp(chain_name, "CFEK", 4) == 0) )
STAKED = 3;
@ -126,13 +138,13 @@ int8_t is_STAKED(const char *chain_name) {
int32_t STAKED_era(int timestamp)
{
int8_t era = 0;
if (timestamp <= STAKED_NOTARIES_TIMESTAMP1)
if (timestamp <= STAKED_NOTARIES_TIMESTAMP[0])
era = 1;
else if (timestamp <= STAKED_NOTARIES_TIMESTAMP2 && timestamp >= (STAKED_NOTARIES_TIMESTAMP1 + STAKED_ERA_GAP))
else if (timestamp <= STAKED_NOTARIES_TIMESTAMP[1] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[0] + STAKED_ERA_GAP))
era = 2;
else if (timestamp <= STAKED_NOTARIES_TIMESTAMP3 && timestamp >= (STAKED_NOTARIES_TIMESTAMP2 + STAKED_ERA_GAP))
else if (timestamp <= STAKED_NOTARIES_TIMESTAMP[2] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[1] + STAKED_ERA_GAP))
era = 3;
else if (timestamp <= STAKED_NOTARIES_TIMESTAMP4 && timestamp >= (STAKED_NOTARIES_TIMESTAMP3 + STAKED_ERA_GAP))
else if (timestamp <= STAKED_NOTARIES_TIMESTAMP[3] && timestamp >= (STAKED_NOTARIES_TIMESTAMP[2] + STAKED_ERA_GAP))
era = 4;
else
era = 0;

11
src/notaries_staked.h

@ -5,12 +5,15 @@
#include "crosschain.h"
#include "cc/CCinclude.h"
static const int32_t iguanaPort = 9997;
static const int8_t BTCminsigs = 13;
static const int8_t overrideMinSigs = 0;
extern const char *iguanaSeeds[8][1];
static const int STAKED_ERA_GAP = 777;
static const int STAKED_NOTARIES_TIMESTAMP1 = 1604211111;
static const int STAKED_NOTARIES_TIMESTAMP2 = 1604222222;
static const int STAKED_NOTARIES_TIMESTAMP3 = 1604233333;
static const int STAKED_NOTARIES_TIMESTAMP4 = 1604244444;
static const int NUM_STAKED_ERAS = 4;
static const int STAKED_NOTARIES_TIMESTAMP[NUM_STAKED_ERAS] = {1542885514, 1604222222, 1604233333, 1604244444};
extern const char *notaries_STAKED1[][2];
extern int num_notaries_STAKED1;

45
src/rpcmisc.cpp

@ -66,9 +66,48 @@ extern std::string NOTARY_PUBKEY,NOTARY_ADDRESS; extern uint8_t NOTARY_PUBKEY33[
UniValue getiguanajson(const UniValue& params, bool fHelp)
{
if ( params.size() != 1 )
throw runtime_error("please supply old staked.json!\n");
UniValue json = params[0].get_obj();
if (fHelp || params.size() != 0)
throw runtime_error("getiguanajson\nreturns json for iguana, for the current ERA.");
UniValue json(UniValue::VOBJ);
UniValue seeds(UniValue::VARR);
UniValue notaries(UniValue::VARR);
// get the current era, use local time for now.
// should ideally take blocktime of last known block.
int now = time(NULL); int32_t era;
for (int32_t i = 0; i < NUM_STAKED_ERAS; i++) {
if ( now <= STAKED_NOTARIES_TIMESTAMP[i] ) {
era = i + 1;
break;
}
}
if ( era != 2 )
throw runtime_error("its not era2 yet!");
// loop over seeds array and push back to json array for seeds
for (int8_t i = 0; i < 8; i++) {
seeds.push_back(iguanaSeeds[i][0]);
}
// loop over era's notaries and push back each pair to the notary array
for (int8_t i = 0; i < num_notaries_STAKED2; i++) {
UniValue notary(UniValue::VOBJ);
notary.push_back(Pair(notaries_STAKED2[i][0],notaries_STAKED2[i][1]));
notaries.push_back(notary);
}
// get the min sigs
int minsigs;
if ( num_notaries_STAKED2/5 > overrideMinSigs )
minsigs = (num_notaries_STAKED2 + 4) / 5;
else
minsigs = overrideMinSigs;
json.push_back(Pair("port",iguanaPort));
json.push_back(Pair("BTCminsigs",BTCminsigs));
json.push_back(Pair("minsigs",minsigs));
json.push_back(Pair("seeds", seeds));
json.push_back(Pair("notaries",notaries));
return json;
}

Loading…
Cancel
Save