jl777 8 years ago
parent
commit
5baf57b7d0
  1. 2
      basilisk/basilisk_MSG.c
  2. 59
      iguana/iguana_notary.c

2
basilisk/basilisk_MSG.c

@ -323,7 +323,7 @@ int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 srchash,bits25
jaddnum(valsobj,"duration",duration); jaddnum(valsobj,"duration",duration);
jaddbits256(valsobj,"srchash",srchash); jaddbits256(valsobj,"srchash",srchash);
jaddbits256(valsobj,"desthash",desthash); jaddbits256(valsobj,"desthash",desthash);
char str[65]; printf("sendmessage.[%d] channel.%u msgid.%x -> %s numrelays.%d\n",datalen,channel,msgid,bits256_str(str,desthash),myinfo->NOTARY.NUMRELAYS); //char str[65]; printf("sendmessage.[%d] channel.%u msgid.%x -> %s numrelays.%d\n",datalen,channel,msgid,bits256_str(str,desthash),myinfo->NOTARY.NUMRELAYS);
if ( (retstr= basilisk_sendmessage(myinfo,0,0,0,desthash,valsobj,hexstr)) != 0 ) if ( (retstr= basilisk_sendmessage(myinfo,0,0,0,desthash,valsobj,hexstr)) != 0 )
free(retstr); free(retstr);
free_json(valsobj); free_json(valsobj);

59
iguana/iguana_notary.c

@ -599,16 +599,32 @@ uint32_t dpow_send(struct supernet_info *myinfo,struct dpow_block *bp,bits256 sr
//return(basilisk_crcsend(myinfo,1,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));
} }
void dpow_sigsend(struct supernet_info *myinfo,struct dpow_block *bp,int32_t myind,int8_t bestk,uint64_t bestmask,bits256 srchash,uint32_t sigchannel)
{
struct dpow_sigentry dsig; int32_t i,len; uint8_t data[4096]; struct dpow_entry *ep;
ep = &bp->notaries[myind];
memset(&dsig,0,sizeof(dsig));
for (i=0; i<33; i++)
dsig.senderpub[i] = myinfo->DPOW.minerkey33[i];
dsig.lastk = bestk;
dsig.mask = bestmask;
dsig.senderind = myind;
dsig.beacon = bp->beacon;
dsig.siglen = ep->siglens[bestk];
memcpy(dsig.sig,ep->sigs[bestk],ep->siglens[bestk]);
memcpy(dsig.senderpub,myinfo->DPOW.minerkey33,33);
len = dpow_rwsigentry(1,data,&dsig);
dpow_send(myinfo,bp,srchash,bp->hashmsg,sigchannel,bp->height,data,len,bp->sigcrcs);
}
int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct iguana_info *coin,struct dpow_block *bp,int8_t bestk,uint64_t bestmask,int32_t myind,char *opret_symbol,uint32_t sigchannel) int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct iguana_info *coin,struct dpow_block *bp,int8_t bestk,uint64_t bestmask,int32_t myind,char *opret_symbol,uint32_t sigchannel)
{ {
int32_t i,j,m=0,incr,len,retval=-1; char rawtx[16384],*jsonstr,*signedtx,*rawtx2,*sigstr; cJSON *txobj,*signobj,*sobj,*txobj2,*vins,*item,*vin; uint8_t data[4096]; bits256 txid,srchash,zero; struct dpow_entry *ep; struct dpow_sigentry dsig; int32_t j,m=0,incr,retval=-1; char rawtx[16384],*jsonstr,*signedtx,*rawtx2,*sigstr; cJSON *txobj,*signobj,*sobj,*txobj2,*vins,*item,*vin; bits256 txid,srchash,zero; struct dpow_entry *ep;
if ( bp->numnotaries < 8 ) if ( bp->numnotaries < 8 )
incr = 1; incr = 1;
else incr = sqrt(bp->numnotaries) + 1; else incr = sqrt(bp->numnotaries) + 1;
ep = &bp->notaries[myind]; ep = &bp->notaries[myind];
memset(&zero,0,sizeof(zero)); memset(&zero,0,sizeof(zero));
for (i=0; i<33; i++)
dsig.senderpub[i] = myinfo->DPOW.minerkey33[i];
if ( bestk < 0 ) if ( bestk < 0 )
return(-1); return(-1);
for (j=0; j<sizeof(srchash); j++) for (j=0; j<sizeof(srchash); j++)
@ -640,17 +656,7 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct iguana_info *coin,s
ep->masks[bestk] = bestmask; ep->masks[bestk] = bestmask;
ep->siglens[bestk] = ep->siglens[bestk]; ep->siglens[bestk] = ep->siglens[bestk];
ep->beacon = bp->beacon; ep->beacon = bp->beacon;
memset(&dsig,0,sizeof(dsig)); dpow_sigsend(myinfo,bp,myind,bestk,bestmask,srchash,sigchannel);
dsig.lastk = bestk;
dsig.mask = bestmask;
dsig.senderind = myind;
dsig.beacon = bp->beacon;
dsig.siglen = ep->siglens[bestk];
memcpy(dsig.sig,ep->sigs[bestk],ep->siglens[bestk]);
memcpy(dsig.senderpub,myinfo->DPOW.minerkey33,33);
len = dpow_rwsigentry(1,data,&dsig);
printf("ht.%d sendsig bestk.%d %llx\n",bp->height,bestk,(long long)bestmask);
dpow_send(myinfo,bp,srchash,bp->hashmsg,sigchannel,bp->height,data,len,bp->sigcrcs);
retval = 0; retval = 0;
break; break;
} // else printf("notmine.(%s)\n",jprint(item,0)); } // else printf("notmine.(%s)\n",jprint(item,0));
@ -847,19 +853,18 @@ int32_t dpow_update(struct supernet_info *myinfo,struct dpow_block *bp,uint32_t
bp->bestk = dpow_bestk(bp,&bp->bestmask); bp->bestk = dpow_bestk(bp,&bp->bestmask);
if ( bp->bestk >= 0 ) if ( bp->bestk >= 0 )
{ {
if ( ep->masks[bp->bestk] == 0 && dpow_signedtxgen(myinfo,bp->coin,bp,bp->bestk,bp->bestmask,myind,bp->opret_symbol,sigchannel) == 0 ) if ( ep->masks[bp->bestk] == 0 )
bp->state = 3; dpow_signedtxgen(myinfo,bp->coin,bp,bp->bestk,bp->bestmask,myind,bp->opret_symbol,sigchannel);
else bp->state = 2; else dpow_sigsend(myinfo,bp,myind,bp->bestk,bp->bestmask,srchash,sigchannel);
} else bp->state = 1;
if ( bp->state == 3 ) }
{
dpow_channelget(myinfo,bp,txidchannel); dpow_channelget(myinfo,bp,txidchannel);
if ( bp->state != 0xffffffff ) if ( bp->state != 0xffffffff )
{ {
dpow_channelget(myinfo,bp,sigchannel); dpow_channelget(myinfo,bp,sigchannel);
if ( ep->masks[bp->bestk] == 0 ) if ( ep->masks[bp->bestk] == 0 )
dpow_signedtxgen(myinfo,bp->coin,bp,bp->bestk,bp->bestmask,myind,bp->opret_symbol,sigchannel); dpow_signedtxgen(myinfo,bp->coin,bp,bp->bestk,bp->bestmask,myind,bp->opret_symbol,sigchannel);
} else dpow_sigsend(myinfo,bp,myind,bp->bestk,bp->bestmask,srchash,sigchannel);
} }
return(bp->state); return(bp->state);
} }
@ -940,20 +945,12 @@ uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info
bp->recvmask |= (1LL << myind); bp->recvmask |= (1LL << myind);
bp->notaries[myind].prev_hash = txid; bp->notaries[myind].prev_hash = txid;
bp->notaries[myind].prev_vout = vout; bp->notaries[myind].prev_vout = vout;
dpow_update(myinfo,bp,channel,sigchannel,txidchannel,srchash,myind); bp->state = 2;
} }
break; break;
case 2: default:
dpow_update(myinfo,bp,channel,sigchannel,txidchannel,srchash,myind); dpow_update(myinfo,bp,channel,sigchannel,txidchannel,srchash,myind);
break; break;
case 3:
dpow_update(myinfo,bp,channel,sigchannel,txidchannel,srchash,myind);
if ( bp->state != 0xffffffff && bp->waiting++ > 10 )
{
bp->state = 2;
bp->waiting = 0;
}
break;
} }
if ( bits256_nonz(bp->signedtxid) != 0 ) if ( bits256_nonz(bp->signedtxid) != 0 )
bp->state = 0xffffffff; bp->state = 0xffffffff;

Loading…
Cancel
Save