Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
jl777 committed May 21, 2015
1 parent 81e7caf commit b24d663
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
2 changes: 1 addition & 1 deletion libjl777/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 ..; \
Expand Down
3 changes: 2 additions & 1 deletion libjl777/plugins/plugin777.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 2 additions & 2 deletions libjl777/plugins/ramchain/ledger777.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
8 changes: 5 additions & 3 deletions libjl777/plugins/ramchain/ramchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -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; i<addrinfo->count; i++)
{
sum += addrinfo->unspents[i].value;
if ( verbose == 0 )
{
item = cJSON_CreateArray();
Expand All @@ -386,22 +387,23 @@ 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));
}
cJSON_AddItemToArray(array,item);
}
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 )
Expand Down
4 changes: 2 additions & 2 deletions libjl777/plugins/ramchain/ramchain_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions libjl777/plugins/relays777.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:"<big string>",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:"<big string>",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);
Expand Down

0 comments on commit b24d663

Please sign in to comment.