Browse Source

hotfix protection

dPoW
jl777 8 years ago
parent
commit
16ba7fd734
  1. 2
      iguana/dPoW.h
  2. 10
      iguana/dpow/dpow_fsm.c
  3. 30
      iguana/dpow/dpow_rpc.c

2
iguana/dPoW.h

@ -40,7 +40,7 @@
#define DPOW_FIFOSIZE 64
#define DPOW_MAXTX 8192
#define DPOW_THIRDPARTY_CONFIRMS 0
#define DPOW_KOMODOCONFIRMS 3
#define DPOW_KOMODOCONFIRMS 10
#define DPOW_BTCCONFIRMS 1
#define DPOW_MAXRELAYS 64
#define DPOW_MAXSIGLEN 128

10
iguana/dpow/dpow_fsm.c

@ -387,6 +387,16 @@ void dpow_statemachinestart(void *ptr)
printf("new ratification started. abort ht.%d\n",bp->height);
break;
}
if ( bp->isratify == 0 )
{
bits256 checkhash;
checkhash = dpow_getblockhash(myinfo,bp->srccoin,bp->height);
if ( bits256_cmp(checkhash,bp->hashmsg) != 0 )
{
printf("%s ht.%d %s got reorged to %s, abort notarization\n",bp->srccoin->symbol,bp->height,bits256_str(str,bp->hashmsg),bits256_str(str2,checkhash));
bp->state = 0xffffffff;
}
}
if ( bp->state != 0xffffffff )
{
dpow_send(myinfo,dp,bp,srchash,bp->hashmsg,0,bp->height,(void *)"ping",0);

30
iguana/dpow/dpow_rpc.c

@ -85,6 +85,36 @@ bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *c
return(blockhash);
}
bits256 dpow_getblockhash(struct supernet_info *myinfo,struct iguana_info *coin,int32_t height)
{
char buf[128],*retstr=0; bits256 blockhash;
memset(blockhash.bytes,0,sizeof(blockhash));
if ( coin->FULLNODE < 0 )
{
sprintf(buf,"\"%d\"",height);
retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getblockhash",buf);
printf("%s ht.%d -> getblockhash.(%s)\n",coin->symbol,height,retstr);
usleep(10000);
}
else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 )
{
printf("test iguana mode getblockhash\n");
retstr = bitcoinrpc_getblockhash(myinfo,coin,0,0,height);
}
else
{
return(blockhash);
}
if ( retstr != 0 )
{
if ( strlen(retstr) == 64 )
decode_hex(blockhash.bytes,32,retstr);
free(retstr);
}
return(blockhash);
}
cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits256 blockhash)
{
char buf[128],str[65],*retstr=0; cJSON *json = 0;

Loading…
Cancel
Save