This commit is contained in:
jl777
2016-11-14 12:51:58 -03:00
parent 836e8b3c12
commit d01ec1158c

View File

@@ -52,7 +52,7 @@ const char *Notaries_genesis[][2] =
{ "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" },
}; };
#define KOMODO_ELECTION_GAP 2000 #define KOMODO_ELECTION_GAP ((ASSETCHAINS_SYMBOL[0] == 0) ? 2000 : 100)
#define KOMODO_PUBKEYS_HEIGHT(height) ((int32_t)(((((height)+KOMODO_ELECTION_GAP*.5)/KOMODO_ELECTION_GAP) + 1) * KOMODO_ELECTION_GAP)) #define KOMODO_PUBKEYS_HEIGHT(height) ((int32_t)(((((height)+KOMODO_ELECTION_GAP*.5)/KOMODO_ELECTION_GAP) + 1) * KOMODO_ELECTION_GAP))
struct nutxo_entry { UT_hash_handle hh; uint256 txhash; uint64_t voutmask; int32_t notaryid,height; } *NUTXOS; struct nutxo_entry { UT_hash_handle hh; uint256 txhash; uint64_t voutmask; int32_t notaryid,height; } *NUTXOS;
@@ -94,8 +94,8 @@ int32_t komodo_ratify_threshold(int32_t height,uint64_t signedmask)
int32_t htind,numnotaries,i,wt = 0; int32_t htind,numnotaries,i,wt = 0;
if ( ASSETCHAINS_SYMBOL[0] != 0 ) if ( ASSETCHAINS_SYMBOL[0] != 0 )
return(2); return(2);
if ( (htind= KOMODO_PUBKEYS_HEIGHT(height) / KOMODO_ELECTION_GAP) == 1 ) if ( (htind= KOMODO_PUBKEYS_HEIGHT(height) / KOMODO_ELECTION_GAP) == 0 )
htind = 0; htind = 1;
numnotaries = Pubkeys[htind].numnotaries; numnotaries = Pubkeys[htind].numnotaries;
for (i=0; i<numnotaries; i++) for (i=0; i<numnotaries; i++)
if ( ((1LL << i) & signedmask) != 0 ) if ( ((1LL << i) & signedmask) != 0 )
@@ -108,8 +108,8 @@ int32_t komodo_ratify_threshold(int32_t height,uint64_t signedmask)
int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height) int32_t komodo_notaries(uint8_t pubkeys[64][33],int32_t height)
{ {
int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp; int32_t i,htind,n; uint64_t mask = 0; struct knotary_entry *kp,*tmp;
if ( (htind= KOMODO_PUBKEYS_HEIGHT(height) / KOMODO_ELECTION_GAP) == 1 ) if ( (htind= KOMODO_PUBKEYS_HEIGHT(height) / KOMODO_ELECTION_GAP) == 0 )
htind = 0; htind = 1;
pthread_mutex_lock(&komodo_mutex); pthread_mutex_lock(&komodo_mutex);
n = Pubkeys[htind].numnotaries; n = Pubkeys[htind].numnotaries;
HASH_ITER(hh,Pubkeys[htind].Notaries,kp,tmp) HASH_ITER(hh,Pubkeys[htind].Notaries,kp,tmp)
@@ -146,8 +146,8 @@ void komodo_notarysinit(int32_t height,uint8_t pubkeys[64][33],int32_t num)
} }
} }
N.numnotaries = num; N.numnotaries = num;
if ( (htind= KOMODO_PUBKEYS_HEIGHT(height) / KOMODO_ELECTION_GAP) == 1 ) if ( (htind= KOMODO_PUBKEYS_HEIGHT(height) / KOMODO_ELECTION_GAP) == 0 )
htind = 0; htind = 1;
for (i=htind; i<sizeof(Pubkeys)/sizeof(*Pubkeys); i++) for (i=htind; i<sizeof(Pubkeys)/sizeof(*Pubkeys); i++)
{ {
Pubkeys[i] = N; Pubkeys[i] = N;
@@ -163,8 +163,8 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33)
*notaryidp = -1; *notaryidp = -1;
if ( height < 0 || height/KOMODO_ELECTION_GAP >= sizeof(Pubkeys)/sizeof(*Pubkeys) ) if ( height < 0 || height/KOMODO_ELECTION_GAP >= sizeof(Pubkeys)/sizeof(*Pubkeys) )
return(-1); return(-1);
if ( (htind= KOMODO_PUBKEYS_HEIGHT(height) / KOMODO_ELECTION_GAP) == 1 ) if ( (htind= KOMODO_PUBKEYS_HEIGHT(height) / KOMODO_ELECTION_GAP) == 0 )
htind = 0; htind = 1;
pthread_mutex_lock(&komodo_mutex); pthread_mutex_lock(&komodo_mutex);
HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp); HASH_FIND(hh,Pubkeys[htind].Notaries,pubkey33,33,kp);
pthread_mutex_unlock(&komodo_mutex); pthread_mutex_unlock(&komodo_mutex);