Browse Source

test

etomic
jl777 8 years ago
parent
commit
47b838ac5a
  1. 5
      crypto777/bitcoind_RPC.c
  2. 3
      iguana/dPoW.h
  3. 50
      iguana/dpow/dpow_network.c

5
crypto777/bitcoind_RPC.c

@ -91,8 +91,11 @@ char *post_process_bitcoind_RPC(char *debugstr,char *command,char *rpcstr,char *
{ {
if ( strcmp(command,"signrawtransaction") != 0 ) if ( strcmp(command,"signrawtransaction") != 0 )
printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC (%s) error.%s\n",debugstr,command,rpcstr); printf("<<<<<<<<<<< bitcoind_RPC: %s post_process_bitcoind_RPC (%s) error.%s\n",debugstr,command,rpcstr);
retstr = rpcstr;
rpcstr = 0;
} }
free(rpcstr); if ( rpcstr != 0 )
free(rpcstr);
} else retstr = rpcstr; } else retstr = rpcstr;
free_json(json); free_json(json);
//fprintf(stderr,"<<<<<<<<<<< bitcoind_RPC: postprocess returns.(%s)\n",retstr); //fprintf(stderr,"<<<<<<<<<<< bitcoind_RPC: postprocess returns.(%s)\n",retstr);

3
iguana/dPoW.h

@ -143,7 +143,6 @@ int32_t dpow_paxpending(uint8_t *hex,uint32_t *paxwdcrcp);
void dex_updateclient(struct supernet_info *myinfo); void dex_updateclient(struct supernet_info *myinfo);
char *dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32_t datalen); char *dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32_t datalen);
char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int32_t keylen,uint8_t *data,int32_t datalen,int32_t sendping,uint32_t duration); char *basilisk_respond_addmessage(struct supernet_info *myinfo,uint8_t *key,int32_t keylen,uint8_t *data,int32_t datalen,int32_t sendping,uint32_t duration);
cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout);
int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *blockhashp,uint32_t *blocktimep,bits256 *txs,uint32_t *numtxp,struct iguana_info *coin); int32_t dpow_getchaintip(struct supernet_info *myinfo,bits256 *blockhashp,uint32_t *blocktimep,bits256 *txs,uint32_t *numtxp,struct iguana_info *coin);
void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen); void dpow_send(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen);
int32_t dpow_nanomsg_update(struct supernet_info *myinfo); int32_t dpow_nanomsg_update(struct supernet_info *myinfo);
@ -154,6 +153,7 @@ cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits2
bits256 dpow_getblockhash(struct supernet_info *myinfo,struct iguana_info *coin,int32_t height); bits256 dpow_getblockhash(struct supernet_info *myinfo,struct iguana_info *coin,int32_t height);
bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *coin); bits256 dpow_getbestblockhash(struct supernet_info *myinfo,struct iguana_info *coin);
char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx); char *dpow_sendrawtransaction(struct supernet_info *myinfo,struct iguana_info *coin,char *signedtx);
cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t vout);
char *_dex_getinfo(struct supernet_info *myinfo,char *symbol); char *_dex_getinfo(struct supernet_info *myinfo,char *symbol);
char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 txid); char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 txid);
@ -161,5 +161,6 @@ char *_dex_getblock(struct supernet_info *myinfo,char *symbol,bits256 hash2);
char *_dex_getblockhash(struct supernet_info *myinfo,char *symbol,int32_t height); char *_dex_getblockhash(struct supernet_info *myinfo,char *symbol,int32_t height);
char *_dex_getbestblockhash(struct supernet_info *myinfo,char *symbol); char *_dex_getbestblockhash(struct supernet_info *myinfo,char *symbol);
char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *signedtx); char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *signedtx);
char *_dex_gettxout(struct supernet_info *myinfo,char *symbol,bits256 txid,int32_t vout);
#endif #endif

50
iguana/dpow/dpow_network.c

@ -186,7 +186,7 @@ char *dex_reqsend(struct supernet_info *myinfo,char *handler,uint8_t *data,int32
return(retstr); return(retstr);
} }
struct dex_request { bits256 hash; int32_t height; char name[15]; uint8_t func; }; struct dex_request { bits256 hash; int32_t height; uint16_t vout; char name[15]; uint8_t func; };
int32_t dex_rwrequest(int32_t rwflag,uint8_t *serialized,struct dex_request *dexreq) int32_t dex_rwrequest(int32_t rwflag,uint8_t *serialized,struct dex_request *dexreq)
{ {
@ -220,6 +220,11 @@ char *dex_response(struct supernet_info *myinfo,struct dex_nanomsghdr *dexp)
if ( (retjson= dpow_gettransaction(myinfo,coin,dexreq.hash)) != 0 ) if ( (retjson= dpow_gettransaction(myinfo,coin,dexreq.hash)) != 0 )
retstr = jprint(retjson,1); retstr = jprint(retjson,1);
} }
else if ( dexreq.func == 'O' )
{
if ( (retjson= dpow_gettxout(myinfo,coin,dexreq.hash,dexreq.vout)) != 0 )
retstr = jprint(retjson,1);
}
else if ( dexreq.func == 'H' ) else if ( dexreq.func == 'H' )
{ {
hash2 = dpow_getblockhash(myinfo,coin,dexreq.height); hash2 = dpow_getblockhash(myinfo,coin,dexreq.height);
@ -254,57 +259,70 @@ char *dex_response(struct supernet_info *myinfo,struct dex_nanomsghdr *dexp)
return(retstr); return(retstr);
} }
char *_dex_sendrequest(struct supernet_info *myinfo,struct dex_request *dexreq)
{
uint8_t packet[sizeof(dexreq)]; int32_t datalen;
datalen = dex_rwrequest(1,packet,dexreq);
return(dex_reqsend(myinfo,"request",packet,datalen));
}
char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 txid) char *_dex_getrawtransaction(struct supernet_info *myinfo,char *symbol,bits256 txid)
{ {
struct dex_request dexreq; uint8_t packet[sizeof(dexreq)]; int32_t datalen; struct dex_request dexreq;
memset(&dexreq,0,sizeof(dexreq)); memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name)); safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.hash = txid; dexreq.hash = txid;
dexreq.func = 'T'; dexreq.func = 'T';
datalen = dex_rwrequest(1,packet,&dexreq); return(_dex_sendrequest(myinfo,&dexreq));
return(dex_reqsend(myinfo,"request",packet,datalen)); }
char *_dex_gettxout(struct supernet_info *myinfo,char *symbol,bits256 txid,int32_t vout)
{
struct dex_request dexreq;
memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.hash = txid;
dexreq.vout = vout;
dexreq.func = 'O';
return(_dex_sendrequest(myinfo,&dexreq));
} }
char *_dex_getinfo(struct supernet_info *myinfo,char *symbol) char *_dex_getinfo(struct supernet_info *myinfo,char *symbol)
{ {
struct dex_request dexreq; uint8_t packet[sizeof(dexreq)]; int32_t datalen; struct dex_request dexreq;
memset(&dexreq,0,sizeof(dexreq)); memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name)); safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.func = 'I'; dexreq.func = 'I';
datalen = dex_rwrequest(1,packet,&dexreq); return(_dex_sendrequest(myinfo,&dexreq));
return(dex_reqsend(myinfo,"request",packet,datalen));
} }
char *_dex_getblock(struct supernet_info *myinfo,char *symbol,bits256 hash2) char *_dex_getblock(struct supernet_info *myinfo,char *symbol,bits256 hash2)
{ {
struct dex_request dexreq; uint8_t packet[sizeof(dexreq)]; int32_t datalen; struct dex_request dexreq;
memset(&dexreq,0,sizeof(dexreq)); memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name)); safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.hash = hash2; dexreq.hash = hash2;
dexreq.func = 'B'; dexreq.func = 'B';
datalen = dex_rwrequest(1,packet,&dexreq); return(_dex_sendrequest(myinfo,&dexreq));
return(dex_reqsend(myinfo,"request",packet,datalen));
} }
char *_dex_getblockhash(struct supernet_info *myinfo,char *symbol,int32_t height) char *_dex_getblockhash(struct supernet_info *myinfo,char *symbol,int32_t height)
{ {
struct dex_request dexreq; uint8_t packet[sizeof(dexreq)]; int32_t datalen; struct dex_request dexreq;
memset(&dexreq,0,sizeof(dexreq)); memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name)); safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.height = height; dexreq.height = height;
dexreq.func = 'H'; dexreq.func = 'H';
datalen = dex_rwrequest(1,packet,&dexreq); return(_dex_sendrequest(myinfo,&dexreq));
return(dex_reqsend(myinfo,"request",packet,datalen));
} }
char *_dex_getbestblockhash(struct supernet_info *myinfo,char *symbol) char *_dex_getbestblockhash(struct supernet_info *myinfo,char *symbol)
{ {
struct dex_request dexreq; uint8_t packet[sizeof(dexreq)]; int32_t datalen; struct dex_request dexreq;
memset(&dexreq,0,sizeof(dexreq)); memset(&dexreq,0,sizeof(dexreq));
safecopy(dexreq.name,symbol,sizeof(dexreq.name)); safecopy(dexreq.name,symbol,sizeof(dexreq.name));
dexreq.func = 'P'; dexreq.func = 'P';
datalen = dex_rwrequest(1,packet,&dexreq); return(_dex_sendrequest(myinfo,&dexreq));
return(dex_reqsend(myinfo,"request",packet,datalen));
} }
char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *signedtx) char *_dex_sendrawtransaction(struct supernet_info *myinfo,char *symbol,char *signedtx)

Loading…
Cancel
Save