From b24d663b181c95c53dffbe2f512220c4f1c8bf69 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 21 May 2015 12:14:41 +0300 Subject: [PATCH] test --- libjl777/Makefile | 2 +- libjl777/plugins/plugin777.c | 3 ++- libjl777/plugins/ramchain/ledger777.c | 4 ++-- libjl777/plugins/ramchain/ramchain.c | 8 +++++--- libjl777/plugins/ramchain/ramchain_main.c | 4 ++-- libjl777/plugins/relays777.c | 4 ++-- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/libjl777/Makefile b/libjl777/Makefile index 20fed6bf..18a2b9bc 100644 --- a/libjl777/Makefile +++ b/libjl777/Makefile @@ -227,7 +227,7 @@ patch2: doesntexist; \ #cd ..; \ dependencies: doesntexist; \ - sudo apt-get install make clang-3.5 autoconf libtool libcurl4-gnutls-dev unzip autogen g++ libssl-dev libdb++-dev libminiupnpc-dev libboost-all-dev; + sudo apt-get install make clang-3.4 autoconf libtool libcurl4-gnutls-dev unzip autogen g++ libssl-dev libdb++-dev libminiupnpc-dev libboost-all-dev; onetime: doesntexist; \ cd nanomsg; ./autogen.sh; ./configure; make; cd ..; \ diff --git a/libjl777/plugins/plugin777.c b/libjl777/plugins/plugin777.c index 463d2296..39d86ae7 100644 --- a/libjl777/plugins/plugin777.c +++ b/libjl777/plugins/plugin777.c @@ -241,7 +241,8 @@ static int32_t process_plugin_json(char *retbuf,int32_t max,int32_t *sendflagp,s if ( retbuf[0] == 0 ) sprintf(retbuf,"{\"result\":\"no response\"}"); append_stdfields(retbuf,max,plugin,tag,0); - printf("return.(%s)\n",retbuf); + if ( Debuglevel > 2 ) + printf("return.(%s)\n",retbuf); return((int32_t)strlen(retbuf)); } else printf("(%s) -> no return.%d (%s) vs (%s) len.%d\n",jsonstr,strcmp(name,plugin->name),name,plugin->name,len); } diff --git a/libjl777/plugins/ramchain/ledger777.c b/libjl777/plugins/ramchain/ledger777.c index 2aa05b80..13cc73bf 100644 --- a/libjl777/plugins/ramchain/ledger777.c +++ b/libjl777/plugins/ramchain/ledger777.c @@ -432,14 +432,14 @@ int32_t ledger_unspentmap(char *txidstr,struct ledger_info *ledger,uint32_t unsp probe = (floor + ceiling) >> 1; if ( (firstvout= ledger_firstvout(1,ledger,probe)) == 0 || (lastvout= ledger_firstvout(1,ledger,probe+1)) == 0 ) break; - printf("search %u, probe.%u (%u %u) floor.%u ceiling.%u\n",unspentind,probe,firstvout,lastvout,floor,ceiling); + //printf("search %u, probe.%u (%u %u) floor.%u ceiling.%u\n",unspentind,probe,firstvout,lastvout,floor,ceiling); if ( unspentind < firstvout ) ceiling = probe; else if ( unspentind >= lastvout ) floor = probe; else { - printf("found match! txidind.%u\n",probe); + //printf("found match! txidind.%u\n",probe); if ( ledger_txidstr(ledger,txidstr,255,probe) == 0 ) return(unspentind - firstvout); else break; diff --git a/libjl777/plugins/ramchain/ramchain.c b/libjl777/plugins/ramchain/ramchain.c index 5850f141..c2d0caf6 100644 --- a/libjl777/plugins/ramchain/ramchain.c +++ b/libjl777/plugins/ramchain/ramchain.c @@ -369,13 +369,14 @@ int32_t ramchain_unspents(char *retbuf,int32_t maxlen,struct ramchain *ramchain, { int32_t ledger_unspentmap(char *txidstr,struct ledger_info *ledger,uint32_t unspentind); //struct ledger_addrinfo { uint64_t balance; uint32_t firstblocknum,count:28,notify:1,pending:1,MGW:1,dirty:1; struct unspentmap unspents[]; }; - struct ledger_addrinfo *addrinfo; cJSON *json,*array,*item; int32_t i,vout,verbose; char *jsonstr,script[8193],txidstr[256],field[256]; + struct ledger_addrinfo *addrinfo; cJSON *json,*array,*item; uint64_t sum = 0; int32_t i,vout,verbose; char *jsonstr,script[8193],txidstr[256],field[256]; if ( (addrinfo= ramchain_addrinfo(field,retbuf,maxlen,ramchain,argjson)) == 0 ) return(-1); verbose = get_API_int(cJSON_GetObjectItem(argjson,"verbose"),0); json = cJSON_CreateObject(), array = cJSON_CreateArray(); for (i=0; icount; i++) { + sum += addrinfo->unspents[i].value; if ( verbose == 0 ) { item = cJSON_CreateArray(); @@ -386,14 +387,13 @@ int32_t ramchain_unspents(char *retbuf,int32_t maxlen,struct ramchain *ramchain, else { item = cJSON_CreateObject(); - cJSON_AddItemToObject(item,"addr",cJSON_CreateString(field)); cJSON_AddItemToObject(item,"value",cJSON_CreateNumber(dstr(addrinfo->unspents[i].value))); if ( (vout= ledger_unspentmap(txidstr,ramchain->activeledger,addrinfo->unspents[i].ind)) >= 0 ) { cJSON_AddItemToObject(item,"txid",cJSON_CreateString(txidstr)); cJSON_AddItemToObject(item,"vout",cJSON_CreateNumber(vout)); } - else cJSON_AddItemToObject(item,"unspentind",cJSON_CreateNumber(addrinfo->unspents[i].ind)); + cJSON_AddItemToObject(item,"unspentind",cJSON_CreateNumber(addrinfo->unspents[i].ind)); ledger_scriptstr(ramchain->activeledger,script,sizeof(script),addrinfo->unspents[i].scriptind); cJSON_AddItemToObject(item,"script",cJSON_CreateString(script)); } @@ -401,7 +401,9 @@ int32_t ramchain_unspents(char *retbuf,int32_t maxlen,struct ramchain *ramchain, } cJSON_AddItemToObject(json,"unspents",array); cJSON_AddItemToObject(json,"count",cJSON_CreateNumber(addrinfo->count)); + cJSON_AddItemToObject(json,"addr",cJSON_CreateString(field)); cJSON_AddItemToObject(json,"balance",cJSON_CreateNumber(dstr(addrinfo->balance))); + cJSON_AddItemToObject(json,"sum",cJSON_CreateNumber(dstr(sum))); if ( addrinfo->notify != 0 ) cJSON_AddItemToObject(json,"notify",cJSON_CreateNumber(1)); if ( addrinfo->pending != 0 ) diff --git a/libjl777/plugins/ramchain/ramchain_main.c b/libjl777/plugins/ramchain/ramchain_main.c index 08748f4a..a02bd1a9 100644 --- a/libjl777/plugins/ramchain/ramchain_main.c +++ b/libjl777/plugins/ramchain/ramchain_main.c @@ -102,8 +102,8 @@ int32_t PLUGNAME(_process_json)(struct plugin_info *plugin,uint64_t tag,char *re ramchain_init(retbuf,maxlen,&coin->ramchain,json,coinstr,coin->serverport,coin->userpass,startblocknum,endblocknum,coin->minconfirms); else if ( coin->ramchain.activeledger != 0 ) ramchain_func(retbuf,maxlen,&coin->ramchain,json,methodstr); - else sprintf(retbuf,"{\"result\":\"no active ramchain\"}"); - printf("RAMCHAIN RETURNS.(%s)\n",retbuf); + //else sprintf(retbuf,"{\"result\":\"no active ramchain\"}"); + //printf("RAMCHAIN RETURNS.(%s)\n",retbuf); } } return((int32_t)strlen(retbuf)); diff --git a/libjl777/plugins/relays777.c b/libjl777/plugins/relays777.c index aa29ca14..cf7a2bc1 100644 --- a/libjl777/plugins/relays777.c +++ b/libjl777/plugins/relays777.c @@ -495,8 +495,8 @@ char *nn_publish(char *publishstr,int32_t nostr) { len = (int32_t)strlen(publishstr) + 1; if ( (sendlen= nn_send(RELAYS.pubsock,publishstr,len,0)) != len ) - printf("add_relay_connections warning: send.%d vs %d for (%s) sock.%d %s\n",sendlen,len,publishstr,RELAYS.pubsock,nn_errstr()); - else printf("published.(%s) %d bytes\n",len<1024?publishstr:"",len); + printf("nn_publish warning: send.%d vs %d for (%s) sock.%d %s\n",sendlen,len,publishstr,RELAYS.pubsock,nn_errstr()); + else printf("nn_publish.(%s) %d bytes\n",len<1024?publishstr:"",len); sprintf(retbuf,"{\"result\":\"published\",\"len\":%d,\"sendlen\":%d,\"crc\":%u}",len,sendlen,_crc32(0,publishstr,(int32_t)strlen(publishstr))); if ( nostr != 0 ) return(0);