jl777 8 years ago
parent
commit
e8e1e8000a
  1. 13
      iguana/dpow/dpow_network.c
  2. 11
      iguana/dpow/dpow_tx.c

13
iguana/dpow/dpow_network.c

@ -35,8 +35,8 @@ struct dpow_nanomsghdr
uint64_t dpow_ratifybest(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp); uint64_t dpow_ratifybest(uint64_t refmask,struct dpow_block *bp,int8_t *lastkp);
struct dpow_block *dpow_heightfind(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height); struct dpow_block *dpow_heightfind(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height);
int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struct iguana_info *coin,struct dpow_block *bp,int8_t bestk,uint64_t bestmask,int32_t myind,uint32_t sigchannel,int32_t src_or_dest,int32_t useratified); int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struct iguana_info *coin,struct dpow_block *bp,int8_t bestk,uint64_t bestmask,int32_t myind,uint32_t deprec,int32_t src_or_dest,int32_t useratified);
void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,int32_t myind,int32_t src_or_dest); void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,int32_t myind,int32_t src_or_dest,int8_t bestk,uint64_t bestmask,uint8_t pubkeys[64][33],int32_t numratified);
char *nanomsg_tcpname(char *str,char *ipaddr) char *nanomsg_tcpname(char *str,char *ipaddr)
{ {
@ -236,12 +236,13 @@ void dpow_ratify_update(struct supernet_info *myinfo,struct dpow_info *dp,struct
} }
if ( bp->ratifysigmasks[1] == bp->ratifybestmask ) // have all sigs if ( bp->ratifysigmasks[1] == bp->ratifybestmask ) // have all sigs
{ {
printf("ready to sign state.%d\n",bp->state);
if ( bp->state < 1000 ) if ( bp->state < 1000 )
dpow_sigscheck(myinfo,dp,bp,bp->myind,1); dpow_sigscheck(myinfo,dp,bp,bp->myind,1,bp->ratifybestk,bp->ratifybestmask,bp->ratified_pubkeys,bp->numratified);
if ( bp->ratifysigmasks[0] == bp->ratifybestmask ) // have all sigs if ( bp->ratifysigmasks[0] == bp->ratifybestmask ) // have all sigs
{ {
if ( bp->state != 0xffffffff ) if ( bp->state != 0xffffffff )
dpow_sigscheck(myinfo,dp,bp,bp->myind,0); dpow_sigscheck(myinfo,dp,bp,bp->myind,0,bp->ratifybestk,bp->ratifybestmask,bp->ratified_pubkeys,bp->numratified);
} //else printf("ratify srcmask.%llx != bestmask.%llx\n",(long long)bp->ratifysigmasks[0],(long long)bp->bestmask); } //else printf("ratify srcmask.%llx != bestmask.%llx\n",(long long)bp->ratifysigmasks[0],(long long)bp->bestmask);
} //else printf("ratify destmask.%llx != bestmask.%llx\n",(long long)bp->ratifysigmasks[1],(long long)bp->bestmask); } //else printf("ratify destmask.%llx != bestmask.%llx\n",(long long)bp->ratifysigmasks[1],(long long)bp->bestmask);
} }
@ -307,11 +308,11 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru
if ( bp->destsigsmasks[bp->bestk] == bp->bestmask ) // have all sigs if ( bp->destsigsmasks[bp->bestk] == bp->bestmask ) // have all sigs
{ {
if ( bp->state < 1000 ) if ( bp->state < 1000 )
dpow_sigscheck(myinfo,dp,bp,bp->myind,1); dpow_sigscheck(myinfo,dp,bp,bp->myind,1,bp->bestk,bp->bestmask,0,0);
if ( bp->srcsigsmasks[bp->bestk] == bp->bestmask ) // have all sigs if ( bp->srcsigsmasks[bp->bestk] == bp->bestmask ) // have all sigs
{ {
if ( bp->state != 0xffffffff ) if ( bp->state != 0xffffffff )
dpow_sigscheck(myinfo,dp,bp,bp->myind,0); dpow_sigscheck(myinfo,dp,bp,bp->myind,0,bp->bestk,bp->bestmask,0,0);
} //else printf("srcmask.%llx != bestmask.%llx\n",(long long)bp->srcsigsmasks[bp->bestk],(long long)bp->bestmask); } //else printf("srcmask.%llx != bestmask.%llx\n",(long long)bp->srcsigsmasks[bp->bestk],(long long)bp->bestmask);
} //else printf("destmask.%llx != bestmask.%llx\n",(long long)bp->destsigsmasks[bp->bestk],(long long)bp->bestmask); } //else printf("destmask.%llx != bestmask.%llx\n",(long long)bp->destsigsmasks[bp->bestk],(long long)bp->bestmask);
} }

11
iguana/dpow/dpow_tx.c

@ -447,17 +447,16 @@ int32_t dpow_signedtxgen(struct supernet_info *myinfo,struct dpow_info *dp,struc
return(retval); return(retval);
} }
void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,int32_t myind,int32_t src_or_dest) void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,int32_t myind,int32_t src_or_dest,int8_t bestk,uint64_t bestmask,uint8_t pubkeys[64][33],int32_t numratified)
{ {
bits256 txid,srchash,zero,signedtxid; struct iguana_info *coin; int32_t j,len,numsigs; char *retstr=0,str[65],str2[65]; uint8_t txdata[32768]; uint32_t channel; bits256 txid,srchash,zero,signedtxid; struct iguana_info *coin; int32_t j,len,numsigs; char *retstr=0,str[65],str2[65]; uint8_t txdata[32768]; uint32_t channel;
coin = (src_or_dest != 0) ? bp->destcoin : bp->srccoin; coin = (src_or_dest != 0) ? bp->destcoin : bp->srccoin;
memset(zero.bytes,0,sizeof(zero)); memset(zero.bytes,0,sizeof(zero));
channel = (src_or_dest != 0) ? DPOW_SIGBTCCHANNEL : DPOW_SIGCHANNEL; channel = (src_or_dest != 0) ? DPOW_SIGBTCCHANNEL : DPOW_SIGCHANNEL;
if ( bp->bestk >= 0 && bp->state != 0xffffffff && coin != 0 ) if ( bestk >= 0 && bp->state != 0xffffffff && coin != 0 )
{ {
//printf("dpow_sigscheck (%d %llx) myind.%d src_dest.%d state.%x coin.%s\n",bp->bestk,(long long)bp->bestmask,myind,src_or_dest,bp->state,coin->symbol); signedtxid = dpow_notarytx(bp->signedtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,1,src_or_dest,pubkeys,numratified);
signedtxid = dpow_notarytx(bp->signedtx,&numsigs,coin->chain->isPoS,bp,bp->bestk,bp->bestmask,1,src_or_dest,bp->numratified!=0?bp->ratified_pubkeys:0,bp->isratify*bp->numratified); printf("src_or_dest.%d bestk.%d %llx %s numsigs.%d signedtx.(%s)\n",src_or_dest,bestk,(long long)bestmask,bits256_str(str,signedtxid),numsigs,bp->signedtx);
//printf("src_or_dest.%d bestk.%d %llx %s numsigs.%d signedtx.(%s)\n",src_or_dest,bp->bestk,(long long)bp->bestmask,bits256_str(str,signedtxid),numsigs,bp->signedtx);
bp->state = 1; bp->state = 1;
if ( bits256_nonz(signedtxid) != 0 && numsigs == bp->minsigs ) if ( bits256_nonz(signedtxid) != 0 && numsigs == bp->minsigs )
{ {
@ -472,7 +471,7 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo
if ( src_or_dest != 0 ) if ( src_or_dest != 0 )
{ {
bp->desttxid = txid; bp->desttxid = txid;
dpow_signedtxgen(myinfo,dp,bp->srccoin,bp,bp->bestk,bp->bestmask,myind,DPOW_SIGCHANNEL,0,bp->isratify); dpow_signedtxgen(myinfo,dp,bp->srccoin,bp,bestk,bestmask,myind,DPOW_SIGCHANNEL,0,numratified != 0);
} else bp->srctxid = txid; } else bp->srctxid = txid;
len = (int32_t)strlen(bp->signedtx) >> 1; len = (int32_t)strlen(bp->signedtx) >> 1;
decode_hex(txdata+32,len,bp->signedtx); decode_hex(txdata+32,len,bp->signedtx);

Loading…
Cancel
Save