Hush hush hush
This commit is contained in:
@@ -31,16 +31,16 @@ extern CScript HUSH_EARLYTXID_SCRIPTPUB;
|
|||||||
#define PRICES_TXFEE 10000
|
#define PRICES_TXFEE 10000
|
||||||
#define PRICES_MAXLEVERAGE 777
|
#define PRICES_MAXLEVERAGE 777
|
||||||
#define PRICES_SMOOTHWIDTH 1
|
#define PRICES_SMOOTHWIDTH 1
|
||||||
#define KOMODO_MAXPRICES 2048 // must be power of 2 and less than 8192
|
#define HUSH_MAXPRICES 2048 // must be power of 2 and less than 8192
|
||||||
#define KOMODO_PRICEMASK (~(KOMODO_MAXPRICES - 1)) // actually 1111 1000 0000 0000
|
#define KOMODO_PRICEMASK (~(HUSH_MAXPRICES - 1)) // actually 1111 1000 0000 0000
|
||||||
#define PRICES_WEIGHT (KOMODO_MAXPRICES * 1) // 0000 1000 0000 0000
|
#define PRICES_WEIGHT (HUSH_MAXPRICES * 1) // 0000 1000 0000 0000
|
||||||
#define PRICES_MULT (KOMODO_MAXPRICES * 2) // 0001 0000 0000 0000
|
#define PRICES_MULT (HUSH_MAXPRICES * 2) // 0001 0000 0000 0000
|
||||||
#define PRICES_DIV (KOMODO_MAXPRICES * 3) // 0001 1000 0000 0000
|
#define PRICES_DIV (HUSH_MAXPRICES * 3) // 0001 1000 0000 0000
|
||||||
#define PRICES_INV (KOMODO_MAXPRICES * 4) // 0010 0000 0000 0000
|
#define PRICES_INV (HUSH_MAXPRICES * 4) // 0010 0000 0000 0000
|
||||||
#define PRICES_MDD (KOMODO_MAXPRICES * 5) // 0010 1000 0000 0000
|
#define PRICES_MDD (HUSH_MAXPRICES * 5) // 0010 1000 0000 0000
|
||||||
#define PRICES_MMD (KOMODO_MAXPRICES * 6) // 0011 0000 0000 0000
|
#define PRICES_MMD (HUSH_MAXPRICES * 6) // 0011 0000 0000 0000
|
||||||
#define PRICES_MMM (KOMODO_MAXPRICES * 7) // 0011 1000 0000 0000
|
#define PRICES_MMM (HUSH_MAXPRICES * 7) // 0011 1000 0000 0000
|
||||||
#define PRICES_DDD (KOMODO_MAXPRICES * 8) // 0100 0000 0000 0000
|
#define PRICES_DDD (HUSH_MAXPRICES * 8) // 0100 0000 0000 0000
|
||||||
|
|
||||||
//#define PRICES_NORMFACTOR (int64_t)(SATOSHIDEN)
|
//#define PRICES_NORMFACTOR (int64_t)(SATOSHIDEN)
|
||||||
//#define PRICES_POINTFACTOR (int64_t)10000
|
//#define PRICES_POINTFACTOR (int64_t)10000
|
||||||
|
|||||||
@@ -657,7 +657,7 @@ static std::string prices_getsourceexpression(const std::vector<uint16_t> &vec)
|
|||||||
char name[65];
|
char name[65];
|
||||||
std::string operand;
|
std::string operand;
|
||||||
uint16_t opcode = vec[i];
|
uint16_t opcode = vec[i];
|
||||||
int32_t value = (opcode & (KOMODO_MAXPRICES - 1)); // index or weight
|
int32_t value = (opcode & (HUSH_MAXPRICES - 1)); // index or weight
|
||||||
|
|
||||||
switch (opcode & KOMODO_PRICEMASK)
|
switch (opcode & KOMODO_PRICEMASK)
|
||||||
{
|
{
|
||||||
@@ -934,7 +934,7 @@ int32_t prices_syntheticvec(std::vector<uint16_t> &vec, std::vector<std::string>
|
|||||||
opcode = PRICES_DDD, need = 3;
|
opcode = PRICES_DDD, need = 3;
|
||||||
else if (!is_weight_str(opstr) && (ind = komodo_priceind(opstr.c_str())) >= 0)
|
else if (!is_weight_str(opstr) && (ind = komodo_priceind(opstr.c_str())) >= 0)
|
||||||
opcode = ind, need = 0;
|
opcode = ind, need = 0;
|
||||||
else if ((weight = atoi(opstr.c_str())) > 0 && weight < KOMODO_MAXPRICES)
|
else if ((weight = atoi(opstr.c_str())) > 0 && weight < HUSH_MAXPRICES)
|
||||||
{
|
{
|
||||||
opcode = PRICES_WEIGHT | weight;
|
opcode = PRICES_WEIGHT | weight;
|
||||||
need = 1;
|
need = 1;
|
||||||
@@ -993,7 +993,7 @@ int64_t prices_syntheticprice(std::vector<uint16_t> vec, int32_t height, int32_t
|
|||||||
for (i = 0; i < vec.size(); i++)
|
for (i = 0; i < vec.size(); i++)
|
||||||
{
|
{
|
||||||
opcode = vec[i];
|
opcode = vec[i];
|
||||||
value = (opcode & (KOMODO_MAXPRICES - 1)); // index or weight
|
value = (opcode & (HUSH_MAXPRICES - 1)); // index or weight
|
||||||
|
|
||||||
mpz_set_ui(mpzResult, 0); // clear result to test overflow (see below)
|
mpz_set_ui(mpzResult, 0); // clear result to test overflow (see below)
|
||||||
|
|
||||||
@@ -2228,7 +2228,7 @@ static bool prices_ispositionup(const std::vector<uint16_t> &vecparsed, int16_t
|
|||||||
if (vecparsed.size() > 1 && vecparsed.size() <= 3) {
|
if (vecparsed.size() > 1 && vecparsed.size() <= 3) {
|
||||||
uint16_t opcode = vecparsed[0];
|
uint16_t opcode = vecparsed[0];
|
||||||
|
|
||||||
int32_t value = (opcode & (KOMODO_MAXPRICES - 1)); // filter index or weight = opcode & (2048-1)
|
int32_t value = (opcode & (HUSH_MAXPRICES - 1)); // filter index or weight = opcode & (2048-1)
|
||||||
|
|
||||||
if ((opcode & KOMODO_PRICEMASK) == 0) {
|
if ((opcode & KOMODO_PRICEMASK) == 0) {
|
||||||
char name[65];
|
char name[65];
|
||||||
@@ -2277,8 +2277,8 @@ static bool prices_isopposite(BetInfo p1, BetInfo p2) {
|
|||||||
uint16_t opcode1 = p1.vecparsed[0];
|
uint16_t opcode1 = p1.vecparsed[0];
|
||||||
uint16_t opcode2 = p2.vecparsed[0];
|
uint16_t opcode2 = p2.vecparsed[0];
|
||||||
|
|
||||||
int32_t value1 = (opcode1 & (KOMODO_MAXPRICES - 1)); // index or weight
|
int32_t value1 = (opcode1 & (HUSH_MAXPRICES - 1)); // index or weight
|
||||||
int32_t value2 = (opcode2 & (KOMODO_MAXPRICES - 1)); // index or weight
|
int32_t value2 = (opcode2 & (HUSH_MAXPRICES - 1)); // index or weight
|
||||||
|
|
||||||
if ( (opcode1 & KOMODO_PRICEMASK) == 0 && (opcode2 & KOMODO_PRICEMASK) == 0 ) {
|
if ( (opcode1 & KOMODO_PRICEMASK) == 0 && (opcode2 & KOMODO_PRICEMASK) == 0 ) {
|
||||||
char name1[65];
|
char name1[65];
|
||||||
@@ -2311,7 +2311,7 @@ static std::string findMatchedBook(const std::vector<uint16_t> &vecparsed, const
|
|||||||
if (vecparsed.size() > 1 && vecparsed.size() <= 3) {
|
if (vecparsed.size() > 1 && vecparsed.size() <= 3) {
|
||||||
uint16_t opcode = vecparsed[0];
|
uint16_t opcode = vecparsed[0];
|
||||||
|
|
||||||
int32_t value = (opcode & (KOMODO_MAXPRICES - 1)); // filter index or weight = opcode & (2048-1)
|
int32_t value = (opcode & (HUSH_MAXPRICES - 1)); // filter index or weight = opcode & (2048-1)
|
||||||
|
|
||||||
if ((opcode & KOMODO_PRICEMASK) == 0) {
|
if ((opcode & KOMODO_PRICEMASK) == 0) {
|
||||||
char name[65];
|
char name[65];
|
||||||
@@ -2370,7 +2370,7 @@ void prices_getorderbook(std::map<std::string, std::vector<BetInfo> > & bookmatc
|
|||||||
|
|
||||||
if (book[0].vecparsed.size() <= 3) { // only short expr check for match: "BTC_USD,1" or "BTC_USD,!,1"
|
if (book[0].vecparsed.size() <= 3) { // only short expr check for match: "BTC_USD,1" or "BTC_USD,!,1"
|
||||||
char name[65];
|
char name[65];
|
||||||
komodo_pricename(name, (book[0].vecparsed[0] & (KOMODO_MAXPRICES - 1)));
|
komodo_pricename(name, (book[0].vecparsed[0] & (HUSH_MAXPRICES - 1)));
|
||||||
std::string sname = name;
|
std::string sname = name;
|
||||||
bookmatched[sname].push_back(book[0]);
|
bookmatched[sname].push_back(book[0]);
|
||||||
|
|
||||||
|
|||||||
@@ -1569,7 +1569,7 @@ extern std::vector<uint8_t> Mineropret; // opreturn data set by the data gatheri
|
|||||||
#define PRICES_ERRORRATE (COIN / 100) // maximum acceptable change, set at 1%
|
#define PRICES_ERRORRATE (COIN / 100) // maximum acceptable change, set at 1%
|
||||||
#define PRICES_SIZEBIT0 (sizeof(uint32_t) * 4) // 4 uint32_t unixtimestamp, BTCUSD, BTCGBP and BTCEUR
|
#define PRICES_SIZEBIT0 (sizeof(uint32_t) * 4) // 4 uint32_t unixtimestamp, BTCUSD, BTCGBP and BTCEUR
|
||||||
#define KOMODO_LOCALPRICE_CACHESIZE 13
|
#define KOMODO_LOCALPRICE_CACHESIZE 13
|
||||||
#define KOMODO_MAXPRICES 2048
|
#define HUSH_MAXPRICES 2048
|
||||||
#define PRICES_SMOOTHWIDTH 1
|
#define PRICES_SMOOTHWIDTH 1
|
||||||
|
|
||||||
#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0)
|
#define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0)
|
||||||
@@ -1592,10 +1592,10 @@ struct komodo_priceinfo
|
|||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char symbol[64];
|
char symbol[64];
|
||||||
} PRICES[KOMODO_MAXPRICES];
|
} PRICES[HUSH_MAXPRICES];
|
||||||
|
|
||||||
uint32_t PriceCache[KOMODO_LOCALPRICE_CACHESIZE][KOMODO_MAXPRICES];//4+sizeof(Cryptos)/sizeof(*Cryptos)+sizeof(Forex)/sizeof(*Forex)];
|
uint32_t PriceCache[KOMODO_LOCALPRICE_CACHESIZE][HUSH_MAXPRICES];//4+sizeof(Cryptos)/sizeof(*Cryptos)+sizeof(Forex)/sizeof(*Forex)];
|
||||||
int64_t PriceMult[KOMODO_MAXPRICES];
|
int64_t PriceMult[HUSH_MAXPRICES];
|
||||||
int32_t komodo_cbopretsize(uint64_t flags);
|
int32_t komodo_cbopretsize(uint64_t flags);
|
||||||
|
|
||||||
void komodo_PriceCache_shift()
|
void komodo_PriceCache_shift()
|
||||||
@@ -1694,7 +1694,7 @@ int32_t komodo_pricecmp(int32_t nHeight,int32_t n,char *maxflags,uint32_t *price
|
|||||||
// komodo_priceclamp() clamps any price that is beyond tolerance
|
// komodo_priceclamp() clamps any price that is beyond tolerance
|
||||||
int32_t komodo_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int64_t tolerance)
|
int32_t komodo_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int64_t tolerance)
|
||||||
{
|
{
|
||||||
int32_t i; uint32_t newprice; char maxflags[KOMODO_MAXPRICES];
|
int32_t i; uint32_t newprice; char maxflags[HUSH_MAXPRICES];
|
||||||
memset(maxflags,0,sizeof(maxflags));
|
memset(maxflags,0,sizeof(maxflags));
|
||||||
for (i=1; i<n; i++)
|
for (i=1; i<n; i++)
|
||||||
{
|
{
|
||||||
@@ -1710,7 +1710,7 @@ int32_t komodo_priceclamp(int32_t n,uint32_t *pricebits,uint32_t *refprices,int6
|
|||||||
// komodo_mineropret() returns a valid pricedata to add to the coinbase opreturn for nHeight
|
// komodo_mineropret() returns a valid pricedata to add to the coinbase opreturn for nHeight
|
||||||
CScript komodo_mineropret(int32_t nHeight)
|
CScript komodo_mineropret(int32_t nHeight)
|
||||||
{
|
{
|
||||||
CScript opret; char maxflags[KOMODO_MAXPRICES]; uint32_t pricebits[KOMODO_MAXPRICES],prevbits[KOMODO_MAXPRICES]; int32_t maxflag,i,n,numzero=0;
|
CScript opret; char maxflags[HUSH_MAXPRICES]; uint32_t pricebits[HUSH_MAXPRICES],prevbits[HUSH_MAXPRICES]; int32_t maxflag,i,n,numzero=0;
|
||||||
if ( Mineropret.size() >= PRICES_SIZEBIT0 )
|
if ( Mineropret.size() >= PRICES_SIZEBIT0 )
|
||||||
{
|
{
|
||||||
n = (int32_t)(Mineropret.size() / sizeof(uint32_t));
|
n = (int32_t)(Mineropret.size() / sizeof(uint32_t));
|
||||||
@@ -1775,7 +1775,7 @@ void komodo_queuelocalprice(int32_t dir,int32_t height,uint32_t timestamp,uint25
|
|||||||
int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey)
|
int32_t komodo_opretvalidate(const CBlock *block,CBlockIndex * const previndex,int32_t nHeight,CScript scriptPubKey)
|
||||||
{
|
{
|
||||||
int32_t testchain_exemption = 0;
|
int32_t testchain_exemption = 0;
|
||||||
std::vector<uint8_t> vopret; char maxflags[KOMODO_MAXPRICES]; uint256 bhash; double btcusd,btcgbp,btceur; uint32_t localbits[KOMODO_MAXPRICES],pricebits[KOMODO_MAXPRICES],prevbits[KOMODO_MAXPRICES],newprice; int32_t i,j,prevtime,maxflag,lag,lag2,lag3,n,errflag,iter; uint32_t now;
|
std::vector<uint8_t> vopret; char maxflags[HUSH_MAXPRICES]; uint256 bhash; double btcusd,btcgbp,btceur; uint32_t localbits[HUSH_MAXPRICES],pricebits[HUSH_MAXPRICES],prevbits[HUSH_MAXPRICES],newprice; int32_t i,j,prevtime,maxflag,lag,lag2,lag3,n,errflag,iter; uint32_t now;
|
||||||
now = (uint32_t)time(NULL);
|
now = (uint32_t)time(NULL);
|
||||||
if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 )
|
if ( ASSETCHAINS_CBOPRET != 0 && nHeight > 0 )
|
||||||
{
|
{
|
||||||
@@ -2223,7 +2223,7 @@ extern uint256 Queued_reconsiderblock;
|
|||||||
void komodo_cbopretupdate(int32_t forceflag)
|
void komodo_cbopretupdate(int32_t forceflag)
|
||||||
{
|
{
|
||||||
static uint32_t lasttime,lastbtc,pending;
|
static uint32_t lasttime,lastbtc,pending;
|
||||||
static uint32_t pricebits[4],pricebuf[KOMODO_MAXPRICES],forexprices[sizeof(Forex)/sizeof(*Forex)];
|
static uint32_t pricebits[4],pricebuf[HUSH_MAXPRICES],forexprices[sizeof(Forex)/sizeof(*Forex)];
|
||||||
int32_t size; uint32_t flags=0,now; CBlockIndex *pindex;
|
int32_t size; uint32_t flags=0,now; CBlockIndex *pindex;
|
||||||
if ( Queued_reconsiderblock != zeroid )
|
if ( Queued_reconsiderblock != zeroid )
|
||||||
{
|
{
|
||||||
@@ -2325,7 +2325,7 @@ void komodo_cbopretupdate(int32_t forceflag)
|
|||||||
int64_t komodo_pricemult(int32_t ind)
|
int64_t komodo_pricemult(int32_t ind)
|
||||||
{
|
{
|
||||||
int32_t i,j;
|
int32_t i,j;
|
||||||
if ( (ASSETCHAINS_CBOPRET & 1) != 0 && ind < KOMODO_MAXPRICES )
|
if ( (ASSETCHAINS_CBOPRET & 1) != 0 && ind < HUSH_MAXPRICES )
|
||||||
{
|
{
|
||||||
if ( PriceMult[0] == 0 )
|
if ( PriceMult[0] == 0 )
|
||||||
{
|
{
|
||||||
@@ -2355,7 +2355,7 @@ int64_t komodo_pricemult(int32_t ind)
|
|||||||
char *komodo_pricename(char *name,int32_t ind)
|
char *komodo_pricename(char *name,int32_t ind)
|
||||||
{
|
{
|
||||||
strcpy(name,"error");
|
strcpy(name,"error");
|
||||||
if ( (ASSETCHAINS_CBOPRET & 1) != 0 && ind < KOMODO_MAXPRICES )
|
if ( (ASSETCHAINS_CBOPRET & 1) != 0 && ind < HUSH_MAXPRICES )
|
||||||
{
|
{
|
||||||
if ( ind < 4 )
|
if ( ind < 4 )
|
||||||
{
|
{
|
||||||
@@ -2431,7 +2431,7 @@ int32_t komodo_priceind(const char *symbol)
|
|||||||
int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth)
|
int64_t komodo_pricecorrelated(uint64_t seed,int32_t ind,uint32_t *rawprices,int32_t rawskip,uint32_t *nonzprices,int32_t smoothwidth)
|
||||||
{
|
{
|
||||||
int32_t i,j,k,n,iter,correlation,maxcorrelation=0; int64_t firstprice,price,sum,den,mult,refprice,lowprice,highprice;
|
int32_t i,j,k,n,iter,correlation,maxcorrelation=0; int64_t firstprice,price,sum,den,mult,refprice,lowprice,highprice;
|
||||||
if ( PRICES_DAYWINDOW < 2 || ind >= KOMODO_MAXPRICES )
|
if ( PRICES_DAYWINDOW < 2 || ind >= HUSH_MAXPRICES )
|
||||||
return(-1);
|
return(-1);
|
||||||
mult = komodo_pricemult(ind);
|
mult = komodo_pricemult(ind);
|
||||||
if ( nonzprices != 0 )
|
if ( nonzprices != 0 )
|
||||||
@@ -2683,7 +2683,7 @@ int32_t komodo_pricesinit()
|
|||||||
fprintf(stderr,"pricesinit (%s)\n",pricesdir.string().c_str());
|
fprintf(stderr,"pricesinit (%s)\n",pricesdir.string().c_str());
|
||||||
if (!boost::filesystem::exists(pricesdir))
|
if (!boost::filesystem::exists(pricesdir))
|
||||||
boost::filesystem::create_directories(pricesdir), createflag = 1;
|
boost::filesystem::create_directories(pricesdir), createflag = 1;
|
||||||
for (i=0; i<KOMODO_MAXPRICES; i++)
|
for (i=0; i<HUSH_MAXPRICES; i++)
|
||||||
{
|
{
|
||||||
if ( komodo_pricename(PRICES[i].symbol,i) == 0 )
|
if ( komodo_pricename(PRICES[i].symbol,i) == 0 )
|
||||||
break;
|
break;
|
||||||
@@ -2732,7 +2732,7 @@ pthread_mutex_t pricemutex;
|
|||||||
void komodo_pricesupdate(int32_t height,CBlock *pblock)
|
void komodo_pricesupdate(int32_t height,CBlock *pblock)
|
||||||
{
|
{
|
||||||
static int numprices; static uint32_t *ptr32; static int64_t *ptr64,*tmpbuf;
|
static int numprices; static uint32_t *ptr32; static int64_t *ptr64,*tmpbuf;
|
||||||
int32_t ind,offset,width; int64_t correlated,smoothed; uint64_t seed,rngval; uint32_t rawprices[KOMODO_MAXPRICES],buf[PRICES_MAXDATAPOINTS*2];
|
int32_t ind,offset,width; int64_t correlated,smoothed; uint64_t seed,rngval; uint32_t rawprices[HUSH_MAXPRICES],buf[PRICES_MAXDATAPOINTS*2];
|
||||||
width = PRICES_DAYWINDOW;//(2*PRICES_DAYWINDOW + PRICES_SMOOTHWIDTH);
|
width = PRICES_DAYWINDOW;//(2*PRICES_DAYWINDOW + PRICES_SMOOTHWIDTH);
|
||||||
if ( numprices == 0 )
|
if ( numprices == 0 )
|
||||||
{
|
{
|
||||||
@@ -2807,7 +2807,7 @@ int32_t komodo_priceget(int64_t *buf64,int32_t ind,int32_t height,int32_t numblo
|
|||||||
{
|
{
|
||||||
FILE *fp; int32_t retval = PRICES_MAXDATAPOINTS;
|
FILE *fp; int32_t retval = PRICES_MAXDATAPOINTS;
|
||||||
pthread_mutex_lock(&pricemutex);
|
pthread_mutex_lock(&pricemutex);
|
||||||
if ( ind < KOMODO_MAXPRICES && (fp= PRICES[ind].fp) != 0 )
|
if ( ind < HUSH_MAXPRICES && (fp= PRICES[ind].fp) != 0 )
|
||||||
{
|
{
|
||||||
fseek(fp,height * PRICES_MAXDATAPOINTS * sizeof(int64_t),SEEK_SET);
|
fseek(fp,height * PRICES_MAXDATAPOINTS * sizeof(int64_t),SEEK_SET);
|
||||||
if ( fread(buf64,sizeof(int64_t),numblocks*PRICES_MAXDATAPOINTS,fp) != numblocks*PRICES_MAXDATAPOINTS )
|
if ( fread(buf64,sizeof(int64_t),numblocks*PRICES_MAXDATAPOINTS,fp) != numblocks*PRICES_MAXDATAPOINTS )
|
||||||
|
|||||||
@@ -138,8 +138,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;
|
||||||
htind = height / KOMODO_ELECTION_GAP;
|
htind = height / KOMODO_ELECTION_GAP;
|
||||||
if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP )
|
if ( htind >= HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP )
|
||||||
htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1;
|
htind = (HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP) - 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 )
|
||||||
@@ -154,7 +154,7 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num)
|
|||||||
static int32_t hwmheight;
|
static int32_t hwmheight;
|
||||||
int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N;
|
int32_t k,i,htind,height; struct knotary_entry *kp; struct knotaries_entry N;
|
||||||
if ( Pubkeys == 0 )
|
if ( Pubkeys == 0 )
|
||||||
Pubkeys = (struct knotaries_entry *)calloc(1 + (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys));
|
Pubkeys = (struct knotaries_entry *)calloc(1 + (HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP),sizeof(*Pubkeys));
|
||||||
memset(&N,0,sizeof(N));
|
memset(&N,0,sizeof(N));
|
||||||
if ( origheight > 0 )
|
if ( origheight > 0 )
|
||||||
{
|
{
|
||||||
@@ -162,8 +162,8 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num)
|
|||||||
height /= KOMODO_ELECTION_GAP;
|
height /= KOMODO_ELECTION_GAP;
|
||||||
height = ((height + 1) * KOMODO_ELECTION_GAP);
|
height = ((height + 1) * KOMODO_ELECTION_GAP);
|
||||||
htind = (height / KOMODO_ELECTION_GAP);
|
htind = (height / KOMODO_ELECTION_GAP);
|
||||||
if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP )
|
if ( htind >= HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP )
|
||||||
htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1;
|
htind = (HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1;
|
||||||
//printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,SMART_CHAIN_SYMBOL);
|
//printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,SMART_CHAIN_SYMBOL);
|
||||||
} else htind = 0;
|
} else htind = 0;
|
||||||
pthread_mutex_lock(&komodo_mutex);
|
pthread_mutex_lock(&komodo_mutex);
|
||||||
@@ -181,7 +181,7 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
N.numnotaries = num;
|
N.numnotaries = num;
|
||||||
for (i=htind; i<KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP; i++)
|
for (i=htind; i<HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP; i++)
|
||||||
{
|
{
|
||||||
if ( Pubkeys[i].height != 0 && origheight < hwmheight )
|
if ( Pubkeys[i].height != 0 && origheight < hwmheight )
|
||||||
{
|
{
|
||||||
@@ -201,7 +201,7 @@ int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,ui
|
|||||||
// -1 if not notary, 0 if notary, 1 if special notary
|
// -1 if not notary, 0 if notary, 1 if special notary
|
||||||
struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1;
|
struct knotary_entry *kp; int32_t numnotaries=0,htind,modval = -1;
|
||||||
*notaryidp = -1;
|
*notaryidp = -1;
|
||||||
if ( height < 0 )//|| height >= KOMODO_MAXBLOCKS )
|
if ( height < 0 )//|| height >= HUSH_MAXBLOCKS )
|
||||||
{
|
{
|
||||||
printf("hush_chosennotary ht.%d illegal\n",height);
|
printf("hush_chosennotary ht.%d illegal\n",height);
|
||||||
return(-1);
|
return(-1);
|
||||||
@@ -219,8 +219,8 @@ int32_t hush_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33,ui
|
|||||||
if ( Pubkeys == 0 )
|
if ( Pubkeys == 0 )
|
||||||
komodo_init(0);
|
komodo_init(0);
|
||||||
htind = height / KOMODO_ELECTION_GAP;
|
htind = height / KOMODO_ELECTION_GAP;
|
||||||
if ( htind >= KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP )
|
if ( htind >= HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP )
|
||||||
htind = (KOMODO_MAXBLOCKS / KOMODO_ELECTION_GAP) - 1;
|
htind = (HUSH_MAXBLOCKS / KOMODO_ELECTION_GAP) - 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);
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
* Removal or modification of this copyright notice is prohibited. *
|
* Removal or modification of this copyright notice is prohibited. *
|
||||||
* *
|
* *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "hush_defs.h"
|
#include "hush_defs.h"
|
||||||
#include "uthash.h"
|
#include "uthash.h"
|
||||||
#include "utlist.h"
|
#include "utlist.h"
|
||||||
@@ -28,12 +27,10 @@
|
|||||||
|
|
||||||
#ifndef KOMODO_STRUCTS_H
|
#ifndef KOMODO_STRUCTS_H
|
||||||
#define KOMODO_STRUCTS_H
|
#define KOMODO_STRUCTS_H
|
||||||
|
|
||||||
#define GENESIS_NBITS 0x1f00ffff
|
#define GENESIS_NBITS 0x1f00ffff
|
||||||
#define KOMODO_MINRATIFY ((height < 90000) ? 7 : 11)
|
#define KOMODO_MINRATIFY ((height < 90000) ? 7 : 11)
|
||||||
#define KOMODO_NOTARIES_HARDCODED 180000 // DONT CHANGE
|
#define KOMODO_NOTARIES_HARDCODED 180000 // DONT CHANGE
|
||||||
#define KOMODO_MAXBLOCKS 250000 // DONT CHANGE
|
#define HUSH_MAXBLOCKS 250000 // DONT CHANGE
|
||||||
|
|
||||||
#define KOMODO_EVENT_RATIFY 'P'
|
#define KOMODO_EVENT_RATIFY 'P'
|
||||||
#define KOMODO_EVENT_NOTARIZED 'N'
|
#define KOMODO_EVENT_NOTARIZED 'N'
|
||||||
#define KOMODO_EVENT_KMDHEIGHT 'K'
|
#define KOMODO_EVENT_KMDHEIGHT 'K'
|
||||||
|
|||||||
Reference in New Issue
Block a user