From a0b9382cb9bccf94aec0a72658406d43ade9c885 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 23 Oct 2017 12:10:22 +0300 Subject: [PATCH] Test --- src/komodo.h | 4 ++-- src/komodo_bitcoind.h | 12 ++++++++---- src/komodo_notary.h | 32 +++++++++++++++++++++++++++----- src/komodo_structs.h | 2 +- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 2687e2add..0395f3d65 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -549,8 +549,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) (numvalid >= KOMODO_MINRATIFY && ASSETCHAINS_SYMBOL[0] != 0) || numvalid > (numnotaries/5)) ) { - if ( height > 500000 ) - printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); + if ( height > 500000 || ASSETCHAINS_SYMBOL[0] != 0 ) + printf("[%s] ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); notarized = 1; } if ( NOTARY_PUBKEY33[0] != 0 && ASSETCHAINS_SYMBOL[0] == 0 ) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 5be8da5e2..e040a4a09 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -427,15 +427,18 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t sprintf(params,"[\"%s\", 1]",NOTARIZED_DESTTXID.ToString().c_str()); if ( strcmp(symbol,ASSETCHAINS_SYMBOL[0]==0?(char *)"KMD":ASSETCHAINS_SYMBOL) != 0 ) return(0); - //printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",ASSETCHAINS_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + printf("[%s] src.%s dest.%s params.[%s] ht.%d notarized.%d\n",ASSETCHAINS_SYMBOL,symbol,dest,params,height,NOTARIZED_HEIGHT); if ( strcmp(dest,"KMD") == 0 ) { if ( KMDUSERPASS[0] != 0 ) { if ( ASSETCHAINS_SYMBOL[0] != 0 ) + { jsonstr = komodo_issuemethod(KMDUSERPASS,(char *)"getrawtransaction",params,7771); - } - //else jsonstr = _dex_getrawtransaction(); +printf("got (%s)\n",jsonstr); + } + }//else jsonstr = _dex_getrawtransaction(); else return(0); // need universal way to issue DEX* API, since notaries mine most blocks, this ok } else if ( strcmp(dest,"BTC") == 0 ) @@ -460,7 +463,8 @@ int32_t komodo_verifynotarization(char *symbol,char *dest,int32_t height,int32_t if ( (txjson= jobj(json,(char *)"result")) != 0 && (vouts= jarray(&n,txjson,(char *)"vout")) > 0 ) { vout = jitem(vouts,n-1); - //printf("vout.(%s)\n",jprint(vout,0)); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + printf("vout.(%s)\n",jprint(vout,0)); if ( (skey= jobj(vout,(char *)"scriptPubKey")) != 0 ) { if ( (hexstr= jstr(skey,(char *)"hex")) != 0 ) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index e47638c8e..28ea470c0 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -320,26 +320,48 @@ int32_t komodo_notarized_height(uint256 *hashp,uint256 *txidp) int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) { - struct notarized_checkpoint *np = 0; int32_t i; char symbol[16],dest[16]; struct komodo_state *sp; + struct notarized_checkpoint *np = 0; int32_t i,flag = 0; char symbol[16],dest[16]; struct komodo_state *sp; if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) { if ( sp->NUM_NPOINTS > 0 ) { - for (i=0; iNUM_NPOINTS; i++) + flag = 0; + if ( sp->last_NPOINTSi < sp->NUM_POINTS && sp->last_NPOINTSi > 0 ) { - if ( sp->NPOINTS[i].nHeight >= nHeight ) - break; - np = &sp->NPOINTS[i]; + np = &sp->NPOINTS[sp->last_NPOINTSi-1]; + for (i=sp->last_NPOINTSi; iNUM_NPOINTS; i++) + { + if ( sp->NPOINTS[i].nHeight >= nHeight ) + { + flag = 1; + break; + } + np = &sp->NPOINTS[i]; + sp->last_NPOINTSi = i; + } + } + if ( flag == 0 ) + { + np = 0; + for (i=0; iNUM_NPOINTS; i++) + { + if ( sp->NPOINTS[i].nHeight >= nHeight ) + break; + np = &sp->NPOINTS[i]; + sp->last_NPOINTSi = i; + } } } if ( np != 0 ) { + char str[65],str2[65]; printf("[%s] notarized_ht.%d %s -> %s\n",ASSETCHAINS_SYMBOL,np->notarized_height,bits256_str(str,np->notarized_hash),bits256_str(str2,np->notarized_desttxid)); *notarized_hashp = np->notarized_hash; *notarized_desttxidp = np->notarized_desttxid; return(np->notarized_height); } } memset(notarized_hashp,0,sizeof(*notarized_hashp)); + memset(notarized_desttxidp,0,sizeof(*notarized_desttxidp)); return(0); } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 510a7e488..8db0a6f43 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -84,7 +84,7 @@ struct komodo_state int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT; uint32_t SAVEDTIMESTAMP; uint64_t deposited,issued,withdrawn,approved,redeemed,shorted; - struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS; + struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS,last_NPOINTSi; struct komodo_event **Komodo_events; int32_t Komodo_numevents; uint32_t RTbufs[64][3]; uint64_t RTmask; };