Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
1b4d08fe6d
  1. 1160
      basilisk/basilisk copy.c
  2. 136
      basilisk/basilisk.c
  3. 42
      datachain/datachain.c
  4. 13
      datachain/datachain.h
  5. 6
      gecko/gecko.c
  6. 4
      gecko/gecko.h
  7. 4
      gecko/gecko_delayedPoW.c
  8. 12
      gecko/gecko_miner.c
  9. 5
      iguana/iguana777.c
  10. 1
      includes/iguana_funcs.h
  11. 12
      includes/iguana_structs.h

1160
basilisk/basilisk copy.c

File diff suppressed because it is too large

136
basilisk/basilisk.c

@ -15,7 +15,7 @@
#include "../iguana/iguana777.h" #include "../iguana/iguana777.h"
typedef char *basilisk_coinfunc(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen); //typedef char *basilisk_coinfunc(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen);
typedef char *basilisk_servicefunc(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk); typedef char *basilisk_servicefunc(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk);
typedef struct basilisk_item *basilisk_requestfunc(struct basilisk_item *Lptr,struct supernet_info *myinfo,bits256 hash,cJSON *valsobj,uint8_t *data,int32_t datalen); typedef struct basilisk_item *basilisk_requestfunc(struct basilisk_item *Lptr,struct supernet_info *myinfo,bits256 hash,cJSON *valsobj,uint8_t *data,int32_t datalen);
@ -561,19 +561,35 @@ char *basilisk_standardcmd(struct supernet_info *myinfo,char *CMD,char *activeco
} else return(retstr); } else return(retstr);
} }
char *_basilisk_value(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen) char *_basilisk_value(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk)
{ {
return(basilisk_standardcmd(myinfo,"VAL",coin->symbol,remoteaddr,basilisktag,valsobj,coin->basilisk_value,coin->basilisk_valuemetric)); struct iguana_info *coin; char *symbol;
if ( (symbol= jstr(valsobj,"coin")) != 0 || (symbol= jstr(valsobj,"symbol")) != 0 )
{
if ( (coin= iguana_coinfind(symbol)) != 0 )
return(basilisk_standardcmd(myinfo,"VAL",symbol,remoteaddr,basilisktag,valsobj,coin->basilisk_value,coin->basilisk_valuemetric));
}
return(clonestr("{\"error\":\"couldnt get coin\"}"));
} }
char *_basilisk_balances(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen) char *_basilisk_balances(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk)
{ {
return(basilisk_standardcmd(myinfo,"BAL",coin->symbol,remoteaddr,basilisktag,valsobj,coin->basilisk_balances,coin->basilisk_balancesmetric)); struct iguana_info *coin; char *symbol;
if ( (symbol= jstr(valsobj,"coin")) != 0 || (symbol= jstr(valsobj,"symbol")) != 0 )
{
if ( (coin= iguana_coinfind(symbol)) != 0 )
return(basilisk_standardcmd(myinfo,"BAL",symbol,remoteaddr,basilisktag,valsobj,coin->basilisk_balances,coin->basilisk_balancesmetric));
}
return(clonestr("{\"error\":\"couldnt get coin\"}"));
} }
char *_basilisk_rawtx(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen) char *_basilisk_rawtx(struct supernet_info *myinfo,char *CMD,void *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen,bits256 hash,int32_t from_basilisk)
{
char *retstr,strbuf[4096],*symbol,*str = 0; struct iguana_info *coin;
if ( (symbol= jstr(valsobj,"coin")) != 0 || (symbol= jstr(valsobj,"symbol")) != 0 )
{
if ( (coin= iguana_coinfind(symbol)) != 0 )
{ {
char *retstr,strbuf[4096],*str = 0;
printf("remote rawtx.(%s)\n",jprint(valsobj,0)); printf("remote rawtx.(%s)\n",jprint(valsobj,0));
basilisk_addhexstr(&str,valsobj,strbuf,sizeof(strbuf),data,datalen); basilisk_addhexstr(&str,valsobj,strbuf,sizeof(strbuf),data,datalen);
retstr = basilisk_rawtx(myinfo,coin,0,remoteaddr,basilisktag,valsobj,coin->symbol); retstr = basilisk_rawtx(myinfo,coin,0,remoteaddr,basilisktag,valsobj,coin->symbol);
@ -581,6 +597,9 @@ char *_basilisk_rawtx(struct supernet_info *myinfo,struct iguana_info *coin,stru
free(str); free(str);
return(retstr); return(retstr);
} }
}
return(clonestr("{\"error\":\"couldnt get coin\"}"));
}
char *_basilisk_result(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen) char *_basilisk_result(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,char *remoteaddr,uint32_t basilisktag,cJSON *valsobj,uint8_t *data,int32_t datalen)
{ {
@ -789,7 +808,7 @@ void basilisk_geckoresult(struct supernet_info *myinfo,struct basilisk_item *ptr
void basilisk_pending_result(struct supernet_info *myinfo,struct basilisk_item *ptr,struct basilisk_item *pending) void basilisk_pending_result(struct supernet_info *myinfo,struct basilisk_item *ptr,struct basilisk_item *pending)
{ {
int32_t n; struct basilisk_item *parent; basilisk_metricfunc metricfunc; cJSON *retjson; int32_t n; struct basilisk_item *parent; basilisk_metricfunc metricfunc;
if ( (n= pending->numresults) < sizeof(pending->results)/sizeof(*pending->results) ) if ( (n= pending->numresults) < sizeof(pending->results)/sizeof(*pending->results) )
{ {
pending->numresults++; pending->numresults++;
@ -798,8 +817,8 @@ void basilisk_pending_result(struct supernet_info *myinfo,struct basilisk_item *
else if ( (pending->metrics[n]= (*metricfunc)(myinfo,pending,ptr->retstr)) != 0. ) else if ( (pending->metrics[n]= (*metricfunc)(myinfo,pending,ptr->retstr)) != 0. )
pending->childrendone++; pending->childrendone++;
printf("%s.%u Add results[%d] <- metric %f\n",pending->CMD,pending->basilisktag,n,pending->metrics[n]); printf("%s.%u Add results[%d] <- metric %f\n",pending->CMD,pending->basilisktag,n,pending->metrics[n]);
pending->results[n] = ptr->retstr; pending->results[n] = ptr->retstr, ptr->retstr = 0;
if ( strcmp(ptr->CMD,"SEQ") == 0 ) /*if ( strcmp(ptr->CMD,"SEQ") == 0 )
{ {
if ( (retjson= cJSON_Parse(ptr->retstr)) != 0 ) if ( (retjson= cJSON_Parse(ptr->retstr)) != 0 )
{ {
@ -807,7 +826,8 @@ void basilisk_pending_result(struct supernet_info *myinfo,struct basilisk_item *
free_json(retjson); free_json(retjson);
} }
} }
else if ( strcmp(ptr->CMD,"RET") == 0 || strcmp(ptr->CMD,"GET") == 0 ) else*/
if ( strcmp(ptr->CMD,"RET") == 0 || strcmp(ptr->CMD,"GET") == 0 )
{ {
printf("got return for tag.%d parent.%p\n",pending->basilisktag,pending->parent); printf("got return for tag.%d parent.%p\n",pending->basilisktag,pending->parent);
if ( (parent= pending->parent) != 0 ) if ( (parent= pending->parent) != 0 )
@ -929,17 +949,11 @@ void basilisks_loop(void *arg)
void basilisks_init(struct supernet_info *myinfo) void basilisks_init(struct supernet_info *myinfo)
{ {
//bits256 basiliskhash;
iguana_initQ(&myinfo->basilisks.submitQ,"submitQ"); iguana_initQ(&myinfo->basilisks.submitQ,"submitQ");
iguana_initQ(&myinfo->basilisks.resultsQ,"resultsQ"); iguana_initQ(&myinfo->basilisks.resultsQ,"resultsQ");
portable_mutex_init(&myinfo->allcoins_mutex); portable_mutex_init(&myinfo->allcoins_mutex);
portable_mutex_init(&myinfo->basilisk_mutex); portable_mutex_init(&myinfo->basilisk_mutex);
portable_mutex_init(&myinfo->gecko_mutex); portable_mutex_init(&myinfo->gecko_mutex);
//basiliskhash = calc_categoryhashes(0,"basilisk",0);
//myinfo->basilisk_category = basiliskhash;
//category_subscribe(myinfo,basiliskhash,GENESIS_PUBKEY);
//category_processfunc(basiliskhash,GENESIS_PUBKEY,basilisk_hexmsg);
//category_processfunc(basiliskhash,myinfo->myaddr.persistent,basilisk_hexmsg);
myinfo->basilisks.launched = iguana_launch(iguana_coinfind("BTCD"),"basilisks_loop",basilisks_loop,myinfo,IGUANA_PERMTHREAD); myinfo->basilisks.launched = iguana_launch(iguana_coinfind("BTCD"),"basilisks_loop",basilisks_loop,myinfo,IGUANA_PERMTHREAD);
} }
@ -973,7 +987,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
{ (void *)"BLK", &basilisk_respond_geckoblock }, // reports block { (void *)"BLK", &basilisk_respond_geckoblock }, // reports block
{ (void *)"MEM", &basilisk_respond_mempool }, // reports mempool { (void *)"MEM", &basilisk_respond_mempool }, // reports mempool
{ (void *)"GTX", &basilisk_respond_geckotx }, // reports tx { (void *)"GTX", &basilisk_respond_geckotx }, // reports tx
{ (void *)"SEQ", &basilisk_respond_hashstamps }, // BTCD and BTC recent hashes from timestamp //{ (void *)"SEQ", &basilisk_respond_hashstamps }, // BTCD and BTC recent hashes from timestamp
// unencrypted low level functions, used by higher level protocols and virtual network funcs // unencrypted low level functions, used by higher level protocols and virtual network funcs
{ (void *)"ADD", &basilisk_respond_addrelay }, // relays register with each other bus { (void *)"ADD", &basilisk_respond_addrelay }, // relays register with each other bus
@ -991,12 +1005,10 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
{ (void *)"SAY", &basilisk_respond_VPNbroadcast }, // broadcast { (void *)"SAY", &basilisk_respond_VPNbroadcast }, // broadcast
{ (void *)"EAR", &basilisk_respond_VPNreceive }, // network receive (via poll) { (void *)"EAR", &basilisk_respond_VPNreceive }, // network receive (via poll)
{ (void *)"END", &basilisk_respond_VPNlogout }, // logout { (void *)"END", &basilisk_respond_VPNlogout }, // logout
};
static basilisk_coinfunc *basilisk_coinservices[][2] = // coin services
{
{ (void *)"RAW", &_basilisk_rawtx }, { (void *)"RAW", &_basilisk_rawtx },
{ (void *)"VAL", &_basilisk_value }, { (void *)"VAL", &_basilisk_value },
{ (void *)"BAL", &_basilisk_balances },
}; };
symbol = "BTCD"; symbol = "BTCD";
if ( (valsobj= cJSON_Parse((char *)data)) != 0 ) if ( (valsobj= cJSON_Parse((char *)data)) != 0 )
@ -1029,17 +1041,8 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
flag = 1; flag = 1;
break; break;
} }
if ( flag == 0 )
{
for (i=0; i<sizeof(basilisk_coinservices)/sizeof(*basilisk_coinservices); i++) // iguana node
if ( strcmp((char *)basilisk_coinservices[i][0],type) == 0 )
{
flag = 1;
break;
}
if ( flag == 0 ) if ( flag == 0 )
return; return;
}
strncpy(CMD,type,3), CMD[3] = cmd[3] = 0; strncpy(CMD,type,3), CMD[3] = cmd[3] = 0;
if ( isupper((int32_t)CMD[0]) != 0 && isupper((int32_t)CMD[1]) != 0 && isupper((int32_t)CMD[2]) != 0 ) if ( isupper((int32_t)CMD[0]) != 0 && isupper((int32_t)CMD[1]) != 0 && isupper((int32_t)CMD[2]) != 0 )
from_basilisk = 1; from_basilisk = 1;
@ -1057,15 +1060,8 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
{ {
jsonlen = (int32_t)strlen((char *)data) + 1; jsonlen = (int32_t)strlen((char *)data) + 1;
if ( datalen > jsonlen ) if ( datalen > jsonlen )
{
data += jsonlen, datalen -= jsonlen; data += jsonlen, datalen -= jsonlen;
if ( 0 && strcmp("BLK",CMD) == 0 ) else data = 0, datalen = 0;
{
for (i=0; i<datalen; i++)
printf("%02x",data[i]);
printf(" <-> got datalen.%d\n",datalen);
}
} else data = 0, datalen = 0;
if ( coin == 0 ) if ( coin == 0 )
coin = iguana_coinfind("BTCD"); coin = iguana_coinfind("BTCD");
if ( coin != 0 ) if ( coin != 0 )
@ -1080,79 +1076,23 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
if ( senderipbits != 0 ) if ( senderipbits != 0 )
expand_ipbits(remoteaddr,senderipbits); expand_ipbits(remoteaddr,senderipbits);
else remoteaddr[0] = 0; else remoteaddr[0] = 0;
if ( valsobj != 0 && remoteaddr != 0 )
{
if ( strcmp(CMD,"RLY") == 0 )
{
printf("add relay path\n");
if ( juint(valsobj,"iamrelay") != 0 )
{
retstr = basilisk_respond_relays(myinfo,type,addr,remoteaddr,basilisktag,valsobj,data,datalen,hash,from_basilisk);
}
free_json(valsobj);
if ( coin != 0 )
coin->basilisk_busy = 0;
myinfo->basilisk_busy = 0;
return;
}
//else if ( (retstr= basilisk_addrelay_info(myinfo,0,(uint32_t)calc_ipbits(remoteaddr),GENESIS_PUBKEY)) != 0 )
// free(retstr);
}
for (i=0; i<sizeof(basilisk_services)/sizeof(*basilisk_services); i++) // iguana node for (i=0; i<sizeof(basilisk_services)/sizeof(*basilisk_services); i++) // iguana node
{ {
if ( strcmp((char *)basilisk_services[i][0],type) == 0 ) if ( strcmp((char *)basilisk_services[i][0],type) == 0 )
{ {
if ( myinfo->IAMRELAY != 0 ) // iguana node if ( coin->RELAYNODE != 0 ) // iguana node
{ {
/*if ( from_basilisk != 0 )
{
printf("echo to other relays\n");
basilisk_sendcmd(myinfo,0,cmd,&basilisktag,0,0,origdata,origlen,-1,0); // to other iguanas
}*/
if ( (retstr= (*basilisk_services[i][1])(myinfo,type,addr,remoteaddr,basilisktag,valsobj,data,datalen,hash,from_basilisk)) != 0 ) if ( (retstr= (*basilisk_services[i][1])(myinfo,type,addr,remoteaddr,basilisktag,valsobj,data,datalen,hash,from_basilisk)) != 0 )
{ {
printf("from_basilisk.%d ret.(%s)\n",from_basilisk,retstr); //printf("from_basilisk.%d ret.(%s)\n",from_basilisk,retstr);
if ( from_basilisk != 0 ) if ( from_basilisk != 0 || strcmp(CMD,"GET") == 0 )
basilisk_sendback(myinfo,CMD,symbol,remoteaddr,basilisktag,retstr); basilisk_sendback(myinfo,CMD,symbol,remoteaddr,basilisktag,retstr);
if ( retstr != 0 ) if ( retstr != 0 )
free(retstr); free(retstr);
} //else printf("services null return\n"); } //else printf("services null return\n");
} else printf("non-relay got unexpected.(%s)\n",type); } else printf("non-relay got unexpected.(%s)\n",type);
free_json(valsobj);
if ( coin != 0 )
coin->basilisk_busy = 0;
myinfo->basilisk_busy = 0;
return;
}
}
if ( coin != 0 )
{
if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 ) // iguana node
{
if ( from_basilisk != 0 )
{
printf("echo to other relays\n");
basilisk_sendcmd(myinfo,0,cmd,&basilisktag,0,0,origdata,origlen,-1,0); // to other iguanas
} }
for (i=0; i<sizeof(basilisk_coinservices)/sizeof(*basilisk_coinservices); i++)
if ( strcmp((char *)basilisk_coinservices[i][0],type) == 0 )
{
retstr = (*basilisk_coinservices[i][1])(myinfo,coin,addr,remoteaddr,basilisktag,valsobj,data,datalen);
printf("from_basilisk.%d ret.(%s)\n",from_basilisk,retstr);
if ( from_basilisk != 0 )
basilisk_sendback(myinfo,CMD,symbol,remoteaddr,basilisktag,retstr);
break;
}
}
else // basilisk node
{
if ( strcmp(type,"ADD") == 0 )
{
printf("new relay ADD.(%s) datalen.%d\n",jprint(valsobj,0),datalen);
basilisk_respond_addrelay(myinfo,type,addr,remoteaddr,basilisktag,valsobj,data,datalen,hash,from_basilisk);
} else printf("basilisk node doenst handle.(%s)\n",type);
} }
} else printf("basilisk_msgprocess no coin\n");
} }
free_json(valsobj); free_json(valsobj);
if ( retstr != 0 ) if ( retstr != 0 )

42
datachain/datachain.c

@ -15,29 +15,53 @@
#include "../iguana/iguana777.h" #include "../iguana/iguana777.h"
int32_t datachain_events_rewind(struct supernet_info *myinfo,struct datachain_event *events,int32_t numevents,int32_t height,uint32_t hdrsi,uint32_t unspentind)
{
return(numevents);
}
void datachain_BTC_clock(struct supernet_info *myinfo,struct iguana_info *btc,int32_t height,uint32_t hdrsi,uint32_t unspentind) void datachain_BTC_clock(struct supernet_info *myinfo,struct iguana_info *btc,int32_t height,uint32_t hdrsi,uint32_t unspentind)
{ {
if ( hdrsi < myinfo->dPOW.lastbtc_hdrsi || (hdrsi == myinfo->dPOW.lastbtc_hdrsi && unspentind < myinfo->dPOW.lastbtc_unspentind) ) if ( hdrsi < myinfo->dPOW.BTC.lasthdrsi || (hdrsi == myinfo->dPOW.BTC.lasthdrsi && unspentind < myinfo->dPOW.BTC.lastunspentind) )
{
myinfo->dPOW.BTC.numevents = datachain_events_rewind(myinfo,myinfo->dPOW.BTC.events,myinfo->dPOW.BTC.numevents,height,hdrsi,unspentind);
}
else
{ {
// rewind BTC printf("NEWBLOCK.%s ht.%d\n",btc->symbol,height);
} }
myinfo->dPOW.lastbtc_hdrsi = hdrsi; myinfo->dPOW.BTC.lasthdrsi = hdrsi;
myinfo->dPOW.lastbtc_unspentind = unspentind; myinfo->dPOW.BTC.lastunspentind = unspentind;
} }
void datachain_BTCD_newblock(struct supernet_info *myinfo,struct iguana_info *btcd,int32_t height,uint32_t hdrsi,uint32_t unspentind) void datachain_BTCD_newblock(struct supernet_info *myinfo,struct iguana_info *btcd,int32_t height,uint32_t hdrsi,uint32_t unspentind)
{ {
if ( hdrsi < myinfo->dPOW.lastbtcd_hdrsi || (hdrsi == myinfo->dPOW.lastbtcd_hdrsi && unspentind < myinfo->dPOW.lastbtcd_unspentind) ) if ( hdrsi < myinfo->dPOW.BTCD.lasthdrsi || (hdrsi == myinfo->dPOW.BTCD.lasthdrsi && unspentind < myinfo->dPOW.BTCD.lastunspentind) )
{ {
// rewind BTCD datachain_events_rewind(myinfo,myinfo->dPOW.BTCD.events,myinfo->dPOW.BTCD.numevents,height,hdrsi,unspentind);
} }
myinfo->dPOW.lastbtcd_hdrsi = hdrsi; else
myinfo->dPOW.lastbtcd_unspentind = unspentind; {
// new BTCD block actions
printf("NEWBLOCK.%s ht.%d\n",btcd->symbol,height);
}
myinfo->dPOW.BTCD.lasthdrsi = hdrsi;
myinfo->dPOW.BTCD.lastunspentind = unspentind;
} }
void datachain_virt_newblock(struct supernet_info *myinfo,struct iguana_info *virt,int32_t height,uint32_t hdrsi,uint32_t unspentind) void datachain_virt_newblock(struct supernet_info *myinfo,struct iguana_info *virt,int32_t height,uint32_t hdrsi,uint32_t unspentind)
{ {
if ( hdrsi < virt->dPOW.lasthdrsi || (hdrsi == virt->dPOW.lasthdrsi && unspentind < virt->dPOW.lastunspentind) )
{
datachain_events_rewind(myinfo,virt->dPOW.events,virt->dPOW.numevents,height,hdrsi,unspentind);
}
else
{
// new virt block actions
printf("NEWBLOCK.%s ht.%d\n",virt->symbol,height);
}
virt->dPOW.lasthdrsi = hdrsi;
virt->dPOW.lastunspentind = unspentind;
} }
void datachain_opreturn(struct supernet_info *myinfo,struct iguana_info *coin,int32_t btc_or_btcd,int64_t crypto777_payment,int64_t burned,int32_t height,uint64_t hdrsi_unspentind,uint8_t *data,int32_t datalen) void datachain_opreturn(struct supernet_info *myinfo,struct iguana_info *coin,int32_t btc_or_btcd,int64_t crypto777_payment,int64_t burned,int32_t height,uint64_t hdrsi_unspentind,uint8_t *data,int32_t datalen)

13
datachain/datachain.h

@ -83,8 +83,21 @@ struct datachain_item
uint8_t itemdata[]; uint8_t itemdata[];
}; };
struct datachain_event
{
};
struct datachain_info struct datachain_info
{ {
uint32_t lasthdrsi,lastunspentind,numevents,maxevents;
struct datachain_event *events;
};
struct delayedPoW_info
{
//struct gecko_sequences SEQ;
struct datachain_info BTC,BTCD;
}; };

6
gecko/gecko.c

@ -44,7 +44,7 @@ void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struc
char mineraddr[64]; int32_t hwmhdrsi,longesthdrsi; char mineraddr[64]; int32_t hwmhdrsi,longesthdrsi;
hwmhdrsi = virt->blocks.hwmchain.height / virt->chain->bundlesize; hwmhdrsi = virt->blocks.hwmchain.height / virt->chain->bundlesize;
longesthdrsi = virt->longestchain / virt->chain->bundlesize; longesthdrsi = virt->longestchain / virt->chain->bundlesize;
if ( 0 && hwmhdrsi <= longesthdrsi && virt->blocks.hwmchain.height < virt->longestchain-1 ) if ( hwmhdrsi <= longesthdrsi && virt->blocks.hwmchain.height < virt->longestchain-1 )
{ {
if ( time(NULL) > virt->hdrstime+3 ) if ( time(NULL) > virt->hdrstime+3 )
{ {
@ -162,7 +162,7 @@ struct gecko_chain *gecko_chain(struct supernet_info *myinfo,char chainname[GECK
return(chain); return(chain);
} }
int32_t gecko_chainvals(struct supernet_info *myinfo,char *CMD,cJSON *valsobj) /*int32_t gecko_chainvals(struct supernet_info *myinfo,char *CMD,cJSON *valsobj)
{ {
struct iguana_info *virt; struct gecko_chain *chain; bits256 hash,prevhash; struct iguana_block *block; char chainname[GECKO_MAXNAMELEN]; struct iguana_info *virt; struct gecko_chain *chain; bits256 hash,prevhash; struct iguana_block *block; char chainname[GECKO_MAXNAMELEN];
if ( strcmp(CMD,"SET") == 0 || strcmp(CMD,"GET") == 0 ) if ( strcmp(CMD,"SET") == 0 || strcmp(CMD,"GET") == 0 )
@ -188,7 +188,7 @@ int32_t gecko_chainvals(struct supernet_info *myinfo,char *CMD,cJSON *valsobj)
return(0); return(0);
} }
return(-1); return(-1);
} }*/
cJSON *gecko_genesisargs(char *symbol,char *chainname,char *chain,char *keystr,char *genesishash,char *genesisblock,char *magicstr,uint16_t port,uint16_t blocktime,char *nbitstr,char *pubval,char *p2shval,char *wifval,uint32_t isPoS) cJSON *gecko_genesisargs(char *symbol,char *chainname,char *chain,char *keystr,char *genesishash,char *genesisblock,char *magicstr,uint16_t port,uint16_t blocktime,char *nbitstr,char *pubval,char *p2shval,char *wifval,uint32_t isPoS)
{ {

4
gecko/gecko.h

@ -33,9 +33,9 @@
struct iguana_peer; struct iguana_peer;
struct hashstamp { bits256 hash2; uint32_t timestamp; int32_t height; }; /*struct hashstamp { bits256 hash2; uint32_t timestamp; int32_t height; };
struct gecko_sequence { struct hashstamp *stamps; int32_t lastupdate,maxstamps,numstamps,lasti,longestchain; }; struct gecko_sequence { struct hashstamp *stamps; int32_t lastupdate,maxstamps,numstamps,lasti,longestchain; };
struct gecko_sequences { struct gecko_sequence BTC,BTCD; }; struct gecko_sequences { struct gecko_sequence BTC,BTCD; };*/
struct gecko_memtx struct gecko_memtx
{ {

4
gecko/gecko_delayedPoW.c

@ -15,7 +15,7 @@
// included from gecko.c // included from gecko.c
int32_t gecko_hashstampsfind(struct hashstamp *stamps,int32_t max,struct gecko_sequence *seq,bits256 hash,uint32_t reftimestamp) /*int32_t gecko_hashstampsfind(struct hashstamp *stamps,int32_t max,struct gecko_sequence *seq,bits256 hash,uint32_t reftimestamp)
{ {
int32_t j,i = 0,foundflag = -1,gap = -1; uint32_t timestamp; int32_t j,i = 0,foundflag = -1,gap = -1; uint32_t timestamp;
if ( seq->stamps == 0 ) if ( seq->stamps == 0 )
@ -230,7 +230,7 @@ char *basilisk_respond_hashstamps(struct supernet_info *myinfo,char *CMD,void *a
jadd(retjson,"BTC",gecko_sequencejson(btcd->chain->zcash,&myinfo->dPOW.SEQ.BTC,startheight,GECKO_FIRSTPOSSIBLEBTC)); jadd(retjson,"BTC",gecko_sequencejson(btcd->chain->zcash,&myinfo->dPOW.SEQ.BTC,startheight,GECKO_FIRSTPOSSIBLEBTC));
} }
return(jprint(retjson,1)); return(jprint(retjson,1));
} }*/
/* /*
done = 3; done = 3;

12
gecko/gecko_miner.c

@ -26,7 +26,7 @@ int32_t gecko_blocknonce_verify(struct iguana_info *virt,uint8_t *serialized,int
{ {
bits256 threshold,hash2; bits256 threshold,hash2;
//printf("time.%u prev.%u\n",timestamp,prevtimestamp); //printf("time.%u prev.%u\n",timestamp,prevtimestamp);
if ( 1 && timestamp != 0 && prevtimestamp != 0 ) if ( timestamp != 0 && prevtimestamp != 0 )
{ {
if ( prevtimestamp != 0 && timestamp < gecko_earliest_blocktime(virt->chain->estblocktime,prevtimestamp) ) if ( prevtimestamp != 0 && timestamp < gecko_earliest_blocktime(virt->chain->estblocktime,prevtimestamp) )
{ {
@ -96,18 +96,20 @@ uint32_t gecko_nBits(struct iguana_info *virt,uint32_t *prevtimestampp,struct ig
int32_t gecko_delayedPoW(struct supernet_info *myinfo,struct iguana_info *btcd,int32_t isPoS,uint8_t *coinbase,bits256 *btcdhashp,uint32_t timestamp,int32_t height) int32_t gecko_delayedPoW(struct supernet_info *myinfo,struct iguana_info *btcd,int32_t isPoS,uint8_t *coinbase,bits256 *btcdhashp,uint32_t timestamp,int32_t height)
{ {
bits256 btchash; int32_t len = 0; int32_t len = 0; //bits256 btchash;
*btcdhashp = GENESIS_PUBKEY;
len += iguana_rwnum(1,&coinbase[len],sizeof(height),(void *)&height); len += iguana_rwnum(1,&coinbase[len],sizeof(height),(void *)&height);
coinbase[len++] = 0;
if ( (isPoS & 7) != 0 ) if ( (isPoS & 7) != 0 )
{ {
*btcdhashp = gecko_hashstampscalc(myinfo,btcd,&btchash,timestamp); /* *btcdhashp = gecko_hashstampscalc(myinfo,btcd,&btchash,timestamp);
if ( (isPoS & 2) != 0 && (bits256_cmp(*btcdhashp,GENESIS_PUBKEY) == 0 || bits256_nonz(*btcdhashp) == 0) ) if ( (isPoS & 2) != 0 && (bits256_cmp(*btcdhashp,GENESIS_PUBKEY) == 0 || bits256_nonz(*btcdhashp) == 0) )
return(-1); return(-1);
if ( (isPoS & 4) != 0 && (bits256_cmp(btchash,GENESIS_PUBKEY) == 0 || bits256_nonz(btchash) == 0) ) if ( (isPoS & 4) != 0 && (bits256_cmp(btchash,GENESIS_PUBKEY) == 0 || bits256_nonz(btchash) == 0) )
return(-1); return(-1);
//len += iguana_rwbignum(1,&coinbase[len],sizeof(*btcdhashp),btcdhashp->bytes); //len += iguana_rwbignum(1,&coinbase[len],sizeof(*btcdhashp),btcdhashp->bytes);
len += iguana_rwbignum(1,&coinbase[len],sizeof(btchash),btchash.bytes); len += iguana_rwbignum(1,&coinbase[len],sizeof(btchash),btchash.bytes);*/
} else *btcdhashp = GENESIS_PUBKEY; }
return(len); return(len);
} }

5
iguana/iguana777.c

@ -952,6 +952,11 @@ int32_t iguana_launchcoin(struct supernet_info *myinfo,char *symbol,cJSON *json)
coin->launched = iguana_launch(coin,"iguana_coinloop",iguana_coinloop,coins,IGUANA_PERMTHREAD); coin->launched = iguana_launch(coin,"iguana_coinloop",iguana_coinloop,coins,IGUANA_PERMTHREAD);
coin->active = 1; coin->active = 1;
coin->started = 0; coin->started = 0;
if ( strcmp("BTCD",coin->symbol) == 0 )
{
basilisk_ensurerelay(coin,(uint32_t)calc_ipbits("78.47.196.146"));
basilisk_ensurerelay(coin,(uint32_t)calc_ipbits("5.9.102.210"));
}
return(1); return(1);
} }
else else

1
includes/iguana_funcs.h

@ -521,6 +521,7 @@ int32_t basilisk_relays_send(struct supernet_info *myinfo,struct iguana_peer *ad
int32_t basilisk_hashes_send(struct supernet_info *myinfo,struct iguana_info *virt,struct iguana_peer *addr,char *CMD,bits256 *txids,int32_t num); int32_t basilisk_hashes_send(struct supernet_info *myinfo,struct iguana_info *virt,struct iguana_peer *addr,char *CMD,bits256 *txids,int32_t num);
int32_t iguana_opreturn(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,int64_t crypto777_payment,int32_t height,uint64_t hdrsi_unspentind,int64_t payment,uint32_t fileid,uint64_t scriptpos,uint32_t scriptlen); int32_t iguana_opreturn(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,int64_t crypto777_payment,int32_t height,uint64_t hdrsi_unspentind,int64_t payment,uint32_t fileid,uint64_t scriptpos,uint32_t scriptlen);
int32_t iguana_scriptdata(struct iguana_info *coin,uint8_t *scriptspace,long fileptr[2],char *fname,uint64_t scriptpos,int32_t scriptlen); int32_t iguana_scriptdata(struct iguana_info *coin,uint8_t *scriptspace,long fileptr[2],char *fname,uint64_t scriptpos,int32_t scriptlen);
struct iguana_peer *basilisk_ensurerelay(struct iguana_info *btcd,uint32_t ipbits);
#include "../includes/iguana_api.h" #include "../includes/iguana_api.h"

12
includes/iguana_structs.h

@ -413,7 +413,7 @@ struct iguana_info
struct iguana_hhutxo *utxotable; struct iguana_hhaccount *accountstable; char lastdispstr[2048]; struct iguana_hhutxo *utxotable; struct iguana_hhaccount *accountstable; char lastdispstr[2048];
double txidfind_totalmillis,txidfind_num,spendtxid_totalmillis,spendtxid_num; double txidfind_totalmillis,txidfind_num,spendtxid_totalmillis,spendtxid_num;
struct iguana_monitorinfo monitoring[256]; struct iguana_monitorinfo monitoring[256];
uint32_t dPoW_lasthdrsi,dPoW_lastunspentind; struct datachain_info dPOW;
struct iguana_blocks blocks; void *mempool; void *mempools[IGUANA_MAXRELAYS]; struct iguana_blocks blocks; void *mempool; void *mempools[IGUANA_MAXRELAYS];
}; };
@ -450,12 +450,6 @@ struct supernet_address
char NXTADDR[32],BTC[64],BTCD[64]; char NXTADDR[32],BTC[64],BTCD[64];
}; };
struct delayedPoW_info
{
struct gecko_sequences SEQ;
uint32_t lastbtc_hdrsi,lastbtc_unspentind,lastbtcd_hdrsi,lastbtcd_unspentind;
};
struct supernet_info struct supernet_info
{ {
struct supernet_address myaddr; struct supernet_address myaddr;
@ -472,10 +466,10 @@ struct supernet_info
struct iguana_info *allcoins; int32_t allcoins_being_added,allcoins_numvirts; struct iguana_info *allcoins; int32_t allcoins_being_added,allcoins_numvirts;
portable_mutex_t allcoins_mutex,gecko_mutex,basilisk_mutex; portable_mutex_t allcoins_mutex,gecko_mutex,basilisk_mutex;
void *ctx; void *ctx;
// compatibility
bits256 pangea_category,instantdex_category;
struct delayedPoW_info dPOW; struct delayedPoW_info dPOW;
uint32_t relaybits[IGUANA_MAXRELAYS]; struct basilisk_relay relays[IGUANA_MAXRELAYS]; int32_t numrelays; uint32_t relaybits[IGUANA_MAXRELAYS]; struct basilisk_relay relays[IGUANA_MAXRELAYS]; int32_t numrelays;
// compatibility
bits256 pangea_category,instantdex_category;
}; };
#endif #endif

Loading…
Cancel
Save