jl777 8 years ago
parent
commit
dc4f04d4a6
  1. 2
      iguana/dPoW.h
  2. 50
      iguana/iguana_notary.c
  3. 3
      iguana/tests/notaryinit

2
iguana/dPoW.h

@ -22,7 +22,7 @@
#define DPOW_FIFOSIZE 64
#define DPOW_MAXTX 8192
#define DPOW_THIRDPARTY_CONFIRMS 10
#define DPOW_KOMODOCONFIRMS 10
#define DPOW_KOMODOCONFIRMS 1
#define DPOW_BTCCONFIRMS 1
#define DPOW_MAXRELAYS 64

50
iguana/iguana_notary.c

@ -204,6 +204,31 @@ char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *c
}
}
int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *blockhashp,uint32_t *blocktimep,bits256 *txs,uint32_t *numtxp,struct iguana_info *coin)
{
int32_t n,i,height = -1,maxtx = *numtxp; bits256 besthash; cJSON *array,*json;
*numtxp = *blocktimep = 0;
besthash = dpow_getbestblockhash(myinfo,coin);
if ( bits256_nonz(besthash) != 0 )
{
if ( (json= dpow_getblock(myinfo,coin,besthash)) != 0 )
{
if ( (height= juint(json,"height")) != 0 && (*blocktimep= juint(json,"time")) != 0 )
{
if ( (array= jarray(&n,json,"tx")) != 0 )
{
for (i=0; i<n&&i<maxtx; i++)
txs[i] = jbits256i(array,i);
//printf("dpow_getchaintip %s ht.%d time.%u numtx.%d\n",coin->symbol,height,*blocktimep,n);
*numtxp = n;
}
} else height = -1;
free_json(json);
}
}
return(height);
}
int32_t dpow_haveutxo(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *txidp,int32_t *voutp,char *coinaddr)
{
int32_t i,n,vout,haveutxo = 0; bits256 txid; cJSON *unspents,*item; uint64_t satoshis; char *str; uint8_t script[35];
@ -694,31 +719,6 @@ void dpow_statemachinestart(void *ptr)
free(ptr);
}
int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *blockhashp,uint32_t *blocktimep,bits256 *txs,uint32_t *numtxp,struct iguana_info *coin)
{
int32_t n,i,height = -1,maxtx = *numtxp; bits256 besthash; cJSON *array,*json;
*numtxp = *blocktimep = 0;
besthash = dpow_getbestblockhash(myinfo,coin);
if ( bits256_nonz(besthash) != 0 )
{
if ( (json= dpow_getblock(myinfo,coin,besthash)) != 0 )
{
if ( (height= juint(json,"height")) != 0 && (*blocktimep= juint(json,"time")) != 0 )
{
if ( (array= jarray(&n,json,"tx")) != 0 )
{
for (i=0; i<n&&i<maxtx; i++)
txs[i] = jbits256i(array,i);
//printf("dpow_getchaintip %s ht.%d time.%u numtx.%d\n",coin->symbol,height,*blocktimep,n);
*numtxp = n;
}
} else height = -1;
free_json(json);
}
}
return(height);
}
void dpow_fifoupdate(struct supernet_info *myinfo,struct dpow_checkpoint *fifo,struct dpow_checkpoint tip)
{
int32_t i,offset; struct dpow_checkpoint newfifo[DPOW_FIFOSIZE];

3
iguana/tests/notaryinit

@ -8,6 +8,9 @@ tests/getinfoN_7776
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"SuperNET\",\"method\":\"myipaddr\",\"ipaddr\":\"$myip\"}"
./wp
curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"SuperNET\",\"method\":\"activehandle\"}"
sleep 3
btc_7776
sleep 3
kmd_7776
sleep 3
tests/dpow_7776

Loading…
Cancel
Save