jl777 8 years ago
parent
commit
0f6f6f5cbf
  1. 21
      iguana/iguana_notary.c
  2. 8
      iguana/notaries.h

21
iguana/iguana_notary.c

@ -26,6 +26,7 @@
#include "notaries.h"
#define CHECKSIG 0xac
#define DPOW_M(bp) (2) // (((bp)->numnotaries >> 1) + 1)
int32_t dpow_opreturnscript(uint8_t *script,uint8_t *opret,int32_t opretlen)
{
@ -153,7 +154,7 @@ bits256 dpow_notarytx(char *signedtx,int32_t isPoS,struct dpow_block *bp,uint64_
len += iguana_rwnum(1,&serialized[len],sizeof(version),&version);
if ( isPoS != 0 )
len += iguana_rwnum(1,&serialized[len],sizeof(bp->timestamp),&bp->timestamp);
m = (bp->numnotaries >> 1) + 1;
m = DPOW_M(bp);
len += iguana_rwvarint32(1,&serialized[len],(uint32_t *)&m);
for (j=m=0; j<bp->numnotaries; j++)
{
@ -169,7 +170,7 @@ bits256 dpow_notarytx(char *signedtx,int32_t isPoS,struct dpow_block *bp,uint64_
len += iguana_rwnum(1,&serialized[len],sizeof(sequenceid),&sequenceid);
//printf("height.%d mod.%d VINI.%d <- i.%d j.%d\n",height,height % numnotaries,m,i,j);
m++;
if ( m == bp->numnotaries/2+1 && i == lastk )
if ( m == DPOW_M(bp) && i == lastk )
break;
}
}
@ -534,7 +535,7 @@ cJSON *dpow_createtx(struct iguana_info *coin,cJSON **vinsp,struct dpow_block *b
bitcoin_txinput(coin,txobj,bp->notaries[i].prev_hash,bp->notaries[i].prev_vout,0xffffffff,script,sizeof(script),0,0,0,0,sig,siglen);
//printf("height.%d mod.%d VINI.%d <- i.%d j.%d\n",height,height % numnotaries,m,i,j);
m++;
if ( m == bp->numnotaries/2+1 && i == lastk )
if ( m == DPOW_M(bp) && i == lastk )
break;
}
}
@ -639,7 +640,7 @@ uint64_t dpow_lastk_mask(struct dpow_block *bp,int32_t *lastkp)
if ( bits256_nonz(bp->notaries[k].prev_hash) != 0 )
{
mask |= (1LL << k);
if ( ++m >= bp->numnotaries/2+1 )
if ( ++m >= DPOW_M(bp) )
{
*lastkp = k;
break;
@ -657,7 +658,7 @@ int32_t dpow_numsigs(struct dpow_block *bp,int32_t lastk,uint64_t mask)
i = ((bp->height % bp->numnotaries) + j) % bp->numnotaries;
if ( ((1LL << i) & mask) != 0 && bp->notaries[i].siglens[lastk] >= 64 )
{
if ( ++m >= bp->numnotaries/2+1 )
if ( ++m >= DPOW_M(bp) )
return(m);
}
}
@ -713,7 +714,7 @@ void dpow_handler(struct supernet_info *myinfo,struct basilisk_message *msg)
ep->commit = commit;
ep->height = height;
bp->recvmask = dpow_lastk_mask(bp,&lastk);
if ( bitweight(bp->recvmask) >= bp->numnotaries/2+1 )
if ( bitweight(bp->recvmask) >= DPOW_M(bp) )
{
if ( ep->masks[lastk] == 0 )
{
@ -747,7 +748,7 @@ void dpow_handler(struct supernet_info *myinfo,struct basilisk_message *msg)
memcpy(ep->sigs[dsig.lastk],dsig.sig,dsig.siglen);
ep->beacon = dsig.beacon;
printf("<<<<<<<< from.%d got lastk.%d %llx siglen.%d %llx >>>>>>>>>\n",dsig.senderind,dsig.lastk,(long long)dsig.mask,dsig.siglen,(long long)bp->recvsigmask);
if ( bp->state != 0xffffffff && bp->coin != 0 && dpow_numsigs(bp,dsig.lastk,bp->recvsigmask) == bp->numnotaries/2+1 )
if ( bp->state != 0xffffffff && bp->coin != 0 && dpow_numsigs(bp,dsig.lastk,bp->recvsigmask) == DPOW_M(bp) )
{
bp->signedtxid = dpow_notarytx(bp->signedtx,bp->coin->chain->isPoS,bp,dsig.mask,dsig.lastk,bp->opret_symbol);
if ( bits256_nonz(bp->signedtxid) != 0 )
@ -877,20 +878,20 @@ uint32_t dpow_statemachineiterate(struct supernet_info *myinfo,struct dpow_info
case 2:
bp->recvmask = dpow_lastk_mask(bp,&k);
//printf("STATE2: RECVMASK.%llx\n",(long long)bp->recvmask);
if ( bitweight(bp->recvmask) > bp->numnotaries/2 )
if ( bitweight(bp->recvmask) >= DPOW_M(bp) )
bp->state = 3;
else bp->state = 2;
break;
case 3: // create rawtx, sign, send rawtx + sig to all other nodes
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);
if ( bitweight(mask) >= bp->numnotaries/2+1 )
if ( bitweight(mask) >= DPOW_M(bp) )
{
if ( dpow_signedtxgen(myinfo,coin,bp,mask,k,myind,opret_symbol) == 0 )
{
bp->state = 4;
}
} 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),DPOW_M(bp));
break;
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);

8
iguana/notaries.h

@ -21,11 +21,11 @@ char *Notaries[][2] =
{ "jl777_testA", "03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828" },
{ "jl777_testB", "02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344" },
//{ "jl777_testC", "020e0f6fe6e0fcdcac541eb728d6fe538a12adff20412b3c8a7fa892b223a47c2f" },
//{ "locomb_EU", "025c6d26649b9d397e63323d96db42a9d3caad82e1d6076970efe5056c00c0779b" },
{ "locomb_EU", "025c6d26649b9d397e63323d96db42a9d3caad82e1d6076970efe5056c00c0779b" },
{ "fullmoon_AE", "020d73d3aedc9998ac0fab7c55eaf5f9c96a7518773057dee95533ae0ff7e51ab4" },
{ "movecrypto_EU", "021ab53bc6cf2c46b8a5456759f9d608966eff87384c2b52c0ac4cc8dd51e9cc42" },
//{ "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" },
/*{ "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" },
{ "pondsea_SH", "02209073bc0943451498de57f802650311b1f12aa6deffcd893da198a544c04f36" },
{ "badass_EU", "0209d48554768dd8dada988b98aca23405057ac4b5b46838a9378b95c3e79b9b9e" },
{ "crackers_NA", "029e1c01131974f4cd3f564cc0c00eb87a0f9721043fbc1ca60f9bd0a1f73f64a1" },
{ "proto_EU", "03681ffdf17c8f4f0008cefb7fa0779c5e888339cdf932f0974483787a4d6747c1" },
{ "jeezy_EU", "023cb3e593fb85c5659688528e9a4f1c4c7f19206edc7e517d20f794ba686fd6d6" },
@ -42,7 +42,7 @@ char *Notaries[][2] =
{ "pondsea_EU", "0225aa6f6f19e543180b31153d9e6d55d41bc7ec2ba191fd29f19a2f973544e29d" },
{ "badass_SH", "0287fed7cd90994281f308ad112230d970c04148d7017e828fee47bfaf11c50679" },
{ "baddass_NA" "03df6bd57ff49a632be2a510dc83109ec90588f37f895b751c3b0f35712027c330" },
{ "Server1","0221876c8259764224dc1a7b70ec956f3fbe9a768cd77f13082cfa60eb6aa2d068"},
/*{ "Server1","0221876c8259764224dc1a7b70ec956f3fbe9a768cd77f13082cfa60eb6aa2d068"},
{ "Server2","03c7c14e6b1f94585bb571cf3ee5eb9b9ab54bd23d0acb8cf13edad1c515842b66"},
{ "Server3","02d28f8992ff0cd68c5d558cf55ec5b3ada25151519a6cea8cef1bac04c40023b6"},
{ "Server4","02adc84814fee5864e67fd1b76f97fbe74d6bd07c62335e2f1da918f46d08d84ba"},

Loading…
Cancel
Save