jl777 8 years ago
parent
commit
9a400fca44
  1. 4
      iguana/dPoW.h
  2. 7
      iguana/dpow/dpow_fsm.c
  3. 95
      iguana/dpow/dpow_network.c
  4. 2
      iguana/iguana777.c
  5. 1
      iguana/iguana_bundles.c

4
iguana/dPoW.h

@ -97,11 +97,11 @@ struct dpow_block
bits256 hashmsg,desttxid,srctxid,beacon,commit;
struct iguana_info *srccoin,*destcoin; char *opret_symbol;
uint64_t destsigsmasks[DPOW_MAXRELAYS],srcsigsmasks[DPOW_MAXRELAYS];
uint64_t recvmask,bestmask,ratifybestmask,ratifyrecvmask,pendingbestmask,ratifysigmasks[2];
uint64_t recvmask,bestmask,ratifybestmask,ratifyrecvmask,pendingbestmask,pendingratifybestmask,ratifysigmasks[2];
struct dpow_entry notaries[DPOW_MAXRELAYS];
uint32_t state,timestamp,waiting,sigcrcs[2],txidcrcs[2],utxocrcs[2];
int32_t height,numnotaries,completed,minsigs,duration,numratified,isratify,require0,scores[DPOW_MAXRELAYS];
int8_t bestk,ratifybestk,pendingbestk;
int8_t bestk,ratifybestk,pendingbestk,pendingratifybestk;
cJSON *ratified;
uint8_t myind,ratified_pubkeys[DPOW_MAXRELAYS][33],ratifysigs[2][76],ratifysiglens[2];
char handles[DPOW_MAXRELAYS][32];

7
iguana/dpow/dpow_fsm.c

@ -116,7 +116,8 @@ void dpow_sync(struct supernet_info *myinfo,int32_t forceflag,struct dpow_info *
int32_t dpow_datahandler(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,uint8_t nn_senderind,uint32_t channel,uint32_t height,uint8_t *data,int32_t datalen)
{
bits256 txid,commit,srchash,hashmsg; uint32_t flag = 0; int32_t src_or_dest,senderind,i,iter,rlen,myind = -1; char str[65],str2[65]; struct dpow_sigentry dsig; struct dpow_entry *ep; struct dpow_coinentry *cp; struct dpow_utxoentry U; struct iguana_info *coin;
//bits256 txid,commit,srchash,hashmsg; uint32_t flag = 0; int32_t src_or_dest,senderind,i,iter,rlen,myind = -1; char str[65],str2[65]; struct dpow_sigentry dsig; struct dpow_entry *ep; struct dpow_coinentry *cp; struct dpow_utxoentry U; struct iguana_info *coin;
int32_t i,src_or_dest,myind = -1; bits256 txid,srchash; struct iguana_info *coin; char str[65],str2[65];
dpow_notaryfind(myinfo,bp,height,&myind,dp->minerkey33);
if ( myind < 0 )
{
@ -125,7 +126,7 @@ int32_t dpow_datahandler(struct supernet_info *myinfo,struct dpow_info *dp,struc
}
for (i=0; i<32; i++)
srchash.bytes[i] = dp->minerkey33[i+1];
if ( channel == DPOW_ENTRIESCHANNEL )
/*if ( channel == DPOW_ENTRIESCHANNEL )
{
struct dpow_entry notaries[DPOW_MAXRELAYS]; uint8_t n; int8_t bestk; struct dpow_coinentry *ptr,*refptr;
rlen = 0;
@ -263,7 +264,7 @@ int32_t dpow_datahandler(struct supernet_info *myinfo,struct dpow_info *dp,struc
//if ( 0 && bp != 0 )
// printf("%s SIG.%d sender.%d lastk.%d mask.%llx siglen.%d recv.%llx\n",coin->symbol,height,dsig.senderind,dsig.lastk,(long long)dsig.mask,dsig.siglen,(long long)bp->recvmask);
}
else if ( channel == DPOW_TXIDCHANNEL || channel == DPOW_BTCTXIDCHANNEL )
else*/ if ( channel == DPOW_TXIDCHANNEL || channel == DPOW_BTCTXIDCHANNEL )
{
src_or_dest = (channel == DPOW_BTCTXIDCHANNEL);
coin = (src_or_dest != 0) ? bp->destcoin : bp->srccoin;

95
iguana/dpow/dpow_network.c

@ -123,7 +123,7 @@ int32_t dpow_crc32find(struct supernet_info *myinfo,struct dpow_info *dp,uint32_
return(firstz);
}
void dpow_sendutxoset(struct dpow_nanoutxo *np,struct dpow_block *bp,int32_t isratify)
void dpow_nanoutxoset(struct dpow_nanoutxo *np,struct dpow_block *bp,int32_t isratify)
{
int32_t i;
if ( isratify != 0 )
@ -201,13 +201,13 @@ void dpow_ratify_update(struct supernet_info *myinfo,struct dpow_info *dp,struct
}
if ( bestmatches >= bp->minsigs )
{
if ( bp->pendingbestk != bp->ratifybestk || bp->pendingbestmask != bp->ratifybestmask )
if ( bp->pendingratifybestk != bp->ratifybestk || bp->pendingreatifybestmask != bp->ratifybestmask )
{
printf("new PENDING BESTK (%d %llx)\n",bp->ratifybestk,(long long)bp->ratifybestmask);
bp->pendingbestk = bp->ratifybestk;
bp->pendingbestmask = bp->ratifybestmask;
dpow_signedtxgen(myinfo,dp,bp->destcoin,bp,bp->pendingbestk,bp->pendingbestmask,bp->myind,DPOW_SIGBTCCHANNEL,1,1);
dpow_signedtxgen(myinfo,dp,bp->srccoin,bp,bp->pendingbestk,bp->pendingbestmask,bp->myind,DPOW_SIGCHANNEL,0,1);
bp->pendingratifybestk = bp->ratifybestk;
bp->pendingratifybestmask = bp->ratifybestmask;
dpow_signedtxgen(myinfo,dp,bp->destcoin,bp,bp->ratifybestk,bp->ratifybestmask,bp->myind,DPOW_SIGBTCCHANNEL,1,1);
dpow_signedtxgen(myinfo,dp,bp->srccoin,bp,bp->ratifybestk,bp->ratifybestmask,bp->myind,DPOW_SIGCHANNEL,0,1);
}
}
}
@ -215,6 +215,76 @@ void dpow_ratify_update(struct supernet_info *myinfo,struct dpow_info *dp,struct
}
}
void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,uint8_t senderind,int8_t bestk,uint64_t bestmask,uint64_t recvmask,bits256 srcutxo,uint16_t srcvout,bits256 destutxo,uint16_t destvout,uint8_t siglens[2],uint8_t sigs[2][76])
{
int32_t i,bestmatches = 0,matches = 0;
if ( senderind >= 0 && senderind < bp->numnotaries && bits256_nonz(srcutxo) != 0 && bits256_nonz(destutxo) != 0 )
{
bp->notaries[senderind].src.prev_hash = srcutxo;
bp->notaries[senderind].src.prev_vout = srcvout;
bp->notaries[senderind].dest.prev_hash = destutxo;
bp->notaries[senderind].dest.prev_vout = destvout;
bp->notaries[senderind].bestmask = bestmask;
bp->notaries[senderind].recvmask = recvmask;
if ( (bp->notaries[senderind].bestk= bestk) >= 0 )
{
if ( (bp->notaries[senderind].src.siglens[bestk]= siglens[0]) != 0 )
{
memcpy(bp->notaries[senderind].src.sigs[bestk],sigs[0],siglens[0]);
if ( bestk == bp->bestk && bestmask == bp->bestmask )
bp->srcsigmasks[bestk] |= (1LL << senderind);
else bp->srcsigmasks[bestk] &= ~(1LL << senderind);
}
if ( (bp->notaries[senderind].dest.siglens[bestk]= siglens[1]) != 0 )
{
memcpy(bp->notaries[senderind].dest.sigs[bestk],sigs[1],siglens[1]);
if ( bestk == bp->bestk && bestmask == bp->bestmask )
bp->destsigmasks[bestk] |= (1LL << senderind);
else bp->destsigmasks[bestk] &= ~(1LL << senderind);
}
}
bp->recvmask |= (1LL << senderind) | (1LL << bp->myind);
bp->bestmask = dpow_maskmin(bp->recvmask,bp,&bp->bestk);
if ( bp->bestk >= 0 )
{
for (i=0; i<bp->numnotaries; i++)
{
if ( bp->bestk >= 0 && bp->notaries[i].bestk == bp->bestk && bp->notaries[i].bestmask == bp->bestmask )
{
matches++;
if ( ((1LL << i) & bp->bestmask) != 0 )
bestmatches++;
}
}
if ( bestmatches >= bp->minsigs )
{
if ( bp->pendingbestk != bp->bestk || bp->pendingbestmask != bp->bestmask )
{
printf("new PENDING BESTK (%d %llx)\n",bp->bestk,(long long)bp->bestmask);
bp->pendingbestk = bp->bestk;
bp->pendingbestmask = bp->bestmask;
dpow_signedtxgen(myinfo,dp,bp->destcoin,bp,bp->bestk,bp->bestmask,bp->myind,DPOW_SIGBTCCHANNEL,1,0);
dpow_signedtxgen(myinfo,dp,bp->srccoin,bp,bp->bestk,bp->bestmask,bp->myind,DPOW_SIGCHANNEL,0,0);
}
}
}
printf("numips.%d RATIFY.%d matches.%d bestmatches.%d bestk.%d %llx recv.%llx sigmasks.(%llx %llx)\n",myinfo->numdpowipbits,bp->minsigs,matches,bestmatches,bp->bestk,(long long)bp->bestmask,(long long)bp->recvmask,(long long)(bp->bestk>=0?bp->destsigmasks[bp->bestk]:0),(long long)(bp->bestk>=0?bp->srcsigmasks[bp->bestk]:0));
}
}
void dpow_nanoutxoget(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,struct dpow_nanoutxo *np,int32_t isratify,int8_t senderind)
{
if ( isratify != 0 )
{
dpow_ratify_update(myinfo,dp,bp,senderind,np->bestk,np->bestmask,np->recvmask,np->srcutxo,np->srcvout,np->destutxo,np->destvout,np->siglens,np->sigs);
}
else
{
dpow_notarize_update(myinfo,dp,bp,senderind,np->bestk,np->bestmask,np->recvmask,np->srcutxo,np->srcvout,np->destutxo,np->destvout,np->siglens,np->sigs);
}
//dpow_bestmask_update(myinfo,dp,bp,nn_senderind,nn_bestk,nn_bestmask,nn_recvmask);
}
void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen)
{
struct dpow_nanomsghdr *np; int32_t i,size,sentbytes = 0; uint32_t crc32;
@ -228,8 +298,8 @@ void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_blo
np->senderind = bp->myind;
memcpy(np->ipbits,myinfo->dpowipbits,myinfo->numdpowipbits * sizeof(*myinfo->dpowipbits));
//printf("dpow_send.(%d) size.%d numipbits.%d\n",datalen,size,np->numipbits);
dpow_sendutxoset(&np->notarize,bp,0);
dpow_sendutxoset(&np->ratify,bp,1);
dpow_nanoutxoset(&np->notarize,bp,0);
dpow_nanoutxoset(&np->ratify,bp,1);
np->size = size;
np->datalen = datalen;
np->crc32 = crc32;
@ -310,9 +380,12 @@ void dpow_nanomsg_update(struct supernet_info *myinfo)
{
if ( (bp= dpow_heightfind(myinfo,dp,np->height)) != 0 )
{
dpow_bestmask_update(myinfo,dp,bp,nn_senderind,nn_bestk,nn_bestmask,nn_recvmask);
dpow_ratify_update(myinfo,dp,bp,nn_senderind,nn_bestk,nn_bestmask,nn_recvmask,nn_srcutxo,nn_srcvout,nn_destutxo,nn_destvout,nn_siglens,nn_sigs);
dpow_datahandler(myinfo,dp,bp,np->senderind,np->channel,np->height,np->packet,np->datalen);
if ( np->senderind >= 0 && np->senderind < bp->numnotaries )
{
dpow_nanoutxoget(myinfo,dp,bp,&np->notarize,0,np->senderind);
dpow_nanoutxoget(myinfo,dp,bp,&np->ratify,1,np->senderind);
dpow_datahandler(myinfo,dp,bp,np->senderind,np->channel,np->height,np->packet,np->datalen);
}
}
//dp->crcs[firstz] = crc32;
}

2
iguana/iguana777.c

@ -756,7 +756,7 @@ void iguana_helper(void *arg)
iguana_bundlefinalize(myinfo,coin,bp,&MEM,MEMB);
if ( bp->emitfinish != 0 && time(NULL) > bp->emitfinish+60 )
{
if ( bp->validated == 0 )
if ( 0 && bp->validated == 0 )
{
for (i=0; i<j; i++)
if ( coin->bundles[i] == 0 || coin->bundles[i]->validated <= 1 )

1
iguana/iguana_bundles.c

@ -420,7 +420,6 @@ struct iguana_txid *iguana_bundletx(struct iguana_info *coin,struct iguana_bundl
{
static const bits256 zero;
int32_t hdrsi,iter; struct iguana_txid *T; int64_t Toffset; char fname[1024]; FILE *fp; struct iguana_ramchaindata rdata,*rptr;
usleep(1000);
portable_mutex_lock(&coin->special_mutex);
if ( (rptr= bp->ramchain.H.data) != 0 )
{

Loading…
Cancel
Save