jl777 8 years ago
parent
commit
fb0c5c4ba5
  1. 44
      basilisk/basilisk.c
  2. 6
      basilisk/basilisk_DEX.c
  3. 121
      basilisk/basilisk_MSG.c
  4. 87
      basilisk/basilisk_swap.c
  5. 4
      iguana/dPoW.h
  6. 42
      iguana/iguana_notary.c
  7. 1
      iguana/notaries.h
  8. 2
      includes/iguana_funcs.h

44
basilisk/basilisk.c

@ -17,50 +17,6 @@
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);
uint32_t basilisk_majority32(int32_t *datalenp,uint32_t rawcrcs[64],int32_t datalens[64],int32_t numcrcs)
{
int32_t tally[64],candlens[64],i,j,mintally,numcandidates = 0; uint32_t candidates[64];
*datalenp = 0;
mintally = (numcrcs >> 1) + 1;
memset(tally,0,sizeof(tally));
memset(candlens,0,sizeof(candlens));
memset(candidates,0,sizeof(candidates));
if ( numcrcs > 0 )
{
for (i=0; i<numcrcs; i++)
{
//printf("%08x ",rawcrcs[i]);
for (j=0; j<numcandidates; j++)
{
if ( rawcrcs[i] == candidates[j] && datalens[i] == candlens[j] )
{
tally[j]++;
break;
}
}
if ( j == numcandidates )
{
tally[numcandidates] = 1;
candlens[numcandidates] = datalens[i];
candidates[numcandidates] = rawcrcs[i];
numcandidates++;
}
}
//printf("n.%d -> numcandidates.%d\n",i,numcandidates);
if ( numcandidates > 0 )
{
for (j=0; j<numcandidates; j++)
if ( tally[j] >= mintally )
{
*datalenp = candlens[j];
//printf("tally[%d] %d >= mintally.%d numcrcs.%d crc %08x datalen.%d\n",j,tally[j],mintally,numcrcs,candidates[j],*datalenp);
return(candidates[j]);
}
}
}
return(0);
}
int32_t basilisk_notarycmd(char *cmd)
{
//&& strcmp(cmd,"DEX") != 0 && strcmp(cmd,"ACC") != 0 && strcmp(cmd,"RID") != 0 &&

6
basilisk/basilisk_DEX.c

@ -282,7 +282,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
free(retstr);
basilisk_channelsend(myinfo,issueR.srchash,issueR.desthash,channel,0x4000000,(void *)&issueR.requestid,sizeof(issueR.requestid),60);
numiters = 0;
while ( numiters < 10 && (crc= basilisk_swapcrcsend(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,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");
sleep(3);
@ -305,7 +305,7 @@ void basilisk_requests_poll(struct supernet_info *myinfo)
crcs[0] = crcs[1] = 0;
numiters = 0;
basilisk_channelsend(myinfo,issueR.desthash,issueR.srchash,channel,msgid,data,datalen,INSTANTDEX_LOCKTIME*2);
while ( numiters < 10 && (crc= basilisk_swapcrcsend(myinfo,buf,sizeof(buf),issueR.desthash,issueR.srchash,channel,msgid,data,datalen,crcs)) == 0 )
while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,buf,sizeof(buf),issueR.desthash,issueR.srchash,channel,msgid,data,datalen,crcs)) == 0 )
{
//printf("didnt get back what was sent\n");
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);
basilisk_channelsend(myinfo,myinfo->myaddr.persistent,hash,DEX_channel,msgid,serialized,datalen,60);
sleep(3);
while ( numiters < 10 && (crc= basilisk_swapcrcsend(myinfo,buf,sizeof(buf),hash,myinfo->myaddr.persistent,DEX_channel,msgid,serialized,datalen,crcs)) == 0 )
while ( numiters < 10 && (crc= basilisk_crcsend(myinfo,buf,sizeof(buf),hash,myinfo->myaddr.persistent,DEX_channel,msgid,serialized,datalen,crcs)) == 0 )
{
//printf("didnt get back what was sent\n");
sleep(3);

121
basilisk/basilisk_MSG.c

@ -422,3 +422,124 @@ int32_t basilisk_process_retarray(struct supernet_info *myinfo,void *ptr,int32_t
return(-errs);
else return(havedata);
}
uint32_t basilisk_majority32(int32_t *datalenp,uint32_t rawcrcs[64],int32_t datalens[64],int32_t numcrcs)
{
int32_t tally[64],candlens[64],i,j,mintally,numcandidates = 0; uint32_t candidates[64];
*datalenp = 0;
mintally = (numcrcs >> 1) + 1;
memset(tally,0,sizeof(tally));
memset(candlens,0,sizeof(candlens));
memset(candidates,0,sizeof(candidates));
if ( numcrcs > 0 )
{
for (i=0; i<numcrcs; i++)
{
//printf("%08x ",rawcrcs[i]);
for (j=0; j<numcandidates; j++)
{
if ( rawcrcs[i] == candidates[j] && datalens[i] == candlens[j] )
{
tally[j]++;
break;
}
}
if ( j == numcandidates )
{
tally[numcandidates] = 1;
candlens[numcandidates] = datalens[i];
candidates[numcandidates] = rawcrcs[i];
numcandidates++;
}
}
//printf("n.%d -> numcandidates.%d\n",i,numcandidates);
if ( numcandidates > 0 )
{
for (j=0; j<numcandidates; j++)
if ( tally[j] >= mintally )
{
*datalenp = candlens[j];
//printf("tally[%d] %d >= mintally.%d numcrcs.%d crc %08x datalen.%d\n",j,tally[j],mintally,numcrcs,candidates[j],*datalenp);
return(candidates[j]);
}
}
}
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)
{
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;
memset(rawcrcs,0,sizeof(rawcrcs));
memset(datalens,0,sizeof(datalens));
if ( (retarray= basilisk_channelget(myinfo,srchash,desthash,channel,msgbits,0)) != 0 )
{
//printf("retarray.(%s)\n",jprint(retarray,0));
if ( (n= cJSON_GetArraySize(retarray)) > 0 )
{
for (i=0; i<n; i++)
{
obj = jitem(retarray,i);
if ( jobj(obj,"error") != 0 )
continue;
if ( (msgarray= jarray(&m,obj,"messages")) != 0 )
{
for (j=0; j<m; j++)
{
item = jitem(msgarray,j);
keystr = hexstr = 0;
datalen = 0;
if ( (keystr= jstr(item,"key")) != 0 && is_hexstr(keystr,0) == BASILISK_KEYSIZE*2 && (hexstr= jstr(item,"data")) != 0 && (datalen= is_hexstr(hexstr,0)) > 0 )
{
decode_hex(key,BASILISK_KEYSIZE,keystr);
datalen >>= 1;
if ( datalen < maxlen )
{
decode_hex(verifybuf,datalen,hexstr);
if ( (retstr= basilisk_respond_addmessage(myinfo,key,BASILISK_KEYSIZE,verifybuf,datalen,juint(item,"expiration"),juint(item,"duration"))) != 0 )
{
if ( numcrcs < sizeof(rawcrcs)/sizeof(*rawcrcs) )
{
rawcrcs[numcrcs] = calc_crc32(0,verifybuf,datalen);
datalens[numcrcs] = datalen;
numcrcs++;
}
free(retstr);
}
} else printf("datalen.%d >= maxlen.%d\n",datalen,maxlen);
} else printf("not keystr.%p or no data.%p or bad datalen.%d\n",keystr,hexstr,datalen);
}
}
//printf("(%s).%d ",jprint(item,0),i);
}
//printf("n.%d maxlen.%d\n",n,maxlen);
}
free_json(retarray);
if ( (crc= basilisk_majority32(datalenp,rawcrcs,datalens,numcrcs)) != 0 )
{
//printf("have majority crc.%08x\n",crc);
}
//else printf("no majority from rawcrcs.%d\n",numcrcs);
}
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 crc; int32_t recvlen;
if ( crcs != 0 )
{
crc = calc_crc32(0,data,datalen);
if ( crcs[0] != crc )
crcs[0] = crc, crcs[1] = 0;
else
{
if ( crcs[1] == 0 )
crcs[1] = basilisk_crcrecv(myinfo,verifybuf,maxlen,&recvlen,srchash,desthash,channel,msgbits);
if ( crcs[0] == crcs[1] && datalen == recvlen )
return(crcs[0]);
}
}
return(0);
}

87
basilisk/basilisk_swap.c

@ -837,64 +837,6 @@ int32_t basilisk_verify_privi(struct supernet_info *myinfo,void *ptr,uint8_t *da
return(-1);
}
uint32_t basilisk_swaprecv(struct supernet_info *myinfo,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];
*datalenp = 0;
memset(rawcrcs,0,sizeof(rawcrcs));
memset(datalens,0,sizeof(datalens));
if ( (retarray= basilisk_channelget(myinfo,srchash,desthash,channel,msgbits,0)) != 0 )
{
//printf("retarray.(%s)\n",jprint(retarray,0));
if ( (n= cJSON_GetArraySize(retarray)) > 0 )
{
for (i=0; i<n; i++)
{
obj = jitem(retarray,i);
if ( jobj(obj,"error") != 0 )
continue;
if ( (msgarray= jarray(&m,obj,"messages")) != 0 )
{
for (j=0; j<m; j++)
{
item = jitem(msgarray,j);
keystr = hexstr = 0;
datalen = 0;
if ( (keystr= jstr(item,"key")) != 0 && is_hexstr(keystr,0) == BASILISK_KEYSIZE*2 && (hexstr= jstr(item,"data")) != 0 && (datalen= is_hexstr(hexstr,0)) > 0 )
{
decode_hex(key,BASILISK_KEYSIZE,keystr);
datalen >>= 1;
if ( datalen < maxlen )
{
decode_hex(verifybuf,datalen,hexstr);
if ( (retstr= basilisk_respond_addmessage(myinfo,key,BASILISK_KEYSIZE,verifybuf,datalen,juint(item,"expiration"),juint(item,"duration"))) != 0 )
{
if ( numcrcs < sizeof(rawcrcs)/sizeof(*rawcrcs) )
{
rawcrcs[numcrcs] = calc_crc32(0,verifybuf,datalen);
datalens[numcrcs] = datalen;
numcrcs++;
}
free(retstr);
}
} else printf("datalen.%d >= maxlen.%d\n",datalen,maxlen);
} else printf("not keystr.%p or no data.%p or bad datalen.%d\n",keystr,hexstr,datalen);
}
}
//printf("(%s).%d ",jprint(item,0),i);
}
//printf("n.%d maxlen.%d\n",n,maxlen);
}
free_json(retarray);
if ( (crc= basilisk_majority32(datalenp,rawcrcs,datalens,numcrcs)) != 0 )
{
//printf("have majority crc.%08x\n",crc);
}
//else printf("no majority from rawcrcs.%d\n",numcrcs);
}
return(crc);
}
int32_t basilisk_process_swapverify(struct supernet_info *myinfo,void *ptr,int32_t (*internal_func)(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen),uint32_t channel,uint32_t msgid,uint8_t *data,int32_t datalen,uint32_t expiration,uint32_t duration)
{
struct basilisk_swap *swap = ptr;
@ -906,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 datalen; uint32_t crc;
if ( (crc= basilisk_swaprecv(myinfo,swap->verifybuf,sizeof(swap->verifybuf),&datalen,swap->I.otherhash,swap->I.myhash,swap->I.req.quoteid,msgbits)) != 0 )
if ( (crc= basilisk_crcrecv(myinfo,swap->verifybuf,sizeof(swap->verifybuf),&datalen,swap->I.otherhash,swap->I.myhash,swap->I.req.quoteid,msgbits)) != 0 )
{
if ( datalen > 0 && datalen < maxlen )
{
@ -917,32 +859,13 @@ int32_t basilisk_swapget(struct supernet_info *myinfo,struct basilisk_swap *swap
return(-1);
}
uint32_t basilisk_swapcrcsend(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 crc; int32_t recvlen;
if ( crcs != 0 )
{
crc = calc_crc32(0,data,datalen);
if ( crcs[0] != crc )
crcs[0] = crc, crcs[1] = 0;
else
{
if ( crcs[1] == 0 )
crcs[1] = basilisk_swaprecv(myinfo,verifybuf,maxlen,&recvlen,srchash,desthash,channel,msgbits);
if ( crcs[0] == crcs[1] && datalen == recvlen )
return(crcs[0]);
}
}
return(0);
}
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_swapcrcsend(myinfo,swap->verifybuf,sizeof(swap->verifybuf),swap->I.myhash,swap->I.otherhash,swap->I.req.quoteid,msgbits,data,datalen,crcs) != 0 )
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_crcsend(myinfo,swap->verifybuf,sizeof(swap->verifybuf),swap->I.myhash,swap->I.otherhash,swap->I.req.quoteid,msgbits,data,datalen,crcs) != 0 )
return(nextbits);
printf("ERROR basilisk_channelsend\n");
//if ( basilisk_channelsend(myinfo,swap->I.myhash,swap->I.otherhash,swap->I.req.quoteid,msgbits,data,datalen,INSTANTDEX_LOCKTIME*2) == 0 )
// return(nextbits);
//printf("ERROR basilisk_channelsend\n");
return(0);
}

4
iguana/dPoW.h

@ -59,9 +59,9 @@ struct dpow_block
struct iguana_info *coin; char *opret_symbol;
uint64_t recvmask,recvsigmask;
struct dpow_entry notaries[DPOW_MAXRELAYS];
uint32_t state,timestamp,waiting;
uint32_t state,timestamp,waiting,sigcrcs[2],txidcrcs[2],utxocrcs[2];
int32_t height,numnotaries,completed;
char signedtx[32768];
char signedtx[32768]; uint8_t sendbuf[32768],recvbuf[32768];
};
struct dpow_info

42
iguana/iguana_notary.c

@ -577,6 +577,11 @@ int32_t dpow_haveutxo(struct supernet_info *myinfo,struct iguana_info *coin,bits
return(haveutxo);
}
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));
}
cJSON *dpow_createtx(struct iguana_info *coin,cJSON **vinsp,struct dpow_block *bp,int32_t lastk,uint64_t mask,int32_t usesigs)
{
int32_t i,j,m=0,siglen; char scriptstr[256]; cJSON *txobj=0,*vins=0,*item; uint64_t satoshis; uint8_t script[35],*sig;
@ -630,7 +635,7 @@ cJSON *dpow_createtx(struct iguana_info *coin,cJSON **vinsp,struct dpow_block *b
int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct iguana_info *coin,struct dpow_block *bp,uint64_t mask,int32_t lastk,int32_t myind,char *opret_symbol)
{
int32_t i,j,z,m=0,datalen,incr,retval=-1; char rawtx[16384],*jsonstr,*signedtx,*rawtx2,*sigstr; cJSON *txobj,*signobj,*sobj,*txobj2,*vins,*item,*vin; uint8_t data[sizeof(struct dpow_sigentry)]; bits256 txid,srchash,desthash,zero; uint32_t channel; struct dpow_entry *ep; struct dpow_sigentry dsig;
int32_t i,j,m=0,datalen,incr,retval=-1; char rawtx[16384],*jsonstr,*signedtx,*rawtx2,*sigstr; cJSON *txobj,*signobj,*sobj,*txobj2,*vins,*item,*vin; uint8_t data[sizeof(struct dpow_sigentry)]; bits256 txid,srchash,zero; uint32_t channel; struct dpow_entry *ep; struct dpow_sigentry dsig;
mask = dpow_maskmin(mask,bp,&lastk);
if ( bp->numnotaries < 8 )
incr = 1;
@ -680,7 +685,7 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct iguana_info *coin,s
ep->beacon = dsig.beacon;
bp->recvsigmask |= (1LL << dsig.senderind);
//printf(">>>>>>>> datalen.%d siglen.%d myind.%d lastk.%d mask.%llx\n",datalen,dsig.siglen,dsig.senderind,dsig.lastk,(long long)dsig.mask);
for (i=0; i<=bp->numnotaries; i++)
/*for (i=0; i<=bp->numnotaries; i++)
//for (i=((myind + (uint32_t)rand()) % incr); i<bp->numnotaries; i+=incr)
{
if ( 0 && i != myind )
@ -693,7 +698,9 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct iguana_info *coin,s
desthash.bytes[z] = bp->notaries[i].pubkey[z+1];
}
basilisk_channelsend(myinfo,srchash,desthash,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);
retval = 0;
break;
} // else printf("notmine.(%s)\n",jprint(item,0));
@ -717,7 +724,7 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct iguana_info *coin,s
void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_block *bp,uint32_t channel,int32_t myind)
{
bits256 txid,srchash,desthash,zero; int32_t i,j,len; char *retstr=0,str[65],str2[65]; uint8_t txdata[16384]; struct dpow_sigentry dsig;
bits256 txid,srchash,zero; int32_t j,len; char *retstr=0,str[65],str2[65]; uint8_t txdata[16384]; struct dpow_sigentry dsig;
memset(zero.bytes,0,sizeof(zero));
if ( bp->state != 0xffffffff && bp->coin != 0 && dpow_numsigs(bp,dsig.lastk,bp->recvsigmask) == DPOW_M(bp) )
{
@ -736,7 +743,7 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_block *bp,uint32_t
decode_hex(txdata+32,len,bp->signedtx);
for (j=0; j<sizeof(srchash); j++)
txdata[j] = txid.bytes[j];
for (i=0; i<=bp->numnotaries; i++)
/*for (i=0; i<=bp->numnotaries; i++)
{
if ( i == bp->numnotaries )
desthash = zero;
@ -746,7 +753,9 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_block *bp,uint32_t
desthash.bytes[j] = bp->notaries[i].pubkey[j+1];
}
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);
dpow_send(myinfo,bp,txid,zero,(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);
bp->state = 0xffffffff;
} else printf("sendtxid mismatch got %s instead of %s\n",bits256_str(str,txid),bits256_str(str2,bp->signedtxid));
@ -874,7 +883,7 @@ void dpow_handler(struct supernet_info *myinfo,struct basilisk_message *msg)
uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info *dp,struct iguana_info *coin,struct dpow_block *bp,int32_t myind)
{
// todo: add RBF support
bits256 txid; int32_t vout,i,len,j,k,incr,haveutxo = 0; cJSON *addresses; char *sendtx,*rawtx,*opret_symbol,coinaddr[64]; uint8_t data[4096]; uint32_t channel; bits256 srchash,desthash,zero; uint64_t mask;
bits256 txid; int32_t vout,len,j,k,incr,haveutxo = 0; cJSON *addresses; char *sendtx,*rawtx,*opret_symbol,coinaddr[64]; uint8_t data[4096]; uint32_t channel; bits256 srchash,zero; uint64_t mask;
if ( bp->numnotaries > 8 )
incr = sqrt(bp->numnotaries) + 1;
else incr = 1;
@ -926,7 +935,7 @@ uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info
len = dpow_rwutxobuf(1,data,&bp->hashmsg,&txid,&vout,&bp->commit,myinfo->DPOW.minerkey33);
bp->recvmask |= (1LL << myind);
//for (i=((myind + (uint32_t)rand()) % incr); i<bp->numnotaries; i+=incr)
for (i=0; i<=bp->numnotaries; i++)
/*for (i=0; i<=bp->numnotaries; i++)
{
if ( i == bp->numnotaries )
desthash = zero;
@ -936,24 +945,13 @@ uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info
desthash.bytes[j] = bp->notaries[i].pubkey[j+1];
}
basilisk_channelsend(myinfo,srchash,desthash,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);
bp->state = 2;
}
break;
case 2:
len = dpow_rwutxobuf(1,data,&bp->hashmsg,&bp->notaries[myind].prev_hash,&bp->notaries[myind].prev_vout,&bp->commit,myinfo->DPOW.minerkey33);
for (i=0; i<=bp->numnotaries; i++)
//for (i=((myind + (uint32_t)rand()) % incr); i<bp->numnotaries; i+=incr)
{
if ( i == bp->numnotaries )
desthash = zero;
else
{
for (j=0; j<sizeof(srchash); j++)
desthash.bytes[j] = bp->notaries[i].pubkey[j+1];
}
basilisk_channelsend(myinfo,srchash,desthash,channel,bp->height,data,len,120);
}
bp->recvmask = dpow_lastk_mask(bp,&k);
//printf("STATE2: RECVMASK.%llx\n",(long long)bp->recvmask);
if ( bitweight(bp->recvmask) >= DPOW_M(bp) )

1
iguana/notaries.h

@ -43,6 +43,7 @@ char *Notaries[][2] =
{ "badass_SH", "0287fed7cd90994281f308ad112230d970c04148d7017e828fee47bfaf11c50679" },
{ "baddass_NA" "02afa1a9f948e1634a29dc718d218e9d150c531cfa852843a1643a02184a63c1a7" },
{ "pondsea_NA", "031bcfdbb62268e2ff8dfffeb9ddff7fe95fca46778c77eebff9c3829dfa1bb411" },
{ "rnr_EU", "0287aa4b73988ba26cf6565d815786caf0d2c4af704d7883d163ee89cd9977edec" },
/*{ "Server1","0221876c8259764224dc1a7b70ec956f3fbe9a768cd77f13082cfa60eb6aa2d068"},
{ "Server2","03c7c14e6b1f94585bb571cf3ee5eb9b9ab54bd23d0acb8cf13edad1c515842b66"},
{ "Server3","02d28f8992ff0cd68c5d558cf55ec5b3ada25151519a6cea8cef1bac04c40023b6"},

2
includes/iguana_funcs.h

@ -490,7 +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);
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);
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);
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]);
struct exchange_info *exchange_create(char *exchangestr,cJSON *argjson);
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);

Loading…
Cancel
Save