jl777 8 years ago
parent
commit
b2363ea097
  1. 1
      iguana/iguana777.c
  2. 45
      iguana/iguana_unspents.c
  3. 1
      includes/iguana_funcs.h

1
iguana/iguana777.c

@ -836,6 +836,7 @@ void iguana_callcoinstart(struct supernet_info *myinfo,struct iguana_info *coin)
memset(zero.bytes,0,sizeof(zero));
if ( (bp= iguana_bundlecreate(coin,&bundlei,0,*(bits256 *)coin->chain->genesis_hashdata,zero,1)) != 0 )
bp->bundleheight = 0;
iguana_unspents_markinit(myinfo,coin);
}
void iguana_coinloop(void *arg)

45
iguana/iguana_unspents.c

@ -839,13 +839,7 @@ int32_t iguana_staker_sort(struct iguana_info *coin,bits256 *hash2p,uint8_t *ref
int32_t iguana_markedunspents_find(struct iguana_info *coin,int32_t *firstslotp,bits256 txid,int32_t vout)
{
static int32_t didinit;
int32_t i; //char str[65];
if ( didinit == 0 )
{
printf("Load recent unspents here!\n");
didinit = 1;
}
int32_t i;
*firstslotp = -1;
if ( bits256_nonz(txid) != 0 && vout >= 0 )
{
@ -902,6 +896,43 @@ void iguana_unspents_mark(struct supernet_info *myinfo,struct iguana_info *coin,
}
}
void iguana_unspents_markinit(struct supernet_info *myinfo,struct iguana_info *coin)
{
static int32_t didinit;
if ( didinit == 0 )
{
char *filestr,fname[1024]; long filesize; bits256 filetxid; cJSON *array,*item; int32_t i,filevout,n,firstslot;
sprintf(fname,"%s/%s/utxo.json",GLOBAL_DBDIR,coin->symbol);
if ( (filestr= OS_filestr(&filesize,fname)) != 0 )
{
if ( (array= cJSON_Parse(filestr)) != 0 )
{
if ( is_cJSON_Array(array) != 0 && (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
{
item = jitem(array,i);
filetxid = jbits256i(item,0);
filevout = jinti(item,1);
if ( iguana_markedunspents_find(coin,&firstslot,filetxid,filevout) < 0 )
{
if ( firstslot >= 0 )
{
char str[65]; printf("slot.[%d] <- %s/v%d\n",firstslot,bits256_str(str,filetxid),filevout);
coin->markedunspents[firstslot] = filetxid;
coin->markedunspents[firstslot].ushorts[15] = filevout;
}
}
}
}
free_json(array);
}
free(filestr);
}
didinit = 1;
}
}
int32_t iguana_RTunspent_check(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_outpoint outpt)
{
int32_t firstslot;

1
includes/iguana_funcs.h

@ -422,6 +422,7 @@ void revcalc_rmd160_sha256(uint8_t rmd160[20],bits256 revhash);
struct iguana_utxo iguana_utxofind(struct iguana_info *coin,struct iguana_outpoint spentpt,int32_t *RTspendflagp,int32_t lockflag);
int32_t iguana_vinifind(struct supernet_info *myinfo,struct iguana_info *coin,bits256 *spentfrom,bits256 txid,int32_t vout);
int32_t iguana_scriptsigextract(struct supernet_info *myinfo,struct iguana_info *coin,uint8_t *script,int32_t maxsize,bits256 txid,int32_t vini);
void iguana_unspents_markinit(struct supernet_info *myinfo,struct iguana_info *coin);
bits256 iguana_str2priv(struct supernet_info *myinfo,struct iguana_info *coin,char *str);
int32_t iguana_RTspentflag(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t *RTspendp,int32_t *spentheightp,struct iguana_ramchain *ramchain,struct iguana_outpoint spentpt,int32_t height,int32_t minconf,int32_t maxconf,uint64_t amount);

Loading…
Cancel
Save