This commit is contained in:
jl777
2016-11-20 11:50:57 -03:00
parent 5461e2431d
commit 48a3cd18c9
6 changed files with 14 additions and 18 deletions

View File

@@ -112,7 +112,7 @@ void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height)
{ {
if ( ep->height < height ) if ( ep->height < height )
break; break;
printf("[%s] undo %s event.%c ht.%d for rewind.%d\n",ASSETCHAINS_SYMBOL,symbol,ep->type,ep->height,height); //printf("[%s] undo %s event.%c ht.%d for rewind.%d\n",ASSETCHAINS_SYMBOL,symbol,ep->type,ep->height,height);
komodo_event_undo(sp,ep); komodo_event_undo(sp,ep);
sp->Komodo_numevents--; sp->Komodo_numevents--;
} }

View File

@@ -136,7 +136,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,uint8_t
uint64_t komodo_paxtotal() uint64_t komodo_paxtotal()
{ {
struct pax_transaction *pax,*tmp; int32_t ht; uint64_t total = 0; struct pax_transaction *pax,*tmp; int32_t ht; uint64_t total = 0;
if ( komodo_isrealtime(&ht,ASSETCHAINS_SYMBOL) == 0 ) if ( komodo_isrealtime(&ht) == 0 )
return(0); return(0);
HASH_ITER(hh,PAX,pax,tmp) HASH_ITER(hh,PAX,pax,tmp)
{ {
@@ -161,7 +161,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to
if ( tokomodo == 0 ) if ( tokomodo == 0 )
{ {
opcode = 'I'; opcode = 'I';
if ( komodo_isrealtime(&ht,ASSETCHAINS_SYMBOL) == 0 ) if ( komodo_isrealtime(&ht) == 0 )
return(0); return(0);
} }
else opcode = 'X'; else opcode = 'X';
@@ -437,7 +437,7 @@ void komodo_passport_iteration()
if ( buf[0] != 0 && buf[0] == buf[1] ) if ( buf[0] != 0 && buf[0] == buf[1] )
{ {
buf[2] = (uint32_t)time(NULL); buf[2] = (uint32_t)time(NULL);
RTmask |= (1LL << baseid); RTmask |= (1LL << baseid) | 1;
memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1])); memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1]));
if ( refid != 0 ) if ( refid != 0 )
memcpy(refsp->RTbufs[0],buf,sizeof(refsp->RTbufs[0])); memcpy(refsp->RTbufs[0],buf,sizeof(refsp->RTbufs[0]));

View File

@@ -20,7 +20,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
void komodo_init(int32_t height); void komodo_init(int32_t height);
void komodo_assetchain_pubkeys(char *jsonstr); void komodo_assetchain_pubkeys(char *jsonstr);
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33); int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33);
int32_t komodo_isrealtime(int32_t *kmdheightp,char *target); int32_t komodo_isrealtime(int32_t *kmdheightp);
uint64_t komodo_paxtotal(); uint64_t komodo_paxtotal();
pthread_mutex_t komodo_mutex; pthread_mutex_t komodo_mutex;

View File

@@ -1512,17 +1512,13 @@ struct komodo_state *komodo_stateptr(char *symbol,char *dest)
return(komodo_stateptrget(symbol)); return(komodo_stateptrget(symbol));
} }
int32_t komodo_isrealtime(int32_t *kmdheightp,char *target) int32_t komodo_isrealtime(int32_t *kmdheightp)
{ {
char symbol[16],dest[16]; int32_t baseid; uint64_t mask; struct komodo_state *sp; char symbol[16],dest[16]; uint64_t mask; struct komodo_state *sp;
*kmdheightp = 0; *kmdheightp = 0;
if ( target == 0 || target[0] == 0 ) if ( (sp= komodo_stateptr(symbol,dest)) != 0 )
target = (char *)"KMD";
if ( (sp= komodo_stateptrget(target)) != 0 )
{ {
if ( (baseid= komodo_baseid(target)) < 0 ) mask = (1LL << 32) | 1LL;
return(0);
mask = (1LL << 32) | (1LL << baseid);
if ( (sp->RTmask & mask) != mask ) if ( (sp->RTmask & mask) != mask )
{ {
printf("%s not RT mask.%llx vs RTmask.%llx\n",target,(long long)mask,(long long)sp->RTmask); printf("%s not RT mask.%llx vs RTmask.%llx\n",target,(long long)mask,(long long)sp->RTmask);

View File

@@ -111,7 +111,7 @@ int32_t komodo_pax_opreturn(uint8_t *opret,int32_t maxsize);
uint64_t komodo_paxtotal(); uint64_t komodo_paxtotal();
int32_t komodo_is_issuer(); int32_t komodo_is_issuer();
int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *symbol,int32_t tokomodo); int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *symbol,int32_t tokomodo);
int32_t komodo_isrealtime(int32_t *kmdheightp,char *target); int32_t komodo_isrealtime(int32_t *kmdheightp);
CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
{ {
@@ -123,12 +123,12 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
CBlock *pblock = &pblocktemplate->block; // pointer for convenience CBlock *pblock = &pblocktemplate->block; // pointer for convenience
if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= 100 ) if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= 100 )
{ {
isrealtime = komodo_isrealtime(&kmdheight,ASSETCHAINS_SYMBOL); isrealtime = komodo_isrealtime(&kmdheight);
fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),isrealtime,KOMODO_ON_DEMAND); fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),isrealtime,KOMODO_ON_DEMAND);
while ( KOMODO_ON_DEMAND == 0 ) while ( KOMODO_ON_DEMAND == 0 )
{ {
deposits = komodo_paxtotal(); deposits = komodo_paxtotal();
if ( KOMODO_INITDONE == 0 || komodo_isrealtime(&kmdheight,ASSETCHAINS_SYMBOL) == 0 ) if ( KOMODO_INITDONE == 0 || komodo_isrealtime(&kmdheight) == 0 )
{ {
//fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN); //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN);
} }

View File

@@ -481,7 +481,7 @@ int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_
extern char ASSETCHAINS_SYMBOL[16]; extern char ASSETCHAINS_SYMBOL[16];
int32_t komodo_is_issuer(); int32_t komodo_is_issuer();
int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp);
int32_t komodo_isrealtime(int32_t *kmdheightp,char *target); int32_t komodo_isrealtime(int32_t *kmdheightp);
Value paxdeposit(const Array& params, bool fHelp) Value paxdeposit(const Array& params, bool fHelp)
{ {
@@ -529,7 +529,7 @@ Value paxwithdraw(const Array& params, bool fHelp)
return 0; return 0;
if (fHelp || params.size() != 2) if (fHelp || params.size() != 2)
throw runtime_error("paxwithdraw \"address\" fiatamount"); throw runtime_error("paxwithdraw \"address\" fiatamount");
if ( komodo_isrealtime(&kmdheight,(char *)"KMD") == 0 ) if ( komodo_isrealtime(&kmdheight) == 0 )
return(0); return(0);
LOCK2(cs_main, pwalletMain->cs_wallet); LOCK2(cs_main, pwalletMain->cs_wallet);
CBitcoinAddress address(params[0].get_str()); CBitcoinAddress address(params[0].get_str());