From 1ebb14e7407874dfaa15ad1a071879c6050e3baa Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 19 Nov 2016 12:45:28 -0300 Subject: [PATCH] test --- src/komodo.h | 18 +++++++++--------- src/komodo_events.h | 12 ------------ src/komodo_notary.h | 35 ++--------------------------------- 3 files changed, 11 insertions(+), 54 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index ad253e032..990438a9b 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -87,7 +87,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char else { printf("updated %d pubkeys at ht.%d\n",num,ht); - if ( matched != 0 ) + if ( matched != 0 ) // private state -> global Pubkeys komodo_eventadd_pubkeys(sp,symbol,ht,num,pubkeys); } } else printf("illegal num.%d\n",num); @@ -100,11 +100,11 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char errs++; if ( fread(¬arized_desttxid,1,sizeof(notarized_desttxid),fp) != sizeof(notarized_desttxid) ) errs++; - printf("load NOTARIZED %d %s\n",notarized_height,notarized_hash.ToString().c_str()); - if ( matched != 0 ) - komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); + printf("load %s NOTARIZED %d %s\n",ASSETCHAINS_SYMBOL,notarized_height,notarized_hash.ToString().c_str()); + //if ( matched != 0 ) global independent states -> inside *sp + komodo_eventadd_notarized(sp,symbol,ht,dest,notarized_hash,notarized_desttxid,notarized_height); } - else if ( func == 'U' ) + else if ( func == 'U' ) // deprecated { uint8_t n,nid; uint256 hash; uint64_t mask; n = fgetc(fp); @@ -122,7 +122,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char int32_t kheight; if ( fread(&kheight,1,sizeof(kheight),fp) != sizeof(kheight) ) errs++; - if ( matched != 0 ) + //if ( matched != 0 ) global independent states -> inside *sp komodo_eventadd_kmdheight(sp,symbol,ht,kheight); } else if ( func == 'R' ) @@ -140,7 +140,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char { if ( fread(opret,1,olen,fp) != olen ) errs++; - if ( matched != 0 ) + //if ( matched != 0 ) global shared state -> global PAX komodo_eventadd_opreturn(sp,symbol,ht,txid,ovalue,v,opret,olen); } else printf("illegal olen.%u\n",olen); } @@ -154,7 +154,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char numpvals = fgetc(fp); if ( numpvals*sizeof(uint32_t) <= sizeof(pvals) && fread(pvals,sizeof(uint32_t),numpvals,fp) == numpvals ) { - if ( matched != 0 ) + //if ( matched != 0 ) global shared state -> global PVALS komodo_eventadd_pricefeed(sp,symbol,ht,pvals,numpvals); //printf("load pvals ht.%d numpvals.%d\n",ht,numpvals); } else printf("error loading pvals[%d]\n",numpvals); @@ -340,7 +340,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); if ( *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { - printf("ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s)\n",height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len]); + printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len]); sp->NOTARIZED_HEIGHT = *notarizedheightp; sp->NOTARIZED_HASH = kmdtxid; sp->NOTARIZED_DESTTXID = desttxid; diff --git a/src/komodo_events.h b/src/komodo_events.h index 774083f71..296824b6e 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -56,18 +56,6 @@ 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) -{ - struct komodo_event_utxo U; - memset(&U,0,sizeof(U)); - U.txid = txid; - U.voutmask = voutmask; - U.numvouts = numvouts; - 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) { struct komodo_event_pricefeed F; diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 64ffb21fd..b58819f30 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -52,46 +52,15 @@ 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) -{ - struct nutxo_entry *np; - if ( numvouts > 1 && notaryid < 64 ) - { - pthread_mutex_lock(&komodo_mutex); - np = (struct nutxo_entry *)calloc(1,sizeof(*np)); - np->height = height; - np->txhash = txhash; - np->voutmask = voutmask; - np->notaryid = notaryid; - HASH_ADD_KEYPTR(hh,NUTXOS,&np->txhash,sizeof(np->txhash),np); - //printf("Add NUTXO[%d] <- %s notaryid.%d t%u %s %llx\n",Num_nutxos,Notaries[notaryid][0],notaryid,komodo_txtime(txhash),txhash.ToString().c_str(),(long long)voutmask); - Num_nutxos++; - pthread_mutex_unlock(&komodo_mutex); - } -} - -int32_t komodo_nutxofind(int32_t height,uint256 txhash,int32_t vout) -{ - struct nutxo_entry *np; - pthread_mutex_lock(&komodo_mutex); - HASH_FIND(hh,NUTXOS,&txhash,sizeof(txhash),np); - pthread_mutex_unlock(&komodo_mutex); - if ( np != 0 && ((1LL << vout) & np->voutmask) != 0 ) - return(np->notaryid); - return(-1); -}*/ - int32_t komodo_ratify_threshold(int32_t height,uint64_t signedmask) { int32_t htind,numnotaries,i,wt = 0; - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - return(2); htind = height / KOMODO_ELECTION_GAP; - numnotaries = Pubkeys[htind].numnotaries; + numnotaries = sp->Pubkeys[htind].numnotaries; for (i=0; i (numnotaries >> 1) || (wt > 7 && (signedmask & 3) != 0) ) + if ( wt > (numnotaries >> 1) || (wt > 7 && (signedmask & 1) != 0) ) return(1); else return(0); }