test
This commit is contained in:
31
src/komodo.h
31
src/komodo.h
@@ -23,7 +23,7 @@
|
||||
#include <pthread.h>
|
||||
#include <ctype.h>
|
||||
|
||||
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals);
|
||||
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight);
|
||||
void komodo_init();
|
||||
int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp);
|
||||
char *komodo_issuemethod(char *method,char *params,uint16_t port);
|
||||
@@ -43,7 +43,7 @@ char KMDUSERPASS[1024]; uint16_t BITCOIND_PORT = 7771;
|
||||
#include "komodo_notary.h"
|
||||
#include "komodo_gateway.h"
|
||||
|
||||
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals)
|
||||
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t KMDheight)
|
||||
{
|
||||
static FILE *fp; static int32_t errs; char fname[512]; int32_t ht,func; uint8_t num,pubkeys[64][33];
|
||||
#ifdef WIN32
|
||||
@@ -97,6 +97,17 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
|
||||
errs++;
|
||||
komodo_nutxoadd(ht,nid,hash,mask,n);
|
||||
}
|
||||
else if ( func == 'K' )
|
||||
{
|
||||
int32_t kheight;
|
||||
if ( fread(&kheight,1,sizeof(kheight),fp) != sizeof(kheight) )
|
||||
errs++;
|
||||
if ( kheight > KMDHEIGHT )
|
||||
{
|
||||
KMDHEIGHT = kheight;
|
||||
printf("KMDHEIGHT <- %d\n",kheight);
|
||||
}
|
||||
}
|
||||
else if ( func == 'D' )
|
||||
{
|
||||
//printf("D[%d]\n",ht);
|
||||
@@ -128,6 +139,14 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
|
||||
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
|
||||
errs++;
|
||||
}
|
||||
else if ( KMDheight > 0 )
|
||||
{
|
||||
fputc('K',fp);
|
||||
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
|
||||
errs++;
|
||||
if ( fwrite(&KMDheight,1,sizeof(KMDheight),fp) != sizeof(KMDheight) )
|
||||
errs++;
|
||||
}
|
||||
else if ( notarypubs != 0 && numnotaries > 0 )
|
||||
{
|
||||
//printf("func P[%d] errs.%d\n",numnotaries,errs);
|
||||
@@ -244,7 +263,7 @@ int32_t komodo_voutupdate(int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,
|
||||
NOTARIZED_HEIGHT = *notarizedheightp;
|
||||
NOTARIZED_HASH = kmdtxid;
|
||||
NOTARIZED_DESTTXID = desttxid;
|
||||
komodo_stateupdate(height,0,0,0,zero,0,0,0,0);
|
||||
komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0);
|
||||
} else printf("reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",height,*notarizedheightp,KOMODO_SOURCE,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]);
|
||||
}
|
||||
#ifdef KOMODO_PAX
|
||||
@@ -252,7 +271,7 @@ int32_t komodo_voutupdate(int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,
|
||||
{
|
||||
double KMDBTC,BTCUSD,CNYUSD; uint32_t numpvals,timestamp,pvals[128];
|
||||
numpvals = dpow_readprices(&scriptbuf[++len],×tamp,&KMDBTC,&BTCUSD,&CNYUSD,pvals);
|
||||
komodo_stateupdate(height,0,0,0,zero,0,0,pvals,numpvals);
|
||||
komodo_stateupdate(height,0,0,0,zero,0,0,pvals,numpvals,0);
|
||||
printf("vout OP_RETURN.%d prices numpvals.%d opretlen.%d\n",height,numpvals,opretlen);
|
||||
}
|
||||
#endif
|
||||
@@ -315,7 +334,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
}
|
||||
if ( i != 0 && notaryid >= 0 && notaryid < 64 && voutmask != 0 )
|
||||
{
|
||||
komodo_stateupdate(height,0,0,notaryid,txhash,voutmask,numvouts,0,0);
|
||||
komodo_stateupdate(height,0,0,notaryid,txhash,voutmask,numvouts,0,0,0);
|
||||
//komodo_nutxoadd(height,notaryid,txhash,voutmask,numvouts);
|
||||
}
|
||||
signedmask = 0;
|
||||
@@ -356,7 +375,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
||||
if ( komodo_isratify(1,numvalid) > 13 )
|
||||
{
|
||||
memset(&txhash,0,sizeof(txhash));
|
||||
komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0);
|
||||
komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0);
|
||||
}
|
||||
printf("new notaries.%d newheight.%d from height.%d\n",numvouts-1,KOMODO_PUBKEYS_HEIGHT(height),height);
|
||||
}
|
||||
|
||||
@@ -113,7 +113,7 @@ int32_t komodo_gateway_block(char *symbol,int32_t height,uint16_t port)
|
||||
|
||||
void komodo_gateway_iteration(char *symbol)
|
||||
{
|
||||
char *retstr; int32_t i,kmdheight; cJSON *infoobj,*result; uint16_t port = 7771;
|
||||
char *retstr; int32_t i,kmdheight; cJSON *infoobj,*result; uint256 zero; uint16_t port = 7771;
|
||||
if ( KMDHEIGHT <= 0 )
|
||||
KMDHEIGHT = 1;
|
||||
if ( (retstr= komodo_issuemethod((char *)"getinfo",0,port)) != 0 )
|
||||
@@ -125,7 +125,11 @@ void komodo_gateway_iteration(char *symbol)
|
||||
for (i=0; i<10 && KMDHEIGHT<kmdheight; i++,KMDHEIGHT++)
|
||||
{
|
||||
if ( (KMDHEIGHT % 100) == 0 )
|
||||
{
|
||||
fprintf(stderr,"%s.%d ",symbol,KMDHEIGHT);
|
||||
memset(&zero,0,sizeof(zero));
|
||||
komodo_stateupdate(0,0,0,0,zero,0,0,0,0,KMDHEIGHT);
|
||||
}
|
||||
if ( komodo_gateway_block(symbol,KMDHEIGHT,port) < 0 )
|
||||
break;
|
||||
usleep(10000);
|
||||
@@ -137,7 +141,7 @@ void komodo_gateway_iteration(char *symbol)
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("error from %s\n",symbol);
|
||||
//printf("error from %s\n",symbol);
|
||||
sleep(30);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,6 +211,6 @@ void komodo_init()
|
||||
}
|
||||
komodo_notarysinit(0,pubkeys,k);
|
||||
memset(&zero,0,sizeof(zero));
|
||||
komodo_stateupdate(0,0,0,0,zero,0,0,0,0);
|
||||
komodo_stateupdate(0,0,0,0,zero,0,0,0,0,0);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user