jl777 8 years ago
parent
commit
714ec71862
  1. 14
      iguana/dpow/dpow_fsm.c
  2. 4
      iguana/dpow/dpow_network.c

14
iguana/dpow/dpow_fsm.c

@ -102,12 +102,19 @@ void dpow_sync(struct supernet_info *myinfo,struct dpow_block *bp,uint64_t refma
void dpow_datahandler(struct supernet_info *myinfo,uint32_t channel,uint32_t height,uint8_t *data,int32_t datalen,int32_t src_or_dest) void dpow_datahandler(struct supernet_info *myinfo,uint32_t channel,uint32_t height,uint8_t *data,int32_t datalen,int32_t src_or_dest)
{ {
bits256 hashmsg,txid,commit,srchash; struct dpow_block *bp = 0; uint32_t flag = 0; int32_t senderind,i,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 hashmsg,txid,commit,srchash; struct dpow_block *bp = 0; uint32_t starttime,flag = 0; int32_t senderind,i,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;
if ( (bp= dpow_heightfind(myinfo,height)) == 0 ) starttime = (uint32_t)time(NULL);
while ( 1 )
{
if ( (bp= dpow_heightfind(myinfo,height)) != 0 )
break;
if ( time(NULL) > starttime+10 )
{ {
printf("dpow_datahandler: cant find ht.%d\n",height); printf("dpow_datahandler: cant find ht.%d\n",height);
return; return;
} }
sleep(1);
}
dpow_notaryfind(myinfo,bp,&myind,myinfo->DPOW.minerkey33); dpow_notaryfind(myinfo,bp,&myind,myinfo->DPOW.minerkey33);
if ( myind < 0 ) if ( myind < 0 )
return; return;
@ -116,7 +123,10 @@ void dpow_datahandler(struct supernet_info *myinfo,uint32_t channel,uint32_t hei
{ {
memset(&U,0,sizeof(U)); memset(&U,0,sizeof(U));
if ( dpow_rwutxobuf(0,data,&U,bp) < 0 ) if ( dpow_rwutxobuf(0,data,&U,bp) < 0 )
{
printf("error from rwutxobuf\n");
return; return;
}
if ( bits256_cmp(hashmsg,bp->hashmsg) != 0 ) if ( bits256_cmp(hashmsg,bp->hashmsg) != 0 )
{ {
printf("unexpected mismatch hashmsg.%s vs %s\n",bits256_str(str,hashmsg),bits256_str(str2,bp->hashmsg)); printf("unexpected mismatch hashmsg.%s vs %s\n",bits256_str(str,hashmsg),bits256_str(str2,bp->hashmsg));

4
iguana/dpow/dpow_network.c

@ -193,8 +193,10 @@ int32_t dpow_rwutxobuf(int32_t rwflag,uint8_t *data,struct dpow_utxoentry *up,st
{ {
uint8_t numnotaries; uint64_t othermask; int32_t i,len = 0; uint8_t numnotaries; uint64_t othermask; int32_t i,len = 0;
if ( bits256_nonz(up->srchash) == 0 || bits256_nonz(up->desthash) == 0 ) if ( bits256_nonz(up->srchash) == 0 || bits256_nonz(up->desthash) == 0 )
{
printf("dpow_rwutxobuf null src.%d or dest.%d\n",bits256_nonz(up->srchash),bits256_nonz(up->desthash));
return(-1); return(-1);
len = 2; }
len += iguana_rwbignum(rwflag,&data[len],sizeof(up->hashmsg),up->hashmsg.bytes); len += iguana_rwbignum(rwflag,&data[len],sizeof(up->hashmsg),up->hashmsg.bytes);
len += iguana_rwbignum(rwflag,&data[len],sizeof(up->srchash),up->srchash.bytes); len += iguana_rwbignum(rwflag,&data[len],sizeof(up->srchash),up->srchash.bytes);
len += iguana_rwbignum(rwflag,&data[len],sizeof(up->desthash),up->desthash.bytes); len += iguana_rwbignum(rwflag,&data[len],sizeof(up->desthash),up->desthash.bytes);

Loading…
Cancel
Save