Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
74ddba9a36
  1. 60
      iguana/databases/cdb-0.75/cdb_make.c
  2. 88
      iguana/databases/iguana_DB.c
  3. 2
      iguana/iguana.sources
  4. 4
      iguana/iguana_unspents.c
  5. 2
      iguana/m_unix

60
iguana/databases/cdb-0.75/cdb_make.c

@ -154,63 +154,3 @@ int cdb_make_finish(struct cdb_make *c)
return buffer_putflush(&c->b,c->final,sizeof c->final);
}
#include "../../../includes/cJSON.h"
int32_t cdb_jsonmake(struct cdb_make c,cJSON *array,char *dest,char *tmpname)
{
uint32_t klen,dlen,i,n,h; char *field,*value; int32_t fd; cJSON *item;
if ( (fd= open_trunc(tmpname)) == -1 )
return(-1);
if ( cdb_make_start(&c,fd) == -1 )
{
close(fd);
return(-2);
}
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
{
item = jitem(array,i);
if ( (field= jfieldname(item)) != 0 && (klen= str_len(field)) > 0)
{
value = jprint(item,0);
if ( (dlen= str_len(value)) > 0 )
{
if ( klen > 429496720 || dlen > 429496720 || cdb_make_addbegin(&c,klen,dlen) == -1 )
{
close(fd);
free(value);
return(-3);
}
h = CDB_HASHSTART;
for (i=0; i<klen; i++)
{
if ( buffer_PUTC(&c.b,field[i]) == -1)
{
close(fd);
free(value);
return(-3);
}
h = cdb_hashadd(h,field[i]);
}
for (i=0; i<dlen; i++)
{
if ( buffer_PUTC(&c.b,value[i]) == -1 )
break;
}
if ( i != dlen || cdb_make_addend(&c,klen,dlen,h) == -1 )
{
close(fd);
free(value);
return(-4);
}
}
free(value);
}
}
}
if ( cdb_make_finish(&c) == -1 || fsync(fd) == -1 || close(fd) == -1 )
return(-5);
if ( rename(tmpname,dest) == -1 )
return(-6);
return(0);
}

88
iguana/databases/iguana_DB.c

@ -0,0 +1,88 @@
/******************************************************************************
* Copyright © 2014-2016 The SuperNET Developers. *
* *
* See the AUTHORS, DEVELOPER-AGREEMENT and LICENSE files at *
* the top-level directory of this distribution for the individual copyright *
* holder information and the developer policies on copyright and licensing. *
* *
* Unless otherwise agreed in a custom licensing agreement, no part of the *
* SuperNET software, including this file may be copied, modified, propagated *
* or distributed except according to the terms contained in the LICENSE file *
* *
* Removal or modification of this copyright notice is prohibited. *
* *
******************************************************************************/
#include "../../includes/cJSON.h"
#include "cdb-0.75/alloc.c"
#include "cdb-0.75/buffer.c"
#include "cdb-0.75/buffer_copy.c"
#include "cdb-0.75/buffer_put.c"
#include "cdb-0.75/buffer_get.c"
#include "cdb-0.75/byte_copy.c"
#include "cdb-0.75/byte_cr.c"
#include "cdb-0.75/byte_diff.c"
#include "cdb-0.75/cdb.c"
#include "cdb-0.75/cdb_hash.c"
#include "cdb-0.75/cdb_make.c"
int32_t cdb_jsonmake(cJSON *array,char *dest,char *tmpname)
{
uint32_t klen,dlen,i,n,h; char *field,*value; int32_t fd; cJSON *item; struct cdb_make cdb;
memset(&cdb,0,sizeof(cdb));
if ( (fd= open_trunc(tmpname)) == -1 )
return(-1);
if ( cdb_make_start(&cdb,fd) == -1 )
{
close(fd);
return(-2);
}
if ( (n= cJSON_GetArraySize(array)) > 0 )
{
for (i=0; i<n; i++)
{
item = jitem(array,i);
if ( (field= jfieldname(item)) != 0 && (klen= str_len(field)) > 0)
{
value = jprint(item,0);
if ( (dlen= str_len(value)) > 0 )
{
if ( klen > 429496720 || dlen > 429496720 || cdb_make_addbegin(&cdb,klen,dlen) == -1 )
{
close(fd);
free(value);
return(-3);
}
h = CDB_HASHSTART;
for (i=0; i<klen; i++)
{
if ( buffer_PUTC(&cdb.b,field[i]) == -1)
{
close(fd);
free(value);
return(-3);
}
h = cdb_hashadd(h,field[i]);
}
for (i=0; i<dlen; i++)
{
if ( buffer_PUTC(&cdb.b,value[i]) == -1 )
break;
}
if ( i != dlen || cdb_make_addend(&cdb,klen,dlen,h) == -1 )
{
close(fd);
free(value);
return(-4);
}
}
free(value);
}
}
}
if ( cdb_make_finish(&cdb) == -1 || fsync(fd) == -1 || close(fd) == -1 )
return(-5);
if ( rename(tmpname,dest) == -1 )
return(-6);
return(0);
}

2
iguana/iguana.sources

@ -2,4 +2,4 @@
#SOURCES := iguana_rpc.c SuperNET.c SuperNET_keys.c SuperNET_category.c SuperNET_hexmsg.c iguana_exchanges.c iguana_tradebots.c iguana_instantdex.c pangea_api.c pangea_bets.c cards777.c pangea_summary.c pangea_json.c pangea_hand.c poker.c ramchain_api.c iguana_tx.c iguana_wallet.c iguana_scripts.c iguana_pubkeys.c iguana_unspents.c iguana_recv.c iguana_bundles.c iguana_msg.c iguana777.c iguana_chains.c iguana_peers.c iguana_accept.c iguana_bitmap.c iguana_init.c iguana_ramchain.c iguana_blocks.c iguana_json.c main.c peggy.c peggy_consensus.c peggy_price.c peggy_update.c peggy_accts.c peggy_tx.c peggy_txind.c peggy_ramkv.c peggy_serdes.c
SOURCES := SuperNET.c iguana_bundles.c iguana_pubkeys.c main.c peggy_price.c SuperNET_category.c iguana_chains.c iguana_ramchain.c pangea_api.c peggy_ramkv.c SuperNET_hexmsg.c iguana_exchanges.c iguana_recv.c pangea_bets.c peggy_serdes.c SuperNET_keys.c iguana_html.c iguana_rpc.c pangea_hand.c peggy_tx.c cards777.c iguana_init.c iguana_scripts.c pangea_json.c peggy_txind.c iguana777.c iguana_instantdex.c iguana_tradebots.c pangea_summary.c peggy_update.c iguana_accept.c iguana_json.c iguana_tx.c peggy.c poker.c iguana_bitmap.c iguana_msg.c iguana_unspents.c peggy_accts.c ramchain_api.c iguana_blocks.c iguana_peers.c iguana_wallet.c peggy_consensus.c
SOURCES := SuperNET.c iguana_bundles.c iguana_pubkeys.c main.c peggy_price.c SuperNET_category.c iguana_chains.c iguana_ramchain.c pangea_api.c peggy_ramkv.c SuperNET_hexmsg.c iguana_exchanges.c iguana_recv.c pangea_bets.c peggy_serdes.c SuperNET_keys.c iguana_html.c iguana_rpc.c pangea_hand.c peggy_tx.c cards777.c iguana_init.c iguana_scripts.c pangea_json.c peggy_txind.c iguana777.c iguana_instantdex.c iguana_tradebots.c pangea_summary.c peggy_update.c iguana_accept.c iguana_json.c iguana_tx.c peggy.c poker.c iguana_bitmap.c iguana_msg.c iguana_unspents.c peggy_accts.c ramchain_api.c iguana_blocks.c iguana_peers.c iguana_wallet.c peggy_consensus.c databases/iguana_DB.c

4
iguana/iguana_unspents.c

@ -2360,7 +2360,7 @@ void iguana_RTspendvectors(struct iguana_info *coin,struct iguana_bundle *bp)
}
else
{
printf("spendvectors calculated to %d [%d]\n",coin->RTheight,bp->hdrsi);
printf("RTspendvectors calculated to %d [%d]\n",coin->RTheight,bp->hdrsi);
bp->converted = 1;
for (hdrsi=num=0; hdrsi<bp->hdrsi; hdrsi++)
{
@ -2373,7 +2373,7 @@ void iguana_RTspendvectors(struct iguana_info *coin,struct iguana_bundle *bp)
#endif
num += iguana_convert(coin,IGUANA_NUMHELPERS,coin->bundles[hdrsi],1,orignumemit);
}
printf("spendvectors converted.%d to %d\n",num,coin->RTheight);
printf("RTspendvectors converted.%d to %d\n",num,coin->RTheight);
bp->converted = (uint32_t)time(NULL);
if ( iguana_balancegen(coin,1,bp,coin->RTstarti,coin->RTheight > 0 ? coin->RTheight-1 : bp->n-1,orignumemit) < 0 )
coin->RTdatabad = 1;

2
iguana/m_unix

@ -1,6 +1,6 @@
#./configure --enable-endomorphism --enable-module-ecdh --enable-module-schnorr --enable-module-rangeproof --enable-experimental
rm ../agents/iguana
git pull
gcc -g -Wno-deprecated -c -O2 *.c
gcc -g -Wno-deprecated -c -O2 *.c databases/iguana_DB.c
gcc -g -Wno-deprecated -c main.c iguana777.c iguana_bundles.c
gcc -g -o ../agents/iguana *.o ../agents/libcrypto777.a -lcurl -lssl -lcrypto -lpthread -lm ../includes/libsecp256k1.a -lgmp

Loading…
Cancel
Save