make function, so IS notaty can update on era change
This commit is contained in:
@@ -706,13 +706,7 @@ void komodo_init(int32_t height)
|
||||
pubkey2addr((char *)Raddress,(uint8_t *)pubkey33);
|
||||
CBitcoinAddress address(Raddress);
|
||||
NOTARY_ADDRESS = address.ToString();
|
||||
std::string notaryname;
|
||||
if (StakedNotaryID(notaryname, Raddress) != -1 ) {
|
||||
IS_STAKED_NOTARY = 1;
|
||||
IS_KOMODO_NOTARY = 0;
|
||||
} else {
|
||||
IS_STAKED_NOTARY = 0;
|
||||
}
|
||||
updateStakedNotary();
|
||||
#endif
|
||||
if ( height >= 0 )
|
||||
{
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
#include <cstring>
|
||||
|
||||
extern char NOTARYADDRS[18][64];
|
||||
extern int32_t STAKED_ERA;
|
||||
extern std::string NOTARY_ADDRESS;
|
||||
extern int32_t STAKED_ERA,IS_STAKED_NOTARY,IS_KOMODO_NOTARY;
|
||||
|
||||
// Era 1 set of pubkeys
|
||||
const char *notaries_STAKED1[][2] =
|
||||
@@ -114,6 +115,19 @@ int is_STAKED(const char *chain_name) {
|
||||
return(STAKED);
|
||||
};
|
||||
|
||||
int updateStakedNotary() {
|
||||
std::string notaryname;
|
||||
pthread_mutex_lock(&komodo_mutex);
|
||||
if (StakedNotaryID(notaryname,(char *)NOTARY_ADDRESS.c_str()) != -1 ) {
|
||||
IS_STAKED_NOTARY = 1;
|
||||
IS_KOMODO_NOTARY = 0;
|
||||
} else {
|
||||
IS_STAKED_NOTARY = 0;
|
||||
}
|
||||
pthread_mutex_unlock(&komodo_mutex);
|
||||
return(0);
|
||||
}
|
||||
|
||||
int STAKED_era(int timestamp)
|
||||
{
|
||||
int era;
|
||||
@@ -128,8 +142,10 @@ int STAKED_era(int timestamp)
|
||||
else
|
||||
era = 0;
|
||||
// if we are in a gap, return era 0, this allows to invalidate notarizations when in GAP.
|
||||
if ( era > STAKED_ERA )
|
||||
if ( era > STAKED_ERA ) {
|
||||
STAKED_ERA = era;
|
||||
updateStakedNotary();
|
||||
}
|
||||
return(era);
|
||||
};
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ extern int num_notaries_STAKED4;
|
||||
|
||||
int is_STAKED(const char *chain_name);
|
||||
int STAKED_era(int timestamp);
|
||||
void updateStakedNotary();
|
||||
int8_t StakedNotaryID(std::string ¬aryname, char *Raddress);
|
||||
int8_t ScanStakedArray(const char *notaries_chosen[][2],int num_notaries,char *Raddress,std::string ¬aryname);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user