diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 8f39e00b1..1abd6429a 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -27,7 +27,7 @@ #define MIN_NON_NOTARIZED_CONFIRMS 101 #endif // TESTMODE int32_t hush_dpowconfs(int32_t height,int32_t numconfs); -struct komodo_state *komodo_stateptr(char *symbol,char *dest); +struct hush_state *hush_stateptr(char *symbol,char *dest); extern uint32_t KOMODO_DPOWCONFS; void endiancpy(uint8_t *dest,uint8_t *src,int32_t len) @@ -682,7 +682,7 @@ bool komodo_txnotarizedconfirmed(uint256 txid) CTransaction tx; uint256 hashBlock; CBlockIndex *pindex; - char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct komodo_state *sp; + char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp; if ( KOMODO_NSPV_SUPERLITE ) { @@ -728,7 +728,7 @@ bool komodo_txnotarizedconfirmed(uint256 txid) confirms=1 + pindex->GetHeight() - txheight; } - if ((sp= komodo_stateptr(symbol,dest)) != 0 && (notarized=sp->NOTARIZED_HEIGHT) > 0 && txheight > sp->NOTARIZED_HEIGHT) notarized=0; + if ((sp= hush_stateptr(symbol,dest)) != 0 && (notarized=sp->NOTARIZED_HEIGHT) > 0 && txheight > sp->NOTARIZED_HEIGHT) notarized=0; #ifdef TESTMODE notarized=0; #endif //TESTMODE diff --git a/src/cc/dapps/dappstd.c b/src/cc/dapps/dappstd.c index 5af8cdccb..7bb52b982 100644 --- a/src/cc/dapps/dappstd.c +++ b/src/cc/dapps/dappstd.c @@ -660,7 +660,7 @@ uint16_t komodo_userpass(char *userpass,char *symbol) #endif } else sprintf(confname,"%s.conf",symbol); - //komodo_statefname(fname,symbol,confname); + //hush_statefname(fname,symbol,confname); if ( (fp= fopen(confname,"rb")) != 0 ) { port = _komodo_userpass(username,password,fp); diff --git a/src/cc/rogue/main.c b/src/cc/rogue/main.c index 5fa792259..f12915fa0 100644 --- a/src/cc/rogue/main.c +++ b/src/cc/rogue/main.c @@ -657,7 +657,7 @@ uint16_t _komodo_userpass(char *username, char *password, FILE *fp) return(port); } -/*void komodo_statefname(char *fname,char *symbol,char *str) +/*void hush_statefname(char *fname,char *symbol,char *str) { int32_t n,len; sprintf(fname,"%s",getDataDir()); @@ -707,7 +707,7 @@ uint16_t komodo_userpass(char *userpass,char *symbol) #endif } else sprintf(confname,"%s.conf",symbol); - //komodo_statefname(fname,symbol,confname); + //hush_statefname(fname,symbol,confname); if ( (fp= fopen(confname,"rb")) != 0 ) { port = _komodo_userpass(username,password,fp); diff --git a/src/hush.h b/src/hush.h index 46f17bd50..95c95e5da 100644 --- a/src/hush.h +++ b/src/hush.h @@ -39,7 +39,7 @@ uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID; #include "utlist.h" int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n); -void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height); +void komodo_event_rewind(struct hush_state *sp,char *symbol,int32_t height); int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block); bool check_pprevnotarizedht(); @@ -53,7 +53,7 @@ bool check_pprevnotarizedht(); #include "komodo_pax.h" #include "hush_notary.h" -int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char *dest); +int32_t komodo_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *dest); #include "komodo_kv.h" #include "komodo_gateway.h" #include "komodo_events.h" @@ -61,25 +61,25 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char void komodo_currentheight_set(int32_t height) { - char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp; + if ( (sp= hush_stateptr(symbol,dest)) != 0 ) sp->CURRENT_HEIGHT = height; } extern struct NSPV_inforesp NSPV_inforesult; int32_t komodo_currentheight() { - char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct komodo_state *sp; + char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp; if ( KOMODO_NSPV_SUPERLITE ) { return (NSPV_inforesult.height); } - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + if ( (sp= hush_stateptr(symbol,dest)) != 0 ) return(sp->CURRENT_HEIGHT); else return(0); } -int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char *dest) +int32_t komodo_parsestatefile(struct hush_state *sp,FILE *fp,char *symbol,char *dest) { static int32_t errs; int32_t func,ht,notarized_height,num,matched=0,MoMdepth; uint256 MoM,notarized_hash,notarized_desttxid; uint8_t pubkeys[64][33]; @@ -225,7 +225,7 @@ int32_t memread(void *dest,int32_t size,uint8_t *filedata,long *fposp,long datal return(-1); } -int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long *fposp,long datalen,char *symbol,char *dest) +int32_t komodo_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fposp,long datalen,char *symbol,char *dest) { static int32_t errs; int32_t func= -1,ht,notarized_height,MoMdepth,num,matched=0; uint256 MoM,notarized_hash,notarized_desttxid; uint8_t pubkeys[64][33]; long fpos = *fposp; @@ -356,26 +356,26 @@ int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long return(-1); } -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,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) +void hush_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,uint32_t KMDtimestamp,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth) { static FILE *fp; static int32_t errs,didinit; static uint256 zero; - struct komodo_state *sp; char fname[512],symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; int32_t retval,ht,func; uint8_t num,pubkeys[64][33]; + struct hush_state *sp; char fname[512],symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; int32_t retval,ht,func; uint8_t num,pubkeys[64][33]; if ( didinit == 0 ) { portable_mutex_init(&KOMODO_KV_mutex); portable_mutex_init(&KOMODO_CC_mutex); didinit = 1; } - if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) + if ( (sp= hush_stateptr(symbol,dest)) == 0 ) { HUSH_INITDONE = (uint32_t)time(NULL); - printf("[%s] no komodo_stateptr\n",SMART_CHAIN_SYMBOL); + printf("[%s] no hush_stateptr\n",SMART_CHAIN_SYMBOL); return; } //printf("[%s] (%s) -> (%s)\n",SMART_CHAIN_SYMBOL,symbol,dest); if ( fp == 0 ) { - komodo_statefname(fname,SMART_CHAIN_SYMBOL,(char *)"komodostate"); + hush_statefname(fname,SMART_CHAIN_SYMBOL,(char *)"hushstate"); if ( (fp= fopen(fname,"rb+")) != 0 ) { if ( (retval= hush_faststateinit(sp,fname,symbol,dest)) > 0 ) @@ -515,8 +515,8 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar int32_t komodo_validate_chain(uint256 srchash,int32_t notarized_height) { - static int32_t last_rewind; int32_t rewindtarget; CBlockIndex *pindex; struct komodo_state *sp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; - if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) + static int32_t last_rewind; int32_t rewindtarget; CBlockIndex *pindex; struct hush_state *sp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; + if ( (sp= hush_stateptr(symbol,dest)) == 0 ) return(0); if ( IsInitialBlockDownload() == 0 && ((pindex= komodo_getblockindex(srchash)) == 0 || pindex->GetHeight() != notarized_height) ) { @@ -541,8 +541,8 @@ int32_t komodo_validate_chain(uint256 srchash,int32_t notarized_height) int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized,uint64_t signedmask,uint32_t timestamp) { static uint256 zero; static FILE *signedfp; - int32_t opretlen,nid,offset,k,MoMdepth,matched,len = 0; uint256 MoM,srchash,desttxid; uint8_t crypto555[33]; struct komodo_state *sp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; - if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) + int32_t opretlen,nid,offset,k,MoMdepth,matched,len = 0; uint256 MoM,srchash,desttxid; uint8_t crypto555[33]; struct hush_state *sp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; + if ( (sp= hush_stateptr(symbol,dest)) == 0 ) return(-1); if ( scriptlen == 35 && scriptbuf[0] == 33 && scriptbuf[34] == 0xac ) { @@ -609,7 +609,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar if ( scriptbuf[len] == 'K' ) { //fprintf(stderr,"i.%d j.%d KV OPRET len.%d %.8f\n",i,j,opretlen,dstr(value)); - komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j,zero,0); + hush_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j,zero,0); return(-1); } if ( strcmp(SMART_CHAIN_SYMBOL,(char *)&scriptbuf[len+32*2+4]) == 0 ) @@ -716,7 +716,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar sp->MoM = MoM; sp->MoMdepth = MoMdepth; } - komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth); + hush_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0,sp->MoM,sp->MoMdepth); //if ( SMART_CHAIN_SYMBOL[0] != 0 ) printf("[%s] ht.%d NOTARIZED.%d %s.%s %sTXID.%s lens.(%d %d) MoM.%s %d\n",SMART_CHAIN_SYMBOL,height,sp->NOTARIZED_HEIGHT,SMART_CHAIN_SYMBOL[0]==0?"KMD":SMART_CHAIN_SYMBOL,srchash.ToString().c_str(),SMART_CHAIN_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),opretlen,len,sp->MoM.ToString().c_str(),sp->MoMdepth); @@ -725,7 +725,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar if ( signedfp == 0 ) { char fname[512]; - komodo_statefname(fname,SMART_CHAIN_SYMBOL,(char *)"signedmasks"); + hush_statefname(fname,SMART_CHAIN_SYMBOL,(char *)"signedmasks"); if ( (signedfp= fopen(fname,"rb+")) == 0 ) signedfp = fopen(fname,"wb"); else fseek(signedfp,0,SEEK_END); @@ -741,7 +741,7 @@ int32_t komodo_voutupdate(bool fJustCheck,int32_t *isratificationp,int32_t notar //for (i=0; i notarisations; - uint64_t signedmask,voutmask; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct komodo_state *sp; + uint64_t signedmask,voutmask; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp; uint8_t scriptbuf[10001],pubkeys[64][33],rmd160[20],scriptPubKey[35]; uint256 zero,btctxid,txhash; int32_t i,j,k,numnotaries,notarized,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; if ( pindex == 0 ) @@ -823,7 +823,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) memset(&zero,0,sizeof(zero)); komodo_init(pindex->GetHeight()); HUSH_INITDONE = (uint32_t)time(NULL); - if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) + if ( (sp= hush_stateptr(symbol,dest)) == 0 ) { fprintf(stderr,"unexpected null stateptr.[%s]\n",SMART_CHAIN_SYMBOL); return(0); @@ -845,7 +845,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) if (!fJustCheck) { komodo_event_rewind(sp,symbol,pindex->GetHeight()); - komodo_stateupdate(pindex->GetHeight(),0,0,0,zero,0,0,0,0,-pindex->GetHeight(),pindex->nTime,0,0,0,0,zero,0); + hush_stateupdate(pindex->GetHeight(),0,0,0,zero,0,0,0,0,-pindex->GetHeight(),pindex->nTime,0,0,0,0,zero,0); } } komodo_currentheight_set(chainActive.LastTip()->GetHeight()); @@ -893,7 +893,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) if ( signedfp == 0 ) { char fname[512]; - komodo_statefname(fname,SMART_CHAIN_SYMBOL,(char *)"signedmasks"); + hush_statefname(fname,SMART_CHAIN_SYMBOL,(char *)"signedmasks"); if ( (signedfp= fopen(fname,"rb+")) == 0 ) signedfp = fopen(fname,"wb"); else fseek(signedfp,0,SEEK_END); @@ -990,7 +990,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) if ( ((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries/3) ) { memset(&txhash,0,sizeof(txhash)); - komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0,zero,0); + hush_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0,zero,0); printf("RATIFIED! >>>>>>>>>> new notaries.%d newheight.%d from height.%d\n",numvalid,(((height+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,height); } else printf("signedmask.%llx numvalid.%d wt.%d numnotaries.%d\n",(long long)signedmask,numvalid,bitweight(signedmask),numnotaries); } @@ -1000,7 +1000,7 @@ int32_t hush_connectblock(bool fJustCheck, CBlockIndex *pindex,CBlock& block) if ( !fJustCheck && IS_HUSH_NOTARY != 0 && SMART_CHAIN_SYMBOL[0] == 0 ) printf("%s ht.%d\n",SMART_CHAIN_SYMBOL[0] == 0 ? "KMD" : SMART_CHAIN_SYMBOL,height); if ( !fJustCheck && pindex->GetHeight() == hwmheight ) - komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0,zero,0); + hush_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0,zero,0); } else { fprintf(stderr,"hush_connectblock: unexpected null pindex\n"); return(0); } diff --git a/src/hush_globals.h b/src/hush_globals.h index 96c4e3dc0..5bb8398dc 100644 --- a/src/hush_globals.h +++ b/src/hush_globals.h @@ -20,7 +20,7 @@ void komodo_prefetch(FILE *fp); uint32_t komodo_heightstamp(int32_t height); -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,uint32_t ktime,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth); +void hush_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,uint32_t ktime,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout,uint256 MoM,int32_t MoMdepth); void komodo_init(int32_t height); int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,int32_t nHeight,uint256 *MoMoMp,int32_t *MoMoMoffsetp,int32_t *MoMoMdepthp,int32_t *kmdstartip,int32_t *kmdendip); int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp); @@ -43,7 +43,7 @@ struct pax_transaction *PAX; int32_t NUM_PRICES; uint32_t *PVALS; struct knotaries_entry *Pubkeys; -struct komodo_state KOMODO_STATES[34]; +struct hush_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; diff --git a/src/hush_notary.h b/src/hush_notary.h index 2debc2e90..f6b14e658 100644 --- a/src/hush_notary.h +++ b/src/hush_notary.h @@ -237,12 +237,12 @@ int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33, return(modval); } -//struct komodo_state *komodo_stateptr(char *symbol,char *dest); +//struct hush_state *hush_stateptr(char *symbol,char *dest); struct notarized_checkpoint *komodo_npptr_for_height(int32_t height, int *idx) { - char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; int32_t i; struct hush_state *sp; struct notarized_checkpoint *np = 0; + if ( (sp= hush_stateptr(symbol,dest)) != 0 ) { for (i=sp->NUM_NPOINTS-1; i>=0; i--) { @@ -264,8 +264,8 @@ struct notarized_checkpoint *komodo_npptr(int32_t height) struct notarized_checkpoint *komodo_npptr_at(int idx) { - char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp; + if ( (sp= hush_stateptr(symbol,dest)) != 0 ) if (idx < sp->NUM_NPOINTS) return &sp->NPOINTS[idx]; return(0); @@ -274,8 +274,8 @@ struct notarized_checkpoint *komodo_npptr_at(int idx) int32_t komodo_prevMoMheight() { static uint256 zero; - char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; int32_t i; struct komodo_state *sp; struct notarized_checkpoint *np = 0; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; int32_t i; struct hush_state *sp; struct notarized_checkpoint *np = 0; + if ( (sp= hush_stateptr(symbol,dest)) != 0 ) { for (i=sp->NUM_NPOINTS-1; i>=0; i--) { @@ -289,11 +289,11 @@ int32_t komodo_prevMoMheight() int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 *txidp) { - char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct komodo_state *sp; + char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp; *prevMoMheightp = 0; memset(hashp,0,sizeof(*hashp)); memset(txidp,0,sizeof(*txidp)); - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + if ( (sp= hush_stateptr(symbol,dest)) != 0 ) { CBlockIndex *pindex; if ( (pindex= komodo_blockindex(sp->NOTARIZED_HASH)) == 0 || pindex->GetHeight() < 0 ) @@ -316,8 +316,8 @@ int32_t komodo_notarized_height(int32_t *prevMoMheightp,uint256 *hashp,uint256 * int32_t hush_dpowconfs(int32_t txheight,int32_t numconfs) { static int32_t hadnotarization; - char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct komodo_state *sp; - if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= komodo_stateptr(symbol,dest)) != 0 ) + char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp; + if ( KOMODO_DPOWCONFS != 0 && txheight > 0 && numconfs > 0 && (sp= hush_stateptr(symbol,dest)) != 0 ) { if ( sp->NOTARIZED_HEIGHT > 0 ) { @@ -356,8 +356,8 @@ int32_t komodo_MoMdata(int32_t *notarized_htp,uint256 *MoMp,uint256 *kmdtxidp,in int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp) { - struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct komodo_state *sp; - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + struct notarized_checkpoint *np = 0; int32_t i=0,flag = 0; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp; + if ( (sp= hush_stateptr(symbol,dest)) != 0 ) { if ( sp->NUM_NPOINTS > 0 ) { @@ -410,7 +410,7 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n return(0); } -void komodo_notarized_update(struct komodo_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) +void komodo_notarized_update(struct hush_state *sp,int32_t nHeight,int32_t notarized_height,uint256 notarized_hash,uint256 notarized_desttxid,uint256 MoM,int32_t MoMdepth) { struct notarized_checkpoint *np; if ( notarized_height >= nHeight ) @@ -457,6 +457,6 @@ void komodo_init(int32_t height) //for (i=0; ipath()); } } - path komodostate = GetDataDir() / "komodostate"; - remove(komodostate); + path hushstate = GetDataDir() / "hushstate"; + remove(hushstate); path minerids = GetDataDir() / "minerids"; remove(minerids); // Remove all block files that aren't part of a contiguous set starting at @@ -1770,10 +1768,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) if (fReindex) { - boost::filesystem::remove(GetDataDir() / "komodostate"); + boost::filesystem::remove(GetDataDir() / "hushstate"); boost::filesystem::remove(GetDataDir() / "signedmasks"); pblocktree->WriteReindexing(true); - fprintf(stderr, "%s: Deleted komodostate and signedmasks...\n", __FUNCTION__); + fprintf(stderr, "%s: Deleted hushstate and signedmasks...\n", __FUNCTION__); //If we're reindexing in prune mode, wipe away unusable block files and all undo data files if (fPruneMode) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index 180e8819b..8909074eb 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -724,14 +724,14 @@ int32_t komodo_isPoS(CBlock *pblock,int32_t height,bool fJustCheck) void komodo_disconnect(CBlockIndex *pindex,CBlock& block) { - char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct komodo_state *sp; + char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; struct hush_state *sp; //fprintf(stderr,"disconnect ht.%d\n",pindex->GetHeight()); komodo_init(pindex->GetHeight()); - if ( (sp= komodo_stateptr(symbol,dest)) != 0 ) + if ( (sp= hush_stateptr(symbol,dest)) != 0 ) { //sp->rewinding = pindex->GetHeight(); //fprintf(stderr,"-%d ",pindex->GetHeight()); - } else printf("komodo_disconnect: ht.%d cant get komodo_state.(%s)\n",pindex->GetHeight(),SMART_CHAIN_SYMBOL); + } else printf("komodo_disconnect: ht.%d cant get hush_state.(%s)\n",pindex->GetHeight(),SMART_CHAIN_SYMBOL); } int32_t komodo_is_notarytx(const CTransaction& tx) @@ -1191,8 +1191,8 @@ int32_t komodo_nextheight() int32_t komodo_isrealtime(int32_t *kmdheightp) { - struct komodo_state *sp; CBlockIndex *pindex; - if ( (sp= komodo_stateptrget((char *)"KMD")) != 0 ) + struct hush_state *sp; CBlockIndex *pindex; + if ( (sp= hush_stateptrget((char *)"KMD")) != 0 ) *kmdheightp = sp->CURRENT_HEIGHT; else *kmdheightp = 0; if ( (pindex= chainActive.LastTip()) != 0 && pindex->GetHeight() >= (int32_t)hush_longestchain() ) diff --git a/src/komodo_events.h b/src/komodo_events.h index ae4f0cf59..070aa407d 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -17,7 +17,7 @@ #define H_KOMODOEVENTS_H #include "hush_defs.h" -struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char *symbol,uint8_t type,uint8_t *data,uint16_t datalen) +struct komodo_event *komodo_eventadd(struct hush_state *sp,int32_t height,char *symbol,uint8_t type,uint8_t *data,uint16_t datalen) { struct komodo_event *ep=0; uint16_t len = (uint16_t)(sizeof(*ep) + datalen); if ( sp != 0 && SMART_CHAIN_SYMBOL[0] != 0 ) @@ -37,7 +37,7 @@ struct komodo_event *komodo_eventadd(struct komodo_state *sp,int32_t height,char return(ep); } -void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t height,char *dest,uint256 notarized_hash,uint256 notarized_desttxid,int32_t notarizedheight,uint256 MoM,int32_t MoMdepth) +void komodo_eventadd_notarized(struct hush_state *sp,char *symbol,int32_t height,char *dest,uint256 notarized_hash,uint256 notarized_desttxid,int32_t notarizedheight,uint256 MoM,int32_t MoMdepth) { static uint32_t counter; int32_t verified=0; char *coin; struct komodo_event_notarized N; coin = (SMART_CHAIN_SYMBOL[0] == 0) ? (char *)"KMD" : SMART_CHAIN_SYMBOL; @@ -63,7 +63,7 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig } } -void komodo_eventadd_pubkeys(struct komodo_state *sp,char *symbol,int32_t height,uint8_t num,uint8_t pubkeys[64][33]) +void komodo_eventadd_pubkeys(struct hush_state *sp,char *symbol,int32_t height,uint8_t num,uint8_t pubkeys[64][33]) { struct komodo_event_pubkeys P; //printf("eventadd pubkeys ht.%d\n",height); @@ -75,7 +75,7 @@ void komodo_eventadd_pubkeys(struct komodo_state *sp,char *symbol,int32_t height komodo_notarysinit(height,pubkeys,num); } -void komodo_eventadd_pricefeed(struct komodo_state *sp,char *symbol,int32_t height,uint32_t *prices,uint8_t num) +void komodo_eventadd_pricefeed(struct hush_state *sp,char *symbol,int32_t height,uint32_t *prices,uint8_t num) { struct komodo_event_pricefeed F; if ( num == sizeof(F.prices)/sizeof(*F.prices) ) @@ -89,7 +89,7 @@ void komodo_eventadd_pricefeed(struct komodo_state *sp,char *symbol,int32_t heig } //else fprintf(stderr,"skip pricefeed[%d]\n",num); } -void komodo_eventadd_opreturn(struct komodo_state *sp,char *symbol,int32_t height,uint256 txid,uint64_t value,uint16_t vout,uint8_t *buf,uint16_t opretlen) +void komodo_eventadd_opreturn(struct hush_state *sp,char *symbol,int32_t height,uint256 txid,uint64_t value,uint16_t vout,uint8_t *buf,uint16_t opretlen) { struct komodo_event_opreturn O; uint8_t *opret; if ( SMART_CHAIN_SYMBOL[0] != 0 ) @@ -108,7 +108,7 @@ void komodo_eventadd_opreturn(struct komodo_state *sp,char *symbol,int32_t heigh } } -void komodo_event_undo(struct komodo_state *sp,struct komodo_event *ep) +void komodo_event_undo(struct hush_state *sp,struct komodo_event *ep) { switch ( ep->type ) { @@ -127,7 +127,7 @@ void komodo_event_undo(struct komodo_state *sp,struct komodo_event *ep) } } -void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height) +void komodo_event_rewind(struct hush_state *sp,char *symbol,int32_t height) { struct komodo_event *ep; if ( sp != 0 ) @@ -152,7 +152,7 @@ void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height) } } -void komodo_setkmdheight(struct komodo_state *sp,int32_t kmdheight,uint32_t timestamp) +void komodo_setkmdheight(struct hush_state *sp,int32_t kmdheight,uint32_t timestamp) { if ( sp != 0 ) { @@ -166,7 +166,7 @@ void komodo_setkmdheight(struct komodo_state *sp,int32_t kmdheight,uint32_t time } } -void komodo_eventadd_kmdheight(struct komodo_state *sp,char *symbol,int32_t height,int32_t kmdheight,uint32_t timestamp) +void komodo_eventadd_kmdheight(struct hush_state *sp,char *symbol,int32_t height,int32_t kmdheight,uint32_t timestamp) { uint32_t buf[2]; if ( kmdheight > 0 ) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f8c04ea18..892158c2b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -29,11 +29,11 @@ int32_t dummy_linker_tricker() int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base) { - int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed,maxval; + int32_t baseid; struct hush_state *sp; int64_t netliability,maxallowed,maxval; *available = *deposited = *issued = *withdrawn = *approved = *redeemed = 0; if ( (baseid= komodo_baseid(base)) >= 0 ) { - if ( (sp= komodo_stateptrget(base)) != 0 ) + if ( (sp= hush_stateptrget(base)) != 0 ) { *deposited = sp->deposited; *issued = sp->issued; @@ -117,12 +117,12 @@ void komodo_paxdelete(struct pax_transaction *pax) void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,uint8_t type,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context { - struct pax_transaction *pax; uint8_t buf[35]; int32_t addflag = 0; struct komodo_state *sp; char str[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN],*s; + struct pax_transaction *pax; uint8_t buf[35]; int32_t addflag = 0; struct hush_state *sp; char str[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN],*s; //if ( KOMODO_PAX == 0 ) // return; //if ( strcmp(symbol,SMART_CHAIN_SYMBOL) != 0 ) // return; - sp = komodo_stateptr(str,dest); + sp = hush_stateptr(str,dest); pthread_mutex_lock(&komodo_mutex); pax_keyset(buf,txid,vout,type); HASH_FIND(hh,PAX,buf,sizeof(buf),pax); @@ -302,7 +302,7 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che uint64_t komodo_paxtotal() { - struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN],*str; int32_t i,ht; int64_t checktoshis; uint64_t seed,total = 0; struct komodo_state *basesp; + struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN],*str; int32_t i,ht; int64_t checktoshis; uint64_t seed,total = 0; struct hush_state *basesp; if ( HUSH_PASSPORT_INITDONE == 0 ) //KOMODO_PAX == 0 || return(0); if ( komodo_isrealtime(&ht) == 0 ) @@ -316,7 +316,7 @@ uint64_t komodo_paxtotal() if ( pax->type == 'A' || pax->type == 'D' || pax->type == 'X' ) str = pax->symbol; else str = pax->source; - basesp = komodo_stateptrget(str); + basesp = hush_stateptrget(str); if ( basesp != 0 && pax->didstats == 0 ) { if ( pax->type == 'I' && (pax2= komodo_paxfind(pax->txid,pax->vout,'D')) != 0 ) @@ -356,7 +356,7 @@ uint64_t komodo_paxtotal() } } } - komodo_stateptr(symbol,dest); + hush_stateptr(symbol,dest); HASH_ITER(hh,PAX,pax,tmp) { pax->ready = 0; @@ -476,11 +476,11 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t tokomodo) { - struct pax_transaction *pax,*tmp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; uint8_t *script,opcode,opret[16384*4],data[16384*4]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t available,deposited,issued,withdrawn,approved,redeemed,mask,sum = 0; + struct pax_transaction *pax,*tmp; char symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; uint8_t *script,opcode,opret[16384*4],data[16384*4]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct hush_state *sp; uint64_t available,deposited,issued,withdrawn,approved,redeemed,mask,sum = 0; if ( HUSH_PASSPORT_INITDONE == 0 )//KOMODO_PAX == 0 || return(0); - struct komodo_state *kmdsp = komodo_stateptrget((char *)"KMD"); - sp = komodo_stateptr(symbol,dest); + struct hush_state *kmdsp = hush_stateptrget((char *)"KMD"); + sp = hush_stateptr(symbol,dest); strcpy(symbol,base); if ( SMART_CHAIN_SYMBOL[0] != 0 && komodo_baseid(SMART_CHAIN_SYMBOL) < 0 ) return(0); @@ -683,7 +683,7 @@ void hush_passport_iteration(); int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtime) // verify above block is valid pax pricing { static uint256 array[64]; static int32_t numbanned,indallvouts; - int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,notmatched=0,matched=0,kmdheights[256],otherheights[256]; uint256 hash,txids[256]; char symbol[HUSH_SMART_CHAIN_MAXLEN],base[HUSH_SMART_CHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,seed; int64_t checktoshis,values[256],srcvalues[256]; struct pax_transaction *pax; struct komodo_state *sp; CTransaction tx; + int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,notmatched=0,matched=0,kmdheights[256],otherheights[256]; uint256 hash,txids[256]; char symbol[HUSH_SMART_CHAIN_MAXLEN],base[HUSH_SMART_CHAIN_MAXLEN]; uint16_t vouts[256]; int8_t baseids[256]; uint8_t *script,opcode,rmd160s[256*20]; uint64_t total,subsidy,available,deposited,issued,withdrawn,approved,redeemed,seed; int64_t checktoshis,values[256],srcvalues[256]; struct pax_transaction *pax; struct hush_state *sp; CTransaction tx; activation = 235300; if ( *(int32_t *)&array[0] == 0 ) numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array))); @@ -829,7 +829,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block,uint32_t prevtim const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct hush_state *basesp; double diff; const char *typestr = "unknown"; if ( SMART_CHAIN_SYMBOL[0] != 0 && komodo_baseid(SMART_CHAIN_SYMBOL) < 0 && opretbuf[0] != 'K' ) { @@ -881,7 +881,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( (pax= komodo_paxfind(txid,vout,'D')) == 0 ) { - if ( (basesp= komodo_stateptrget(base)) != 0 ) + if ( (basesp= hush_stateptrget(base)) != 0 ) { basesp->deposited += fiatoshis; didstats = 1; @@ -898,7 +898,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax->fiatoshis = fiatoshis; if ( didstats == 0 && pax->didstats == 0 ) { - if ( (basesp= komodo_stateptrget(base)) != 0 ) + if ( (basesp= hush_stateptrget(base)) != 0 ) { basesp->deposited += fiatoshis; didstats = 1; @@ -916,7 +916,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax2->height = pax->height = height; if ( pax2->didstats == 0 ) { - if ( (basesp= komodo_stateptrget(base)) != 0 ) + if ( (basesp= hush_stateptrget(base)) != 0 ) { basesp->issued += pax2->fiatoshis; pax2->didstats = 1; @@ -968,7 +968,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax->marked = pax2->marked = pax2->height; if ( pax->didstats == 0 ) { - if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + if ( (basesp= hush_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->issued += pax->fiatoshis; pax->didstats = 1; @@ -1010,7 +1010,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( value != 0 && ((pax= komodo_paxfind(txid,vout,'W')) == 0 || pax->didstats == 0) ) { - if ( (basesp= komodo_stateptrget(base)) != 0 ) + if ( (basesp= hush_stateptrget(base)) != 0 ) { basesp->withdrawn += value; didstats = 1; @@ -1080,7 +1080,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax2->approved = kmdheights[i]; komodo_paxmark(height,txids[i],vouts[i],'W',height); //komodo_paxmark(height,txids[i],vouts[i],'A',height); - if ( values[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + if ( values[i] != 0 && (basesp= hush_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->approved += values[i]; didstats = 1; @@ -1090,7 +1090,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( pax->didstats == 0 && srcvalues[i] != 0 ) { - if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + if ( (basesp= hush_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->approved += values[i]; didstats = 1; @@ -1132,7 +1132,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( height < 121842 ) // fields got switched around due to legacy issues and approves value = srcvalues[i]; else value = values[i]; - if ( baseids[i] >= 0 && value != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + if ( baseids[i] >= 0 && value != 0 && (basesp= hush_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->redeemed += value; pax->didstats = 1; @@ -1152,9 +1152,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 return(typestr); } -int32_t komodo_parsestatefiledata(struct komodo_state *sp,uint8_t *filedata,long *fposp,long datalen,char *symbol,char *dest); +int32_t komodo_parsestatefiledata(struct hush_state *sp,uint8_t *filedata,long *fposp,long datalen,char *symbol,char *dest); -void komodo_stateind_set(struct komodo_state *sp,uint32_t *inds,int32_t n,uint8_t *filedata,long datalen,char *symbol,char *dest) +void hush_stateind_set(struct hush_state *sp,uint32_t *inds,int32_t n,uint8_t *filedata,long datalen,char *symbol,char *dest) { uint8_t func; long lastK,lastT,lastN,lastV,fpos,lastfpos; int32_t i,count,doissue,iter,numn,numv,numN,numV,numR; uint32_t tmp,prevpos100,offset; count = numR = numN = numV = numn = numv = 0; @@ -1293,7 +1293,7 @@ uint8_t *OS_fileptr(long *allocsizep,char *fname) return((uint8_t *)retptr); } -long komodo_stateind_validate(struct komodo_state *sp,char *indfname,uint8_t *filedata,long datalen,uint32_t *prevpos100p,uint32_t *indcounterp,char *symbol,char *dest) +long hush_stateind_validate(struct hush_state *sp,char *indfname,uint8_t *filedata,long datalen,uint32_t *prevpos100p,uint32_t *indcounterp,char *symbol,char *dest) { FILE *fp; long fsize,lastfpos=0,fpos=0; uint8_t *inds,func; int32_t i,n; uint32_t offset,tmp,prevpos100 = 0; *indcounterp = *prevpos100p = 0; @@ -1327,7 +1327,7 @@ long komodo_stateind_validate(struct komodo_state *sp,char *indfname,uint8_t *fi *indcounterp = n; *prevpos100p = prevpos100; if ( sp != 0 ) - komodo_stateind_set(sp,(uint32_t *)inds,n,filedata,fpos,symbol,dest); + hush_stateind_set(sp,(uint32_t *)inds,n,filedata,fpos,symbol,dest); //printf("free inds.%p %s validated[%d] fpos.%ld datalen.%ld, offset %ld vs fsize.%ld\n",inds,indfname,i,fpos,datalen,i * sizeof(uint32_t),fsize); free(inds); return(fpos); @@ -1357,7 +1357,7 @@ long komodo_indfile_update(FILE *indfp,uint32_t *prevpos100p,long lastfpos,long return(newfpos); } -int32_t hush_faststateinit(struct komodo_state *sp,char *fname,char *symbol,char *dest) +int32_t hush_faststateinit(struct hush_state *sp,char *fname,char *symbol,char *dest) { FILE *indfp; char indfname[1024]; uint8_t *filedata; long validated=-1,datalen,fpos,lastfpos; uint32_t tmp,prevpos100,indcounter,starttime; int32_t func,finished = 0; starttime = (uint32_t)time(NULL); @@ -1365,7 +1365,7 @@ int32_t hush_faststateinit(struct komodo_state *sp,char *fname,char *symbol,char strcat(indfname,".ind"); if ( (filedata= OS_fileptr(&datalen,fname)) != 0 ) { - if ( 1 )//datalen >= (1LL << 32) || GetArg("-genind",0) != 0 || (validated= komodo_stateind_validate(0,indfname,filedata,datalen,&prevpos100,&indcounter,symbol,dest)) < 0 ) + if ( 1 )//datalen >= (1LL << 32) || GetArg("-genind",0) != 0 || (validated= hush_stateind_validate(0,indfname,filedata,datalen,&prevpos100,&indcounter,symbol,dest)) < 0 ) { lastfpos = fpos = 0; indcounter = prevpos100 = 0; @@ -1379,8 +1379,8 @@ int32_t hush_faststateinit(struct komodo_state *sp,char *fname,char *symbol,char if ( indfp != 0 ) { fclose(indfp); - if ( (fpos= komodo_stateind_validate(0,indfname,filedata,datalen,&prevpos100,&indcounter,symbol,dest)) < 0 ) - printf("unexpected komodostate.ind validate failure %s datalen.%ld\n",indfname,datalen); + if ( (fpos= hush_stateind_validate(0,indfname,filedata,datalen,&prevpos100,&indcounter,symbol,dest)) < 0 ) + printf("unexpected hushstate.ind validate failure %s datalen.%ld\n",indfname,datalen); else printf("%s validated fpos.%ld\n",indfname,fpos); } finished = 1; @@ -1406,8 +1406,8 @@ int32_t hush_faststateinit(struct komodo_state *sp,char *fname,char *symbol,char } fclose(indfp); } - if ( komodo_stateind_validate(sp,indfname,filedata,datalen,&prevpos100,&indcounter,symbol,dest) < 0 ) - printf("unexpected komodostate.ind validate failure %s datalen.%ld\n",indfname,datalen); + if ( hush_stateind_validate(sp,indfname,filedata,datalen,&prevpos100,&indcounter,symbol,dest) < 0 ) + printf("unexpected hushstate.ind validate failure %s datalen.%ld\n",indfname,datalen); else { printf("%s validated updated from validated.%ld to %ld new.[%ld] -> indcounter %u, prevpos100 %u offset.%ld | elapsed %d seconds\n",indfname,validated,fpos,fpos-validated,indcounter,prevpos100,indcounter * sizeof(uint32_t),(int32_t)(time(NULL) - starttime)); @@ -1427,7 +1427,7 @@ void hush_passport_iteration() { static long lastpos[34]; static char userpass[33][1024]; static uint32_t lasttime,callcounter,lastinterest; int32_t maxseconds = 10; - FILE *fp; uint8_t *filedata; long fpos,datalen,lastfpos; int32_t baseid,limit,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; uint32_t buf[3],starttime; uint64_t RTmask = 0; //CBlockIndex *pindex; + FILE *fp; uint8_t *filedata; long fpos,datalen,lastfpos; int32_t baseid,limit,n,ht,isrealtime,expired,refid,blocks,longest; struct hush_state *sp,*refsp; char *retstr,fname[512],*base,symbol[HUSH_SMART_CHAIN_MAXLEN],dest[HUSH_SMART_CHAIN_MAXLEN]; uint32_t buf[3],starttime; uint64_t RTmask = 0; //CBlockIndex *pindex; expired = 0; while ( 0 && HUSH_INITDONE == 0 ) { @@ -1441,7 +1441,7 @@ void hush_passport_iteration() //hush_longestchain(); lastinterest = komodo_chainactive_timestamp(); } - refsp = komodo_stateptr(symbol,dest); + refsp = hush_stateptr(symbol,dest); if ( SMART_CHAIN_SYMBOL[0] == 0 || strcmp(SMART_CHAIN_SYMBOL,"JUSTLIES") == 0 ) { refid = 33; @@ -1472,9 +1472,9 @@ void hush_passport_iteration() if ( baseid == 32 ) // only care about KMD's state { refsp->RTmask &= ~(1LL << baseid); - komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"komodostate"); + hush_statefname(fname,baseid<32?base:(char *)"",(char *)"hushstate"); komodo_nameset(symbol,dest,base); - sp = komodo_stateptrget(symbol); + sp = hush_stateptrget(symbol); n = 0; if ( lastpos[baseid] == 0 && (filedata= OS_fileptr(&datalen,fname)) != 0 ) { @@ -1516,7 +1516,7 @@ void hush_passport_iteration() } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); } else fprintf(stderr,"load error.(%s) %p\n",fname,sp); - komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime"); + hush_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime"); if ( (fp= fopen(fname,"rb")) != 0 ) { if ( fread(buf,1,sizeof(buf),fp) == sizeof(buf) ) @@ -1538,7 +1538,7 @@ void hush_passport_iteration() else { refsp->RTmask &= ~(1LL << baseid); - komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime"); + hush_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime"); if ( (fp= fopen(fname,"wb")) != 0 ) { buf[0] = (uint32_t)chainActive.LastTip()->GetHeight(); diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 4a005d2b3..0ca6d6e92 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -709,7 +709,7 @@ void komodo_paxpricefeed(int32_t height,uint8_t *pricefeed,int32_t opretlen) double KMDBTC,BTCUSD,CNYUSD; uint32_t numpvals,timestamp,pvals[128]; uint256 zero; numpvals = dpow_readprices(height,pricefeed,×tamp,&KMDBTC,&BTCUSD,&CNYUSD,pvals); memset(&zero,0,sizeof(zero)); - komodo_stateupdate(height,0,0,0,zero,0,0,pvals,numpvals,0,0,0,0,0,0,zero,0); + hush_stateupdate(height,0,0,0,zero,0,0,pvals,numpvals,0,0,0,0,0,0,zero,0); if ( 0 ) { int32_t i;