Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
967ea445e6
  1. 4
      gecko/gecko.c
  2. 2
      gecko/gecko_miner.c
  3. 22
      iguana/iguana777.c
  4. 4
      iguana/iguana_json.c
  5. 6
      includes/iguana_funcs.h

4
gecko/gecko.c

@ -56,7 +56,7 @@ void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struc
virt->hdrstime = (uint32_t)time(NULL);
}
}
if ( btcd->RELAYNODE != 0 )//&& virt->blocks.hwmchain.height >= virt->longestchain-virt->chain->bundlesize )
//if ( btcd->RELAYNODE != 0 )//&& virt->blocks.hwmchain.height >= virt->longestchain-virt->chain->bundlesize )
{
bitcoin_address(mineraddr,virt->chain->pubtype,myinfo->persistent_pubkey33,33);
//fprintf(stderr,"mine.%s %s\n",virt->symbol,mineraddr);
@ -290,7 +290,7 @@ struct iguana_info *basilisk_geckochain(struct supernet_info *myinfo,char *symbo
int32_t datalen,hdrsize,len=0; struct iguana_info *virt=0; char *hexstr; uint8_t hexbuf[8192],*ptr,*serialized; struct iguana_peer *addr; struct iguana_txblock txdata;
portable_mutex_lock(&myinfo->gecko_mutex);
printf("basilisk_geckochain symbol.%s chain.%s (%s)\n",symbol,chainname,jprint(valsobj,0));
if ( iguana_coinfind(symbol) == 0 && (hexstr= jstr(valsobj,"genesisblock")) != 0 && (virt= iguana_coinadd(symbol,chainname,valsobj)) != 0 )
if ( iguana_coinfind(symbol) == 0 && (hexstr= jstr(valsobj,"genesisblock")) != 0 && (virt= iguana_coinadd(symbol,chainname,valsobj,1)) != 0 )
{
safecopy(virt->name,chainname,sizeof(virt->name));
virt->chain = calloc(1,sizeof(*virt->chain));

2
gecko/gecko_miner.c

@ -331,7 +331,7 @@ int32_t gecko_blocksubmit(struct supernet_info *myinfo,struct iguana_info *btcd,
void gecko_miner(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,int32_t maxmillis,uint8_t *minerpubkey33)
{
struct iguana_zblock newblock; uint32_t prevtimestamp,nBits; int64_t reward = 0; int32_t i,gap,txn_count; char *blockstr,*space[256]; struct gecko_memtx **txptrs; void *ptr; //struct iguana_bundle *bp;
if ( virt->virtualchain == 0 || myinfo->RELAYID < 0 || myinfo->numrelays < 1 )
if ( virt->virtualchain == 0 )//|| myinfo->RELAYID < 0 || myinfo->numrelays < 1 )
return;
if ( (virt->blocks.hwmchain.height % myinfo->numrelays) != myinfo->RELAYID )
{

22
iguana/iguana777.c

@ -37,7 +37,7 @@ struct iguana_info *iguana_coinfind(char *symbol)
return(coin);
}
struct iguana_info *iguana_coinadd(char *symbol,char *name,cJSON *argjson)
struct iguana_info *iguana_coinadd(char *symbol,char *name,cJSON *argjson,int32_t virtcoin)
{
struct iguana_info *coin; uint32_t symbolcrc; char *privatechain; int32_t j; struct supernet_info *myinfo = SuperNET_MYINFO(0);
if ( (coin= iguana_coinfind(symbol)) == 0 )
@ -48,7 +48,7 @@ struct iguana_info *iguana_coinadd(char *symbol,char *name,cJSON *argjson)
coin = mycalloc('C',1,sizeof(*coin));
coin->blockspacesize = IGUANA_MAXPACKETSIZE + 8192;
coin->blockspace = calloc(1,coin->blockspacesize);
if ( (privatechain= jstr(argjson,"geckochain")) != 0 && privatechain[0] != 0 )
if ( virtcoin != 0 || ((privatechain= jstr(argjson,"geckochain")) != 0 && privatechain[0] != 0) )
{
myinfo->allcoins_numvirts++;
coin->virtualchain = 1;
@ -574,9 +574,9 @@ void iguana_helper(void *arg)
{
//if ( helperid == 0 && myinfo->numrelays > 0 && myinfo->genesisresults == 0 )
// basilisk_geckogenesis(myinfo,btcd,0,0,GENESIS_PUBKEY,0,0);
if ( myinfo->allcoins_numvirts > 0 )
//if ( myinfo->allcoins_numvirts > 0 )
{
maxmillis = (10000 / myinfo->allcoins_numvirts) + 1;
maxmillis = (10000 / (myinfo->allcoins_numvirts + 1)) + 1;
n = 0;
//portable_mutex_lock(&myinfo->allcoins_mutex);
HASH_ITER(hh,myinfo->allcoins,virt,tmp)
@ -832,14 +832,14 @@ void iguana_nameset(char name[64],char *symbol,cJSON *json)
}
}
struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,int64_t maxrecvcache,uint64_t services,int32_t initialheight,int32_t maphash,int32_t minconfirms,int32_t maxrequests,int32_t maxbundles,cJSON *json)
struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,int64_t maxrecvcache,uint64_t services,int32_t initialheight,int32_t maphash,int32_t minconfirms,int32_t maxrequests,int32_t maxbundles,cJSON *json,int32_t virtcoin)
{
struct iguana_chain *iguana_createchain(cJSON *json);
struct iguana_info *coin; int32_t j,m,mult,maxval,mapflags; char name[64]; cJSON *peers;
mapflags = IGUANA_MAPRECVDATA | maphash*IGUANA_MAPTXIDITEMS | maphash*IGUANA_MAPPKITEMS | maphash*IGUANA_MAPBLOCKITEMS | maphash*IGUANA_MAPPEERITEMS;
iguana_nameset(name,symbol,json);
if ( (coin= iguana_coinfind(symbol)) == 0 )
coin = iguana_coinadd(symbol,name,json);
coin = iguana_coinadd(symbol,name,json,virtcoin);
//printf("ensure directories maxval.%d mult.%d start.%d end.%d\n",maxval,mult,coin->startPEND,coin->endPEND);
mult = (strcmp("BTC",coin->symbol) != 0) ? 8 : 32;
maxval = IGUANA_MAXPENDBUNDLES;
@ -939,7 +939,7 @@ struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,
return(coin);
}
int32_t iguana_launchcoin(struct supernet_info *myinfo,char *symbol,cJSON *json)
int32_t iguana_launchcoin(struct supernet_info *myinfo,char *symbol,cJSON *json,int32_t virtcoin)
{
int32_t maxpeers,maphash,initialheight,minconfirms,maxrequests,maxbundles; char name[64]; int64_t maxrecvcache; uint64_t services; struct iguana_info **coins,*coin;
if ( symbol == 0 )
@ -948,7 +948,7 @@ int32_t iguana_launchcoin(struct supernet_info *myinfo,char *symbol,cJSON *json)
return(0);
iguana_nameset(name,symbol,json);
printf("launchcoin.%s name.%s\n",symbol,name);
if ( (coin= iguana_coinadd(symbol,name,json)) == 0 )
if ( (coin= iguana_coinadd(symbol,name,json,virtcoin)) == 0 )
return(-1);
if ( myinfo->rpcsymbol[0] == 0 || iguana_coinfind(myinfo->rpcsymbol) == 0 )
strcpy(myinfo->rpcsymbol,symbol);
@ -959,7 +959,7 @@ int32_t iguana_launchcoin(struct supernet_info *myinfo,char *symbol,cJSON *json)
else maphash = 0;
iguana_coinargs(symbol,&maxrecvcache,&minconfirms,&maxpeers,&initialheight,&services,&maxrequests,&maxbundles,json);
coins = mycalloc('A',1+1,sizeof(*coins));
if ( (coin= iguana_setcoin(symbol,coins,maxpeers,maxrecvcache,services,initialheight,maphash,minconfirms,maxrequests,maxbundles,json)) != 0 )
if ( (coin= iguana_setcoin(symbol,coins,maxpeers,maxrecvcache,services,initialheight,maphash,minconfirms,maxrequests,maxbundles,json,virtcoin)) != 0 )
{
coins[0] = (void *)((long)1);
coins[1] = coin;
@ -1001,7 +1001,7 @@ void iguana_coins(void *arg)
if ( (symbol= jstr(json,"coin")) != 0 && strncmp(symbol,"BTC",3) == 0 )
{
coins = mycalloc('A',1+1,sizeof(*coins));
if ( (coins[1]= iguana_setcoin(symbol,coins,0,0,0,0,0,0,0,0,json)) != 0 )
if ( (coins[1]= iguana_setcoin(symbol,coins,0,0,0,0,0,0,0,0,json,0)) != 0 )
{
_iguana_calcrmd160(coins[1],&V);
coins[0] = (void *)((long)1);
@ -1029,7 +1029,7 @@ void iguana_coins(void *arg)
continue;
}
iguana_coinargs(symbol,&maxrecvcache,&minconfirms,&maxpeers,&initialheight,&services,&maxrequests,&maxbundles,item);
coins[1 + i] = coin = iguana_setcoin(symbol,coins,maxpeers,maxrecvcache,services,initialheight,maphash,minconfirms,maxrequests,maxbundles,item);
coins[1 + i] = coin = iguana_setcoin(symbol,coins,maxpeers,maxrecvcache,services,initialheight,maphash,minconfirms,maxrequests,maxbundles,item,0);
if ( coin == 0 )
{
printf("iguana_coins: couldnt initialize.(%s)\n",symbol);

4
iguana/iguana_json.c

@ -623,7 +623,7 @@ STRING_ARG(iguana,addcoin,newcoin)
// if ( strcmp(symbol,"BTC") == 0 )
// return(clonestr("{\"result\":\"BTC for chrome app is not yet\"}"));
#endif
if ( (retval= iguana_launchcoin(myinfo,symbol,json)) > 0 )
if ( (retval= iguana_launchcoin(myinfo,symbol,json,0)) > 0 )
{
if ( myinfo->rpcsymbol[0] == 0 )
safecopy(myinfo->rpcsymbol,symbol,sizeof(myinfo->rpcsymbol));
@ -876,7 +876,7 @@ STRING_ARG(SuperNET,bitcoinrpc,setcoin)
strcpy(myinfo->rpcsymbol,setcoin);
touppercase(myinfo->rpcsymbol);
printf("bitcoinrpc.%s\n",myinfo->rpcsymbol);
if ( iguana_launchcoin(myinfo,myinfo->rpcsymbol,json) < 0 )
if ( iguana_launchcoin(myinfo,myinfo->rpcsymbol,json,0) < 0 )
return(clonestr("{\"error\":\"error creating coin\"}"));
else
{

6
includes/iguana_funcs.h

@ -121,7 +121,7 @@ int32_t iguana_updatebundles(struct iguana_info *coin);
void iguana_bundlestats(struct iguana_info *coin,char *str,int32_t lag);
void iguana_chaininit(struct iguana_chain *chain,int32_t hasheaders,cJSON *argjson);
void iguana_coinargs(char *symbol,int64_t *maxrecvcachep,int32_t *minconfirmsp,int32_t *maxpeersp,int32_t *initialheightp,uint64_t *servicesp,int32_t *maxrequestsp,int32_t *maxbundlesp,cJSON *json);
struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,int64_t maxrecvcache,uint64_t services,int32_t initialheight,int32_t maphash,int32_t minconfirms,int32_t maxrequests,int32_t maxbundles,cJSON *json);
struct iguana_info *iguana_setcoin(char *symbol,void *launched,int32_t maxpeers,int64_t maxrecvcache,uint64_t services,int32_t initialheight,int32_t maphash,int32_t minconfirms,int32_t maxrequests,int32_t maxbundles,cJSON *json,int32_t virtcoin);
// init
struct iguana_info *iguana_coinstart(struct iguana_info *coin,int32_t initialheight,int32_t mapflags);
@ -245,7 +245,7 @@ char *busdata_sync(uint32_t *noncep,char *jsonstr,char *broadcastmode,char *dest
void peggy();
int32_t opreturns_init(uint32_t blocknum,uint32_t blocktimestamp,char *path);
struct iguana_info *iguana_coinfind(char *symbol);
struct iguana_info *iguana_coinadd(char *symbol,char *nane,cJSON *json);
struct iguana_info *iguana_coinadd(char *symbol,char *nane,cJSON *json,int32_t virtcoin);
struct iguana_ramchain *iguana_bundleload(struct iguana_info *coin,struct iguana_ramchain *ramchain,struct iguana_bundle *bp,int32_t extraflag);
int32_t iguana_sendblockreq(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundle *bp,int32_t bundlei,bits256 hash2,int32_t iamthreadsafe);
int32_t iguana_send_supernet(struct iguana_peer *addr,char *jsonstr,int32_t delay);
@ -259,7 +259,7 @@ char *iguana_coinjson(struct iguana_info *coin,char *method,cJSON *json);
cJSON *iguana_peersjson(struct iguana_info *coin,int32_t addronly);
//int32_t btc_priv2wif(char *wifstr,uint8_t privkey[32],uint8_t addrtype);
//int32_t btc_pub2rmd(uint8_t rmd160[20],uint8_t pubkey[33]);
int32_t iguana_launchcoin(struct supernet_info *myinfo,char *symbol,cJSON *json);
int32_t iguana_launchcoin(struct supernet_info *myinfo,char *symbol,cJSON *json,int32_t virtcoin);
int32_t iguana_bundleinitmap(struct iguana_info *coin,struct iguana_bundle *bp,int32_t height,bits256 hash2,bits256 hash1);
int32_t iguana_jsonQ();
int32_t is_bitcoinrpc(struct supernet_info *myinfo,char *method,char *remoteaddr);

Loading…
Cancel
Save