diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index f00f2a5b8..cc165cc5a 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -821,11 +821,11 @@ int64_t iguana_fastfindinit(struct iguana_info *coin) printf("%s\n",fname); if ( (sortbuf= OS_filestr(&allocsize,fname)) != 0 ) { - qsort(sortbuf,allocsize/sizeof(bits256),sizeof(bits256),_bits256_cmp); + num = (int32_t)allocsize/sizeof(bits256); + qsort(sortbuf,num,sizeof(bits256),_bits256_cmp); strcat(fname,".all"); if ( (coin->fastfps[i]= fopen(fname,"wb")) != 0 ) { - num = (int32_t)allocsize/sizeof(bits256); tablesize = (num << 1); hashtable = calloc(sizeof(*hashtable),tablesize); for (ind=1; ind<=num; ind++) @@ -853,7 +853,8 @@ int64_t iguana_fastfindinit(struct iguana_info *coin) memcpy(&buf[sizeof(uint64_t) + sizeof(uint16_t)],&hash2.ushorts[13],sizeof(hash2.ushorts[13])); memcpy(&buf[sizeof(uint64_t) + sizeof(uint16_t) + sizeof(hash2.ushorts[13])],&hash2.uints[7],sizeof(hash2.uints[7])); fwrite(buf,1,sizeof(buf),coin->fastfps[i]); - hash2 = sortbuf[j-1]; + if ( j < num ) + hash2 = sortbuf[j]; } if ( fwrite(hashtable,sizeof(*hashtable),tablesize,coin->fastfps[i]) == tablesize ) { diff --git a/iguana/main.c b/iguana/main.c index 361925d15..75b64fed6 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -1146,7 +1146,7 @@ void iguana_appletests(struct supernet_info *myinfo) exit(-1); } sleep(1);*/ - if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"prefetchlag\":-1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":500,\"endpend\":500,\"services\":128,\"maxpeers\":64,\"newcoin\":\"BTC\",\"active\":1,\"numhelpers\":4,\"poll\":1}"),0,myinfo->rpcport)) != 0 ) + if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"prefetchlag\":-1,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":500,\"endpend\":500,\"services\":128,\"maxpeers\":64,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":1}"),0,myinfo->rpcport)) != 0 ) { free(str); if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":1024,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1}"),0,myinfo->rpcport)) != 0 )