jl777 8 years ago
parent
commit
9ad6697519
  1. 52
      deprecated/obsolete.h
  2. 66
      iguana/iguana_notary.c

52
deprecated/obsolete.h

@ -19261,6 +19261,58 @@ len = 0;
} }
return(num); return(num);
} }
/*int32_t dpow_mostsignedtx(struct supernet_info *myinfo,struct dpow_info *dp,struct iguana_info *coin,uint64_t *maskp,int32_t *lastkp,struct dpow_block *bp,int32_t myind)
{
uint64_t mostmask=0,refmask = 0; struct dpow_entry *ep; int32_t nonz,k,i,mostk = -1,most = 0;
for (k=0; k<bp->numnotaries; k++)
{
for (refmask=i=nonz=0; i<bp->numnotaries; i++)
{
ep = &bp->notaries[i];
if ( ep->masks[k] != 0 )
{
if ( nonz == 0 )
{
refmask = ep->masks[k], nonz++;
printf("refmask.%llx\n",(long long)refmask);
}
else if ( ep->masks[k] != refmask )
printf("refk.%d refmask.%llx but got %llx\n",k,(long long)refmask,(long long)ep->masks[k]);
}
}
if ( nonz > most )
{
most = nonz;
mostmask = refmask;
mostk = k;
}
printf("k.%d nonz.%d vs most.%d mostk.%d mostmask.%llx\n",k,nonz,most,mostk,(long long)mostmask);
}
if ( most > 0 )
{
*lastkp = mostk;
*maskp = mostmask;
bp->signedtxid = dpow_notarytx(bp->signedtx,coin->chain->isPoS,bp,mostmask,mostk,dp->symbol);
} else printf("mostsignedtx most.%d\n",most);
return(most);
}*/
/*if ( (m= dpow_mostsignedtx(myinfo,dp,coin,&mask,&k,bp,myind)) > 0 )
{
if ( m >= bp->numnotaries/2+1 )
{
if ( (retstr= dpow_sendrawtransaction(myinfo,coin,bp->signedtx)) != 0 )
{
dp->destupdated = 0;
printf("sendrawtransaction.(%s)\n",retstr);
free(retstr);
}
bp->state = 0xffffffff;
}
else
{
dpow_signedtxgen(myinfo,coin,bp,mask,k,myind,opret_symbol);
}
}*/
int32_t dpow_dsigs_match(struct dpow_entry notaries[DPOW_MAXRELAYS],int32_t numnotaries,struct dpow_sigentry *dsigs,int32_t num,int32_t refk,uint64_t refmask,int32_t refheight) int32_t dpow_dsigs_match(struct dpow_entry notaries[DPOW_MAXRELAYS],int32_t numnotaries,struct dpow_sigentry *dsigs,int32_t num,int32_t refk,uint64_t refmask,int32_t refheight)
{ {

66
iguana/iguana_notary.c

@ -545,7 +545,7 @@ cJSON *dpow_createtx(struct iguana_info *coin,cJSON **vinsp,struct dpow_block *b
txobj = bitcoin_txoutput(txobj,script,sizeof(script),satoshis); txobj = bitcoin_txoutput(txobj,script,sizeof(script),satoshis);
} }
*vinsp = vins; *vinsp = vins;
if ( usesigs != 0 ) if ( 0 && usesigs != 0 )
printf("%s createtx.(%s)\n",coin->symbol,jprint(txobj,0)); printf("%s createtx.(%s)\n",coin->symbol,jprint(txobj,0));
return(txobj); return(txobj);
} }
@ -598,6 +598,7 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct iguana_info *coin,s
ep->siglens[dsig.lastk] = dsig.siglen; ep->siglens[dsig.lastk] = dsig.siglen;
memcpy(ep->sigs[dsig.lastk],dsig.sig,dsig.siglen); memcpy(ep->sigs[dsig.lastk],dsig.sig,dsig.siglen);
ep->beacon = dsig.beacon; 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); //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=((myind + (uint32_t)rand()) % incr); i<bp->numnotaries; i+=incr) for (i=((myind + (uint32_t)rand()) % incr); i<bp->numnotaries; i+=incr)
{ {
@ -628,42 +629,6 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct iguana_info *coin,s
return(retval); return(retval);
} }
/*int32_t dpow_mostsignedtx(struct supernet_info *myinfo,struct dpow_info *dp,struct iguana_info *coin,uint64_t *maskp,int32_t *lastkp,struct dpow_block *bp,int32_t myind)
{
uint64_t mostmask=0,refmask = 0; struct dpow_entry *ep; int32_t nonz,k,i,mostk = -1,most = 0;
for (k=0; k<bp->numnotaries; k++)
{
for (refmask=i=nonz=0; i<bp->numnotaries; i++)
{
ep = &bp->notaries[i];
if ( ep->masks[k] != 0 )
{
if ( nonz == 0 )
{
refmask = ep->masks[k], nonz++;
printf("refmask.%llx\n",(long long)refmask);
}
else if ( ep->masks[k] != refmask )
printf("refk.%d refmask.%llx but got %llx\n",k,(long long)refmask,(long long)ep->masks[k]);
}
}
if ( nonz > most )
{
most = nonz;
mostmask = refmask;
mostk = k;
}
printf("k.%d nonz.%d vs most.%d mostk.%d mostmask.%llx\n",k,nonz,most,mostk,(long long)mostmask);
}
if ( most > 0 )
{
*lastkp = mostk;
*maskp = mostmask;
bp->signedtxid = dpow_notarytx(bp->signedtx,coin->chain->isPoS,bp,mostmask,mostk,dp->symbol);
} else printf("mostsignedtx most.%d\n",most);
return(most);
}*/
uint64_t dpow_lastk_mask(struct dpow_block *bp,int32_t *lastkp) uint64_t dpow_lastk_mask(struct dpow_block *bp,int32_t *lastkp)
{ {
int32_t j,m,k; uint64_t mask = 0; int32_t j,m,k; uint64_t mask = 0;
@ -747,7 +712,7 @@ void dpow_handler(struct supernet_info *myinfo,struct basilisk_message *msg)
ep->prev_vout = vout; ep->prev_vout = vout;
ep->commit = commit; ep->commit = commit;
ep->height = height; ep->height = height;
mask = dpow_lastk_mask(bp,&lastk); bp->recvmask = dpow_lastk_mask(bp,&lastk);
if ( bitweight(mask) >= bp->numnotaries/2+1 ) if ( bitweight(mask) >= bp->numnotaries/2+1 )
{ {
if ( ep->masks[lastk] == 0 ) if ( ep->masks[lastk] == 0 )
@ -854,6 +819,7 @@ uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info
return(0xffffffff); return(0xffffffff);
for (j=0; j<sizeof(srchash); j++) for (j=0; j<sizeof(srchash); j++)
srchash.bytes[j] = myinfo->DPOW.minerkey33[j+1]; srchash.bytes[j] = myinfo->DPOW.minerkey33[j+1];
if ( (rand() % 10) == 0 )
printf("%s FSM.%d %s BTC.%d masks.(%llx %llx)\n",coin->symbol,bp->state,coinaddr,bits256_nonz(bp->btctxid)==0,(long long)bp->recvmask,(long long)bp->recvsigmask); printf("%s FSM.%d %s BTC.%d masks.(%llx %llx)\n",coin->symbol,bp->state,coinaddr,bits256_nonz(bp->btctxid)==0,(long long)bp->recvmask,(long long)bp->recvsigmask);
switch ( bp->state ) switch ( bp->state )
{ {
@ -881,6 +847,7 @@ uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info
if ( (haveutxo= dpow_haveutxo(myinfo,coin,&txid,&vout,coinaddr)) != 0 && vout >= 0 && vout < 0x100 ) if ( (haveutxo= dpow_haveutxo(myinfo,coin,&txid,&vout,coinaddr)) != 0 && vout >= 0 && vout < 0x100 )
{ {
len = dpow_rwutxobuf(1,data,&bp->hashmsg,&txid,&vout,&bp->commit,myinfo->DPOW.minerkey33); 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=((myind + (uint32_t)rand()) % incr); i<bp->numnotaries; i+=incr)
{ {
for (j=0; j<sizeof(srchash); j++) for (j=0; j<sizeof(srchash); j++)
@ -899,7 +866,7 @@ uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info
break; break;
case 3: // create rawtx, sign, send rawtx + sig to all other nodes case 3: // create rawtx, sign, send rawtx + sig to all other nodes
mask = dpow_lastk_mask(bp,&k); mask = dpow_lastk_mask(bp,&k);
printf("STATE3: %s BTC.%d RECVMASK.%llx mask.%llx\n",coin->symbol,bits256_nonz(bp->btctxid)==0,(long long)bp->recvmask,(long long)mask); //printf("STATE3: %s BTC.%d RECVMASK.%llx mask.%llx\n",coin->symbol,bits256_nonz(bp->btctxid)==0,(long long)bp->recvmask,(long long)mask);
if ( bitweight(mask) >= bp->numnotaries/2+1 ) if ( bitweight(mask) >= bp->numnotaries/2+1 )
{ {
if ( dpow_signedtxgen(myinfo,coin,bp,mask,k,myind,opret_symbol) == 0 ) if ( dpow_signedtxgen(myinfo,coin,bp,mask,k,myind,opret_symbol) == 0 )
@ -909,31 +876,14 @@ uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info
} else printf("state 3 not done: mask.%llx wt.%d vs.%d\n",(long long)mask,bitweight(mask),bp->numnotaries/2+1); } else printf("state 3 not done: mask.%llx wt.%d vs.%d\n",(long long)mask,bitweight(mask),bp->numnotaries/2+1);
break; break;
case 4: // wait for N/2+1 signed tx and broadcast case 4: // wait for N/2+1 signed tx and broadcast
printf("STATE4: %s BTC.%d RECVMASK.%llx\n",coin->symbol,bits256_nonz(bp->btctxid)==0,(long long)bp->recvmask); //printf("STATE4: %s BTC.%d RECVMASK.%llx\n",coin->symbol,bits256_nonz(bp->btctxid)==0,(long long)bp->recvmask);
if ( bp->waiting++ > 10 ) if ( bp->waiting++ > 10 )
{ {
bp->state = 2; bp->state = 2;
bp->waiting = 0; bp->waiting = 0;
} }
/*if ( (m= dpow_mostsignedtx(myinfo,dp,coin,&mask,&k,bp,myind)) > 0 )
{
if ( m >= bp->numnotaries/2+1 )
{
if ( (retstr= dpow_sendrawtransaction(myinfo,coin,bp->signedtx)) != 0 )
{
dp->destupdated = 0;
printf("sendrawtransaction.(%s)\n",retstr);
free(retstr);
}
bp->state = 0xffffffff;
}
else
{
dpow_signedtxgen(myinfo,coin,bp,mask,k,myind,opret_symbol);
}
}*/
if ( bp->state != 0xffffffff ) if ( bp->state != 0xffffffff )
bp->state = 2; bp->state = 1;
break; break;
} }
return(bp->state); return(bp->state);

Loading…
Cancel
Save