From 6f3cb4d03ac342f4f46cfbe17797b2dc23404068 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 18 Nov 2016 09:16:18 -0300 Subject: [PATCH] test --- src/komodo.h | 58 +++++++++++++++++++++++--------------------- src/komodo_events.h | 4 +-- src/komodo_globals.h | 2 +- src/komodo_notary.h | 4 +-- src/komodo_structs.h | 2 +- 5 files changed, 37 insertions(+), 33 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 320904725..b431bda48 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -117,8 +117,8 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char errs++; if ( fread(&hash,1,sizeof(hash),fp) != sizeof(hash) ) errs++; - if ( matched != 0 ) - komodo_eventadd_utxo(sp,symbol,ht,nid,hash,mask,n); + //if ( matched != 0 ) + // komodo_eventadd_utxo(sp,symbol,ht,nid,hash,mask,n); } else if ( func == 'K' ) { @@ -262,8 +262,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar errs++; if ( fwrite(&txhash,1,sizeof(txhash),fp) != sizeof(txhash) ) errs++; - komodo_eventadd_utxo(sp,symbol,height,notaryid,txhash,voutmask,numvouts); - //komodo_nutxoadd(height,notaryid,txhash,voutmask,numvouts); + //komodo_eventadd_utxo(sp,symbol,height,notaryid,txhash,voutmask,numvouts); } //#ifdef KOMODO_PAX else if ( pvals != 0 && numpvals > 0 ) @@ -407,15 +406,31 @@ int32_t komodo_isratify(int32_t isspecial,int32_t numvalid) // if txi == 0 && 2 outputs and 2nd OP_RETURN, len == 32*2+4 -> notarized, 1st byte 'P' -> pricefeed // OP_RETURN: 'D' -> deposit, 'W' -> withdraw void komodo_currentheight_set(int32_t height); +int32_t gettxout_scriptPubKey(uint8_t *scriptPubKey,int32_t maxsize,uint256 txid,int32_t n); + +int32_t komodo_notarycmp(uint8_t *scriptPubKey,int32_t scriptlen,uint8_t pubkeys[64][33],int32_t numnotaries,uint8_t rmd160[20]) +{ + int32_t i; + if ( scriptlen == 25 && memcmp(&scriptPubKey[3],rmd160,20) == 0 ) + return(0); + else if ( scriptlen == 35 ) + { + for (i=0; inHeight); numnotaries = komodo_notaries(pubkeys,pindex->nHeight); + calc_rmd160_sha256(rmd160,pubkeys[0],33); if ( pindex->nHeight > hwmheight ) hwmheight = pindex->nHeight; else @@ -437,8 +452,6 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) { height = pindex->nHeight; txn_count = block.vtx.size(); - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) - printf("%s ht.%d connect txn_count.%d\n",ASSETCHAINS_SYMBOL,height,txn_count); for (i=0; i= 0 ) - { - if ( height < sizeof(Minerids)/sizeof(*Minerids) ) - { - if ( (Minerids[height]= nid) >= -1 ) - { - if ( Minerfp != 0 ) - { - fseek(Minerfp,height,SEEK_SET); - fputc(Minerids[height],Minerfp); - fflush(Minerfp); - } - } - } - }*/ if ( 0 && i > 0 ) { for (k=0; k= 0 && notaryid < 64 && voutmask != 0 ) { - komodo_stateupdate(height,0,0,notaryid,txhash,voutmask,numvouts,0,0,0,0,0,0,0); - //komodo_nutxoadd(height,notaryid,txhash,voutmask,numvouts); + //komodo_stateupdate(height,0,0,notaryid,txhash,voutmask,numvouts,0,0,0,0,0,0,0); } signedmask = 0; numvins = block.vtx[i].vin.size(); for (j=0; j= 0 ) + if ( (scriptlen= gettxout_scriptPubKey(scriptPubKey,sizeof(scriptPubKey),block.vtx[i].vin[j].prevout.hash,block.vtx[i].vin[j].prevout.n)) > 0 ) + { + if ( (k= komodo_notarycmp(scriptPubKey,scriptlen,pubkeys,numnotaries,rmd160)) >= 0 ) + signedmask |= (1LL << k); + } + /*if ( (k= komodo_nutxofind(height,block.vtx[i].vin[j].prevout.hash,block.vtx[i].vin[j].prevout.n)) >= 0 ) signedmask |= (1LL << k); else if ( signedmask != 0 ) - printf("signedmask.%llx but ht.%d i.%d j.%d not found (%s %d)\n",(long long)signedmask,height,i,j,block.vtx[i].vin[j].prevout.hash.ToString().c_str(),block.vtx[i].vin[j].prevout.n); + printf("signedmask.%llx but ht.%d i.%d j.%d not found (%s %d)\n",(long long)signedmask,height,i,j,block.vtx[i].vin[j].prevout.hash.ToString().c_str(),block.vtx[i].vin[j].prevout.n);*/ } + if ( signedmask != 0 ) + printf("ht.%d signedmask.%llx numvins.%d numvouts.%d\n",height,(long long)signedmask,numvins,numvouts); if ( signedmask != 0 && (notarizedheight != 0 || specialtx != 0) ) { printf("NOTARY SIGNED.%llx numvins.%d ht.%d txi.%d notaryht.%d specialtx.%d\n",(long long)signedmask,numvins,height,i,notarizedheight,specialtx); diff --git a/src/komodo_events.h b/src/komodo_events.h index 8351ae37d..fb1ca452c 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -92,7 +92,7 @@ void komodo_eventadd_pubkeys(struct komodo_state *sp,char *symbol,int32_t height komodo_notarysinit(height,pubkeys,num); } -void komodo_eventadd_utxo(struct komodo_state *sp,char *symbol,int32_t height,uint8_t notaryid,uint256 txid,uint64_t voutmask,uint8_t numvouts) +/*void komodo_eventadd_utxo(struct komodo_state *sp,char *symbol,int32_t height,uint8_t notaryid,uint256 txid,uint64_t voutmask,uint8_t numvouts) { struct komodo_event_utxo U; memset(&U,0,sizeof(U)); @@ -102,7 +102,7 @@ void komodo_eventadd_utxo(struct komodo_state *sp,char *symbol,int32_t height,ui komodo_eventadd(height,symbol,KOMODO_EVENT_UTXO,(uint8_t *)&U,sizeof(U)); if ( sp != 0 ) komodo_nutxoadd(height,notaryid,txid,voutmask,numvouts); -} +}*/ void komodo_eventadd_pricefeed(struct komodo_state *sp,char *symbol,int32_t height,uint32_t *prices,uint8_t num) { diff --git a/src/komodo_globals.h b/src/komodo_globals.h index aba22a8eb..f5eba4929 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -32,7 +32,7 @@ int32_t KMDHEIGHT = 43000; struct pax_transaction *PAX; int32_t NUM_PRICES; uint32_t *PVALS; struct knotaries_entry *Pubkeys; -struct nutxo_entry *NUTXOS; int32_t Num_nutxos; +//struct nutxo_entry *NUTXOS; int32_t Num_nutxos; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS; struct komodo_state KOMODO_STATES[33]; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index ba1bf93f6..e66fec47e 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -52,7 +52,7 @@ const char *Notaries_genesis[][2] = { "titomane_SH", "035f49d7a308dd9a209e894321f010d21b7793461b0c89d6d9231a3fe5f68d9960" }, }; -void komodo_nutxoadd(int32_t height,int32_t notaryid,uint256 txhash,uint64_t voutmask,int32_t numvouts) +/*void komodo_nutxoadd(int32_t height,int32_t notaryid,uint256 txhash,uint64_t voutmask,int32_t numvouts) { struct nutxo_entry *np; if ( numvouts > 1 && notaryid < 64 ) @@ -79,7 +79,7 @@ int32_t komodo_nutxofind(int32_t height,uint256 txhash,int32_t vout) if ( np != 0 && ((1LL << vout) & np->voutmask) != 0 ) return(np->notaryid); return(-1); -} +}*/ int32_t komodo_ratify_threshold(int32_t height,uint64_t signedmask) { diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 946eb708a..f3a572fdc 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -30,7 +30,7 @@ struct pax_transaction char symbol[16],coinaddr[64]; uint8_t rmd160[20],shortflag; }; -struct nutxo_entry { UT_hash_handle hh; uint256 txhash; uint64_t voutmask; int32_t notaryid,height; }; +//struct nutxo_entry { UT_hash_handle hh; uint256 txhash; uint64_t voutmask; int32_t notaryid,height; }; struct knotary_entry { UT_hash_handle hh; uint8_t pubkey[33],notaryid; }; struct knotaries_entry { int32_t height,numnotaries; struct knotary_entry *Notaries; }; struct notarized_checkpoint { uint256 notarized_hash,notarized_desttxid; int32_t nHeight,notarized_height; };