Browse Source

Scaling fixes for iguana notary

patch-3
jl777 7 years ago
parent
commit
727d48548e
  1. 1279
      deprecated/iguana_notary.c
  2. 3
      iguana/dpow/dPoW.h
  3. 2
      iguana/iguana777.h
  4. 51
      iguana/iguana_notary.c
  5. 2
      includes/iguana_apideclares.h

1279
deprecated/iguana_notary.c

File diff suppressed because it is too large

3
iguana/dpow/dPoW.h

@ -21,6 +21,7 @@
#define DPOW_FIRSTRATIFY 1000
#define DPOW_CHECKPOINTFREQ 10
#define DPOW_MAXFREQ 100
#define DPOW_MINSIGS 13
#define DPOW_MIN_ASSETCHAIN_SIGS 11
//#define DPOW_M(bp) ((bp)->minsigs) // (((bp)->numnotaries >> 1) + 1)
@ -137,7 +138,7 @@ struct dpow_info
struct dpow_hashheight approved[DPOW_FIFOSIZE],notarized[DPOW_FIFOSIZE];
bits256 activehash,lastnotarized,srctx[DPOW_MAXTX],desttx[DPOW_MAXTX];
uint32_t SRCREALTIME,lastsrcupdate,destupdated,srcconfirms,numdesttx,numsrctx,lastsplit,cancelratify;
int32_t lastheight,maxblocks,SRCHEIGHT,SHORTFLAG,ratifying;
int32_t lastheight,maxblocks,SRCHEIGHT,SHORTFLAG,ratifying,minsigs,freq;
struct pax_transaction *PAX;
portable_mutex_t paxmutex,dexmutex;
uint32_t ipbits[128],numipbits;

2
iguana/iguana777.h

@ -167,7 +167,7 @@ struct supernet_info
uint8_t *pingbuf;
struct basilisk_request DEXaccept;
FILE *dexfp;
struct dpow_info DPOWS[1024]; int32_t numdpows,dpowsock,dexsock,pubsock,repsock,subsock,reqsock;
struct dpow_info *DPOWS; int32_t maxdpows,numdpows,dpowsock,dexsock,pubsock,repsock,subsock,reqsock;
struct delayedPoW_info dPoW;
struct basilisk_spend *spends; int32_t numspends;
char bindaddr[64];

51
iguana/iguana_notary.c

@ -61,10 +61,10 @@ void dpow_checkpointset(struct supernet_info *myinfo,struct dpow_checkpoint *che
void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height,bits256 hash,uint32_t timestamp,uint32_t blocktime)
{
//struct komodo_ccdataMoMoM mdata; cJSON *blockjson; uint64_t signedmask; struct iguana_info *coin;
void **ptrs; char str[65]; struct dpow_checkpoint checkpoint; int32_t freq,minsigs,i,ht; struct dpow_block *bp;
void **ptrs; char str[65]; struct dpow_checkpoint checkpoint; int32_t i,ht; struct dpow_block *bp;
dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime);
checkpoint = dp->srcfifo[dp->srcconfirms];
if ( strcmp("BTC",dp->dest) == 0 )
/*if ( strcmp("BTC",dp->dest) == 0 )
{
freq = DPOW_CHECKPOINTFREQ;
minsigs = Notaries_BTCminsigs; //DPOW_MINSIGS;
@ -72,10 +72,10 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
else
{
minsigs = Notaries_minsigs; //DPOW_MIN_ASSETCHAIN_SIGS;
if ( strcmp("CHIPS",dp->symbol) == 0 )
freq = 100;
if ( strcmp("CHIPS",dp->symbol) == 0 || strncmp("TEST",dp->symbol,4) == 0)
freq = DPOW_MAXFREQ;
else freq = 1;
}
}*/
dpow_fifoupdate(myinfo,dp->srcfifo,dp->last);
/*if ( strcmp(dp->dest,"KMD") == 0 )//|| strcmp(dp->dest,"CHAIN") == 0 )
{
@ -119,7 +119,9 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
} else return;
} else return;
}*/
if ( bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % freq) == 0 )
if ( dp->freq <= 0 )
dp->freq = 1;
if ( bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % dp->freq) == 0 )
{
if ( (0) && strcmp("KMD",dp->symbol) == 0 )
printf("%s/%s src ht.%d dest.%u nonz.%d %s minsigs.%d\n",dp->symbol,dp->dest,checkpoint.blockhash.height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash),minsigs);
@ -127,7 +129,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
ptrs = calloc(1,sizeof(void *)*5 + sizeof(struct dpow_checkpoint) + sizeof(pthread_t));
ptrs[0] = (void *)myinfo;
ptrs[1] = (void *)dp;
ptrs[2] = (void *)(uint64_t)minsigs;
ptrs[2] = (void *)(uint64_t)dp->minsigs;
if ( strcmp(dp->dest,"KMD") != 0 )
ptrs[3] = (void *)DPOW_DURATION;
else ptrs[3] = (void *)(DPOW_DURATION * 60); // essentially try forever for assetchains
@ -138,13 +140,13 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
if ( OS_thread_create((void *)((uint64_t)&ptrs[5] + sizeof(struct dpow_checkpoint)),NULL,(void *)dpow_statemachinestart,(void *)ptrs) != 0 )
{
}
if ( ht > 500 )
if ( ht > DPOW_MAXFREQ*5 )
{
if ( (0) && strcmp("CHIPS",dp->symbol) == 0 )
printf("ht.%d maxblocks.%d\n",ht,dp->maxblocks);
for (i=ht-500; i>ht-10000&&i>100; i--)
for (i=ht-DPOW_MAXFREQ*5; i>ht-DPOW_MAXFREQ*100&&i>DPOW_MAXFREQ; i--)
{
if ( (i % 100) != 0 && (bp= dp->blocks[i]) != 0 && bp->state == 0xffffffff )
if ( (i % DPOW_MAXFREQ) != 0 && (bp= dp->blocks[i]) != 0 && bp->state == 0xffffffff )
{
dp->blocks[i] = 0;
Numallocated--;
@ -293,9 +295,16 @@ void dpow_addresses()
#include "../includes/iguana_apideclares.h"
#include "../includes/iguana_apideclares2.h"
THREE_STRINGS(iguana,dpow,symbol,dest,pubkey)
THREE_STRINGS_AND_DOUBLE(iguana,dpow,symbol,dest,pubkey,freq)
{
char *retstr,srcaddr[64],destaddr[64]; struct iguana_info *src,*destcoin; cJSON *ismine; int32_t i,srcvalid,destvalid; struct dpow_info *dp = &myinfo->DPOWS[myinfo->numdpows];
char *retstr,srcaddr[64],destaddr[64]; struct iguana_info *src,*destcoin; cJSON *ismine; int32_t i,srcvalid,destvalid; struct dpow_info *dp;
if ( myinfo->numdpows == myinfo->maxdpows )
{
myinfo->maxdpows++;
myinfo->DPOWS = realloc(myinfo->DPOWS,sizeof(*myinfo->DPOWS) * myinfo->maxdpows);
}
dp = &myinfo->DPOWS[myinfo->numdpows];
memset(dp,0,sizeof(*dp));
destvalid = srcvalid = 0;
if ( myinfo->NOTARY.RELAYID < 0 )
{
@ -349,6 +358,20 @@ THREE_STRINGS(iguana,dpow,symbol,dest,pubkey)
}
if ( dp->srcconfirms > DPOW_FIFOSIZE )
dp->srcconfirms = DPOW_FIFOSIZE;
if ( strcmp("BTC",dp->dest) == 0 )
{
dp->freq = DPOW_CHECKPOINTFREQ;
dp->minsigs = Notaries_BTCminsigs; //DPOW_MINSIGS;
}
else
{
dp->minsigs = Notaries_minsigs; //DPOW_MIN_ASSETCHAIN_SIGS;
if ( strcmp("CHIPS",dp->symbol) == 0 || strncmp("TEST",dp->symbol,4) == 0)
dp->freq = DPOW_MAXFREQ;
else if ( freq >= 2 )
dp->freq = freq;
else dp->freq = 1;
}
src = iguana_coinfind(dp->symbol);
destcoin = iguana_coinfind(dp->dest);
if ( src == 0 || destcoin == 0 )
@ -381,7 +404,7 @@ THREE_STRINGS(iguana,dpow,symbol,dest,pubkey)
}
for (i=0; i<33; i++)
printf("%02x",dp->minerkey33[i]);
printf(" DPOW with pubkey.(%s) %s.valid%d %s -> %s %s.valid%d\n",tmp,srcaddr,srcvalid,dp->symbol,dp->dest,destaddr,destvalid);
printf(" DPOW with pubkey.(%s) %s.valid%d %s -> %s %s.valid%d, num.%d/max.%d\n",tmp,srcaddr,srcvalid,dp->symbol,dp->dest,destaddr,destvalid,myinfo->numdpows,myinfo->maxdpows);
if ( srcvalid <= 0 || destvalid <= 0 )
{
dp->symbol[0] = 0;
@ -394,7 +417,7 @@ THREE_STRINGS(iguana,dpow,symbol,dest,pubkey)
}
if ( dp->blocks == 0 )
{
dp->maxblocks = 1000000;
dp->maxblocks = 10000;
dp->blocks = calloc(dp->maxblocks,sizeof(*dp->blocks));
}
portable_mutex_init(&dp->paxmutex);

2
includes/iguana_apideclares.h

@ -174,7 +174,7 @@ STRING_AND_INT(iguana,snapshot,symbol,height);
INT_ARRAY_STRING(iguana,dividends,height,vals,symbol);
THREE_STRINGS(iguana,passthru,asset,function,hex);
STRING_ARG(iguana,initfastfind,activecoin);
THREE_STRINGS(iguana,dpow,symbol,dest,pubkey);
THREE_STRINGS_AND_DOUBLE(iguana,dpow,symbol,dest,pubkey,freq);
STRING_ARG(iguana,peers,activecoin);
STRING_AND_INT(iguana,maxpeers,activecoin,max);
STRING_ARG(iguana,getconnectioncount,activecoin);

Loading…
Cancel
Save