jl777 8 years ago
parent
commit
3355cca676
  1. 6
      basilisk/basilisk_DEX.c
  2. 20
      basilisk/basilisk_MSG.c
  3. 4
      basilisk/basilisk_swap.c
  4. 1
      iguana/dPoW.h
  5. 10
      iguana/iguana_notary.c
  6. 4
      includes/iguana_funcs.h

6
basilisk/basilisk_DEX.c

@ -282,7 +282,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
free(retstr); free(retstr);
basilisk_channelsend(myinfo,issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),60); basilisk_channelsend(myinfo,issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),60);
numiters = 0; numiters = 0;
while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,buf,sizeof(buf),issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),crcs)) == 0 ) while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,0,buf,sizeof(buf),issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),crcs)) == 0 )
{ {
printf("didnt get back what was sent\n"); printf("didnt get back what was sent\n");
sleep(3); sleep(3);
@ -305,7 +305,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
crcs[0] = crcs[1] = 0; crcs[0] = crcs[1] = 0;
numiters = 0; numiters = 0;
basilisk_channelsend(myinfo,issueR.desthash,issueR.srchash,channel,msgid,data,datalen,INSTANTDEX_LOCKTIME*2); basilisk_channelsend(myinfo,issueR.desthash,issueR.srchash,channel,msgid,data,datalen,INSTANTDEX_LOCKTIME*2);
while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,buf,sizeof(buf),issueR.desthash,issueR.srchash,channel,msgid,data,datalen,crcs)) == 0 ) while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,0,buf,sizeof(buf),issueR.desthash,issueR.srchash,channel,msgid,data,datalen,crcs)) == 0 )
{ {
//printf("didnt get back what was sent\n"); //printf("didnt get back what was sent\n");
sleep(3); sleep(3);
@ -577,7 +577,7 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr)
DEX_channel = 'D' + ((uint32_t)'E' << 8) + ((uint32_t)'X' << 16); DEX_channel = 'D' + ((uint32_t)'E' << 8) + ((uint32_t)'X' << 16);
basilisk_channelsend(myinfo,myinfo->myaddr.persistent,hash,DEX_channel,msgid,serialized,datalen,60); basilisk_channelsend(myinfo,myinfo->myaddr.persistent,hash,DEX_channel,msgid,serialized,datalen,60);
sleep(3); sleep(3);
while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,buf,sizeof(buf),hash,myinfo->myaddr.persistent,DEX_channel,msgid,serialized,datalen,crcs)) == 0 ) while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,0,buf,sizeof(buf),hash,myinfo->myaddr.persistent,DEX_channel,msgid,serialized,datalen,crcs)) == 0 )
{ {
//printf("didnt get back what was sent\n"); //printf("didnt get back what was sent\n");
sleep(3); sleep(3);

20
basilisk/basilisk_MSG.c

@ -216,9 +216,9 @@ char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int3
msg->expiration = (uint32_t)time(NULL) + duration; msg->expiration = (uint32_t)time(NULL) + duration;
HASH_ADD_KEYPTR(hh,myinfo->messagetable,msg->key,msg->keylen,msg); HASH_ADD_KEYPTR(hh,myinfo->messagetable,msg->key,msg->keylen,msg);
QUEUEITEMS++; QUEUEITEMS++;
//int32_t i; for (i=0; i<BASILISK_KEYSIZE; i++) int32_t i; for (i=0; i<BASILISK_KEYSIZE; i++)
// printf("%02x",key[i]); printf("%02x",key[i]);
//printf(" <- ADDMSG.[%d] exp %u %p (%p %p)\n",QUEUEITEMS,msg->expiration,msg,msg->hh.next,msg->hh.prev); printf(" <- ADDMSG.[%d] exp %u %p (%p %p)\n",QUEUEITEMS,msg->expiration,msg,msg->hh.next,msg->hh.prev);
portable_mutex_unlock(&myinfo->messagemutex); portable_mutex_unlock(&myinfo->messagemutex);
if ( myinfo->NOTARY.RELAYID >= 0 ) if ( myinfo->NOTARY.RELAYID >= 0 )
dpow_handler(myinfo,msg); dpow_handler(myinfo,msg);
@ -435,7 +435,7 @@ uint32_t basilisk_majority32(int32_t *datalenp,uint32_t rawcrcs[64],int32_t data
{ {
for (i=0; i<numcrcs; i++) for (i=0; i<numcrcs; i++)
{ {
//printf("%08x ",rawcrcs[i]); printf("%08x ",rawcrcs[i]);
for (j=0; j<numcandidates; j++) for (j=0; j<numcandidates; j++)
{ {
if ( rawcrcs[i] == candidates[j] && datalens[i] == candlens[j] ) if ( rawcrcs[i] == candidates[j] && datalens[i] == candlens[j] )
@ -452,7 +452,7 @@ uint32_t basilisk_majority32(int32_t *datalenp,uint32_t rawcrcs[64],int32_t data
numcandidates++; numcandidates++;
} }
} }
//printf("n.%d -> numcandidates.%d\n",i,numcandidates); printf("n.%d -> numcandidates.%d\n",i,numcandidates);
if ( numcandidates > 0 ) if ( numcandidates > 0 )
{ {
for (j=0; j<numcandidates; j++) for (j=0; j<numcandidates; j++)
@ -467,13 +467,13 @@ uint32_t basilisk_majority32(int32_t *datalenp,uint32_t rawcrcs[64],int32_t data
return(0); return(0);
} }
uint32_t basilisk_crcrecv(struct supernet_info *myinfo,uint8_t *verifybuf,int32_t maxlen,int32_t *datalenp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits) uint32_t basilisk_crcrecv(struct supernet_info *myinfo,int32_t width,uint8_t *verifybuf,int32_t maxlen,int32_t *datalenp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits)
{ {
cJSON *retarray,*obj,*item,*msgarray; char *hexstr,*keystr,*retstr; uint32_t rawcrcs[64],crc=0; int32_t numcrcs=0,i,j,m,n,datalen,datalens[64];; uint8_t key[BASILISK_KEYSIZE]; cJSON *retarray,*obj,*item,*msgarray; char *hexstr,*keystr,*retstr; uint32_t rawcrcs[64],crc=0; int32_t numcrcs=0,i,j,m,n,datalen,datalens[64]; uint8_t key[BASILISK_KEYSIZE];
*datalenp = 0; *datalenp = 0;
memset(rawcrcs,0,sizeof(rawcrcs)); memset(rawcrcs,0,sizeof(rawcrcs));
memset(datalens,0,sizeof(datalens)); memset(datalens,0,sizeof(datalens));
if ( (retarray= basilisk_channelget(myinfo,srchash,desthash,channel,msgbits,0)) != 0 ) if ( (retarray= basilisk_channelget(myinfo,srchash,desthash,channel,msgbits,width)) != 0 )
{ {
//printf("retarray.(%s)\n",jprint(retarray,0)); //printf("retarray.(%s)\n",jprint(retarray,0));
if ( (n= cJSON_GetArraySize(retarray)) > 0 ) if ( (n= cJSON_GetArraySize(retarray)) > 0 )
@ -525,7 +525,7 @@ uint32_t basilisk_crcrecv(struct supernet_info *myinfo,uint8_t *verifybuf,int32_
return(crc); return(crc);
} }
uint32_t basilisk_crcsend(struct supernet_info *myinfo,uint8_t *verifybuf,int32_t maxlen,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2]) uint32_t basilisk_crcsend(struct supernet_info *myinfo,int32_t width,uint8_t *verifybuf,int32_t maxlen,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2])
{ {
uint32_t crc; int32_t recvlen; uint32_t crc; int32_t recvlen;
if ( crcs != 0 ) if ( crcs != 0 )
@ -536,7 +536,7 @@ uint32_t basilisk_crcsend(struct supernet_info *myinfo,uint8_t *verifybuf,int32_
else else
{ {
if ( crcs[1] == 0 ) if ( crcs[1] == 0 )
crcs[1] = basilisk_crcrecv(myinfo,verifybuf,maxlen,&recvlen,srchash,desthash,channel,msgbits); crcs[1] = basilisk_crcrecv(myinfo,width,verifybuf,maxlen,&recvlen,srchash,desthash,channel,msgbits);
if ( crcs[0] == crcs[1] && datalen == recvlen ) if ( crcs[0] == crcs[1] && datalen == recvlen )
return(crcs[0]); return(crcs[0]);
} }

4
basilisk/basilisk_swap.c

@ -848,7 +848,7 @@ int32_t basilisk_process_swapverify(struct supernet_info *myinfo,void *ptr,int32
int32_t basilisk_swapget(struct supernet_info *myinfo,struct basilisk_swap *swap,uint32_t msgbits,uint8_t *data,int32_t maxlen,int32_t (*basilisk_verify_func)(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen)) int32_t basilisk_swapget(struct supernet_info *myinfo,struct basilisk_swap *swap,uint32_t msgbits,uint8_t *data,int32_t maxlen,int32_t (*basilisk_verify_func)(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen))
{ {
int32_t datalen; uint32_t crc; int32_t datalen; uint32_t crc;
if ( (crc= basilisk_crcrecv(myinfo,swap->verifybuf,sizeof(swap->verifybuf),&datalen,swap->I.otherhash,swap->I.myhash,swap->I.req.quoteid,msgbits)) != 0 ) if ( (crc= basilisk_crcrecv(myinfo,0,swap->verifybuf,sizeof(swap->verifybuf),&datalen,swap->I.otherhash,swap->I.myhash,swap->I.req.quoteid,msgbits)) != 0 )
{ {
if ( datalen > 0 && datalen < maxlen ) if ( datalen > 0 && datalen < maxlen )
{ {
@ -861,7 +861,7 @@ int32_t basilisk_swapget(struct supernet_info *myinfo,struct basilisk_swap *swap
uint32_t basilisk_swapsend(struct supernet_info *myinfo,struct basilisk_swap *swap,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t nextbits,uint32_t crcs[2]) uint32_t basilisk_swapsend(struct supernet_info *myinfo,struct basilisk_swap *swap,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t nextbits,uint32_t crcs[2])
{ {
if ( basilisk_crcsend(myinfo,swap->verifybuf,sizeof(swap->verifybuf),swap->I.myhash,swap->I.otherhash,swap->I.req.quoteid,msgbits,data,datalen,crcs) != 0 ) if ( basilisk_crcsend(myinfo,0,swap->verifybuf,sizeof(swap->verifybuf),swap->I.myhash,swap->I.otherhash,swap->I.req.quoteid,msgbits,data,datalen,crcs) != 0 )
return(nextbits); return(nextbits);
//if ( basilisk_channelsend(myinfo,swap->I.myhash,swap->I.otherhash,swap->I.req.quoteid,msgbits,data,datalen,INSTANTDEX_LOCKTIME*2) == 0 ) //if ( basilisk_channelsend(myinfo,swap->I.myhash,swap->I.otherhash,swap->I.req.quoteid,msgbits,data,datalen,INSTANTDEX_LOCKTIME*2) == 0 )
// return(nextbits); // return(nextbits);

1
iguana/dPoW.h

@ -26,6 +26,7 @@
#define DPOW_KOMODOCONFIRMS 1 #define DPOW_KOMODOCONFIRMS 1
#define DPOW_BTCCONFIRMS 1 #define DPOW_BTCCONFIRMS 1
#define DPOW_MAXRELAYS 64 #define DPOW_MAXRELAYS 64
#define DPOW_CHECKPOINTFREQ 5
struct dpow_entry struct dpow_entry
{ {

10
iguana/iguana_notary.c

@ -579,7 +579,7 @@ int32_t dpow_haveutxo(struct supernet_info *myinfo,struct iguana_info *coin,bits
uint32_t dpow_send(struct supernet_info *myinfo,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2]) uint32_t dpow_send(struct supernet_info *myinfo,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2])
{ {
return(basilisk_crcsend(myinfo,bp->sendbuf,sizeof(bp->sendbuf),srchash,desthash,channel,msgbits,data,datalen,crcs)); return(basilisk_crcsend(myinfo,1,bp->sendbuf,sizeof(bp->sendbuf),srchash,desthash,channel,msgbits,data,datalen,crcs));
} }
cJSON *dpow_createtx(struct iguana_info *coin,cJSON **vinsp,struct dpow_block *bp,int32_t lastk,uint64_t mask,int32_t usesigs) cJSON *dpow_createtx(struct iguana_info *coin,cJSON **vinsp,struct dpow_block *bp,int32_t lastk,uint64_t mask,int32_t usesigs)
@ -700,7 +700,7 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct iguana_info *coin,s
basilisk_channelsend(myinfo,srchash,desthash,channel,bp->height,data,datalen,120); basilisk_channelsend(myinfo,srchash,desthash,channel,bp->height,data,datalen,120);
}*/ }*/
//basilisk_channelsend(myinfo,srchash,zero,channel,bp->height,data,datalen,120); //basilisk_channelsend(myinfo,srchash,zero,channel,bp->height,data,datalen,120);
dpow_send(myinfo,bp,srchash,zero,channel,bp->height,data,datalen,bp->sigcrcs); dpow_send(myinfo,bp,srchash,bp->hashmsg,channel,bp->height,data,datalen,bp->sigcrcs);
retval = 0; retval = 0;
break; break;
} // else printf("notmine.(%s)\n",jprint(item,0)); } // else printf("notmine.(%s)\n",jprint(item,0));
@ -755,7 +755,7 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_block *bp,uint32_t
basilisk_channelsend(myinfo,txid,desthash,(channel == DPOW_SIGBTCCHANNEL) ? DPOW_BTCTXIDCHANNEL : DPOW_TXIDCHANNEL,bp->height,txdata,len+32,120); basilisk_channelsend(myinfo,txid,desthash,(channel == DPOW_SIGBTCCHANNEL) ? DPOW_BTCTXIDCHANNEL : DPOW_TXIDCHANNEL,bp->height,txdata,len+32,120);
}*/ }*/
//basilisk_channelsend(myinfo,txid,zero,(channel == DPOW_SIGBTCCHANNEL) ? DPOW_BTCTXIDCHANNEL : DPOW_TXIDCHANNEL,bp->height,txdata,len+32,120); //basilisk_channelsend(myinfo,txid,zero,(channel == DPOW_SIGBTCCHANNEL) ? DPOW_BTCTXIDCHANNEL : DPOW_TXIDCHANNEL,bp->height,txdata,len+32,120);
dpow_send(myinfo,bp,txid,zero,(channel == DPOW_SIGBTCCHANNEL) ? DPOW_BTCTXIDCHANNEL : DPOW_TXIDCHANNEL,bp->height,txdata,len+32,bp->txidcrcs); dpow_send(myinfo,bp,txid,bp->hashmsg,(channel == DPOW_SIGBTCCHANNEL) ? DPOW_BTCTXIDCHANNEL : DPOW_TXIDCHANNEL,bp->height,txdata,len+32,bp->txidcrcs);
printf("complete statemachine.%s ht.%d\n",bp->coin->symbol,bp->height); printf("complete statemachine.%s ht.%d\n",bp->coin->symbol,bp->height);
bp->state = 0xffffffff; bp->state = 0xffffffff;
} else printf("sendtxid mismatch got %s instead of %s\n",bits256_str(str,txid),bits256_str(str2,bp->signedtxid)); } else printf("sendtxid mismatch got %s instead of %s\n",bits256_str(str,txid),bits256_str(str2,bp->signedtxid));
@ -947,7 +947,7 @@ uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info
basilisk_channelsend(myinfo,srchash,desthash,channel,bp->height,data,len,120); basilisk_channelsend(myinfo,srchash,desthash,channel,bp->height,data,len,120);
}*/ }*/
//basilisk_channelsend(myinfo,srchash,zero,channel,bp->height,data,len,120); //basilisk_channelsend(myinfo,srchash,zero,channel,bp->height,data,len,120);
dpow_send(myinfo,bp,srchash,zero,channel,bp->height,data,len,bp->utxocrcs); dpow_send(myinfo,bp,srchash,bp->hashmsg,channel,bp->height,data,len,bp->utxocrcs);
bp->state = 2; bp->state = 2;
} }
break; break;
@ -1112,7 +1112,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he
checkpoint = dp->srcfifo[dp->srcconfirms]; checkpoint = dp->srcfifo[dp->srcconfirms];
printf("%s srcupdate ht.%d destupdated.%u nonz.%d %s\n",dp->symbol,height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash)); printf("%s srcupdate ht.%d destupdated.%u nonz.%d %s\n",dp->symbol,height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash));
dpow_fifoupdate(myinfo,dp->srcfifo,dp->last); dpow_fifoupdate(myinfo,dp->srcfifo,dp->last);
if ( dp->destupdated != 0 && bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % 10) == 0 ) if ( dp->destupdated != 0 && bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % DPOW_CHECKPOINTFREQ) == 0 )
{ {
ptrs = calloc(1,sizeof(void *)*2 + sizeof(struct dpow_checkpoint)); ptrs = calloc(1,sizeof(void *)*2 + sizeof(struct dpow_checkpoint));
ptrs[0] = (void *)myinfo; ptrs[0] = (void *)myinfo;

4
includes/iguana_funcs.h

@ -490,9 +490,9 @@ char *iguana_signunspents(struct supernet_info *myinfo,struct iguana_info *coin,
bits256 iguana_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx); bits256 iguana_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx);
int32_t iguana_inv2packet(uint8_t *serialized,int32_t maxsize,int32_t type,bits256 *hashes,int32_t n); int32_t iguana_inv2packet(uint8_t *serialized,int32_t maxsize,int32_t type,bits256 *hashes,int32_t n);
int32_t instantdex_inv2data(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,struct exchange_info *exchange); int32_t instantdex_inv2data(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,struct exchange_info *exchange);
uint32_t basilisk_crcrecv(struct supernet_info *myinfo,uint8_t *verifybuf,int32_t maxlen,int32_t *datalenp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits); uint32_t basilisk_crcrecv(struct supernet_info *myinfo,int32_t width,uint8_t *verifybuf,int32_t maxlen,int32_t *datalenp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits);
struct iguana_bundlereq *instantdex_recvquotes(struct iguana_info *coin,struct iguana_bundlereq *req,bits256 *encodedhash,int32_t n); struct iguana_bundlereq *instantdex_recvquotes(struct iguana_info *coin,struct iguana_bundlereq *req,bits256 *encodedhash,int32_t n);
uint32_t basilisk_crcsend(struct supernet_info *myinfo,uint8_t *verifybuf,int32_t maxlen,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2]); uint32_t basilisk_crcsend(struct supernet_info *myinfo,int32_t width,uint8_t *verifybuf,int32_t maxlen,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2]);
struct exchange_info *exchange_create(char *exchangestr,cJSON *argjson); struct exchange_info *exchange_create(char *exchangestr,cJSON *argjson);
int32_t iguana_inv2poll(struct supernet_info *myinfo,struct iguana_info *coin); int32_t iguana_inv2poll(struct supernet_info *myinfo,struct iguana_info *coin);
struct iguana_bundlereq *iguana_bundlereq(struct iguana_info *coin,struct iguana_peer *addr,int32_t type,uint8_t *data,int32_t datalen); struct iguana_bundlereq *iguana_bundlereq(struct iguana_info *coin,struct iguana_peer *addr,int32_t type,uint8_t *data,int32_t datalen);

Loading…
Cancel
Save