test
This commit is contained in:
@@ -34,6 +34,7 @@
|
|||||||
#include "utlist.h"
|
#include "utlist.h"
|
||||||
|
|
||||||
int32_t gettxout_scriptPubKey(uint8_t *scriptPubkey,int32_t maxsize,uint256 txid,int32_t n);
|
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);
|
||||||
|
|
||||||
#include "komodo_structs.h"
|
#include "komodo_structs.h"
|
||||||
#include "komodo_globals.h"
|
#include "komodo_globals.h"
|
||||||
@@ -83,7 +84,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char
|
|||||||
//printf("fpos.%ld func.(%d %c) ht.%d ",ftell(fp),func,func,ht);
|
//printf("fpos.%ld func.(%d %c) ht.%d ",ftell(fp),func,func,ht);
|
||||||
if ( func == 'P' )
|
if ( func == 'P' )
|
||||||
{
|
{
|
||||||
if ( (num= fgetc(fp)) < 64 )
|
if ( (num= fgetc(fp)) <= 64 )
|
||||||
{
|
{
|
||||||
if ( fread(pubkeys,33,num,fp) != num )
|
if ( fread(pubkeys,33,num,fp) != num )
|
||||||
errs++;
|
errs++;
|
||||||
@@ -241,7 +242,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
|
|||||||
}
|
}
|
||||||
else if ( notarypubs != 0 && numnotaries > 0 )
|
else if ( notarypubs != 0 && numnotaries > 0 )
|
||||||
{
|
{
|
||||||
//printf("ht.%d func P[%d] errs.%d\n",height,numnotaries,errs);
|
printf("ht.%d func P[%d] errs.%d\n",height,numnotaries,errs);
|
||||||
fputc('P',fp);
|
fputc('P',fp);
|
||||||
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
|
if ( fwrite(&height,1,sizeof(height),fp) != sizeof(height) )
|
||||||
errs++;
|
errs++;
|
||||||
|
|||||||
@@ -375,16 +375,11 @@ uint64_t komodo_seed(int32_t height)
|
|||||||
|
|
||||||
void komodo_disconnect(CBlockIndex *pindex,CBlock& block)
|
void komodo_disconnect(CBlockIndex *pindex,CBlock& block)
|
||||||
{
|
{
|
||||||
//int32_t i; uint256 hash;
|
char base[16],dest[16]; struct komodo_state *sp;
|
||||||
komodo_init(pindex->nHeight);
|
komodo_init(pindex->nHeight);
|
||||||
//Minerids[pindex->nHeight] = -2;
|
if ( (sp= komodo_stateptr(symbol,dest)) != 0 )
|
||||||
//hash = block.GetHash();
|
komodo_event_rewind(sp,symbol,pindex->nHeight);
|
||||||
//for (i=0; i<32; i++)
|
komodo_stateupdate();
|
||||||
// printf("%02x",((uint8_t *)&hash)[i]);
|
|
||||||
//printf(" <- disconnect block\n");
|
|
||||||
//uint256 zero;
|
|
||||||
//printf("disconnect ht.%d\n",pindex->nHeight);
|
|
||||||
//memset(&zero,0,sizeof(zero));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t komodo_is_notarytx(const CTransaction& tx)
|
int32_t komodo_is_notarytx(const CTransaction& tx)
|
||||||
@@ -464,14 +459,6 @@ void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
komodo_block2pubkey33(pubkey33,block);
|
komodo_block2pubkey33(pubkey33,block);
|
||||||
/* if ( ReadBlockFromDisk(block,(const CBlockIndex *)pindex
|
|
||||||
#ifndef KOMODO_ZCASH
|
|
||||||
,Params().GetConsensus()
|
|
||||||
#endif
|
|
||||||
) != 0 )
|
|
||||||
{
|
|
||||||
komodo_block2pubkey33(pubkey33,block);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#define KOMODO_EVENT_NOTARIZED 'N'
|
#define KOMODO_EVENT_NOTARIZED 'N'
|
||||||
#define KOMODO_EVENT_UTXO 'U'
|
#define KOMODO_EVENT_UTXO 'U'
|
||||||
#define KOMODO_EVENT_KMDHEIGHT 'K'
|
#define KOMODO_EVENT_KMDHEIGHT 'K'
|
||||||
|
#define KOMODO_EVENT_REWIND 'B'
|
||||||
//#define KOMODO_EVENT_DELETE 'D'
|
//#define KOMODO_EVENT_DELETE 'D'
|
||||||
#define KOMODO_EVENT_PRICEFEED 'V'
|
#define KOMODO_EVENT_PRICEFEED 'V'
|
||||||
#define KOMODO_EVENT_OPRETURN 'R'
|
#define KOMODO_EVENT_OPRETURN 'R'
|
||||||
@@ -84,6 +85,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 komodo_state *sp,char *symbol,int32_t height,uint8_t num,uint8_t pubkeys[64][33])
|
||||||
{
|
{
|
||||||
struct komodo_event_pubkeys P;
|
struct komodo_event_pubkeys P;
|
||||||
|
printf("eventadd pubkeys ht.%d\n",height);
|
||||||
memset(&P,0,sizeof(P));
|
memset(&P,0,sizeof(P));
|
||||||
P.num = num;
|
P.num = num;
|
||||||
memcpy(P.pubkeys,pubkeys,33 * num);
|
memcpy(P.pubkeys,pubkeys,33 * num);
|
||||||
@@ -151,17 +153,22 @@ void komodo_event_undo(struct komodo_event *ep)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void komodo_event_rewind(int32_t height)
|
void komodo_event_rewind(struct komodo_state *sp,char *symbol,int32_t height)
|
||||||
{
|
{
|
||||||
struct komodo_event *ep;
|
struct komodo_event *ep;
|
||||||
while ( Komodo_numevents > 0 )
|
komodo_eventadd(height,symbol,KOMODO_EVENT_REWIND,(uint8_t *)&height,sizeof(height));
|
||||||
|
if ( sp != 0 )
|
||||||
{
|
{
|
||||||
if ( (ep= Komodo_events[Komodo_numevents-1]) != 0 )
|
while ( Komodo_numevents > 0 )
|
||||||
{
|
{
|
||||||
if ( ep->height < height )
|
if ( (ep= Komodo_events[Komodo_numevents-1]) != 0 )
|
||||||
break;
|
{
|
||||||
komodo_event_undo(ep);
|
if ( ep->height < height )
|
||||||
Komodo_numevents--;
|
break;
|
||||||
|
printf("undo event.%c ht.%d for rewind.%d\n",ep->type,ep->height,height);
|
||||||
|
komodo_event_undo(ep);
|
||||||
|
Komodo_numevents--;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num)
|
|||||||
height /= KOMODO_ELECTION_GAP;
|
height /= KOMODO_ELECTION_GAP;
|
||||||
height = ((height + 1) * KOMODO_ELECTION_GAP);
|
height = ((height + 1) * KOMODO_ELECTION_GAP);
|
||||||
htind = (height / KOMODO_ELECTION_GAP);
|
htind = (height / KOMODO_ELECTION_GAP);
|
||||||
printf("htind.%d activation %d from %d\n",htind,height,origheight);
|
printf("htind.%d activation %d from %d vs %d\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP);
|
||||||
} else htind = 0;
|
} else htind = 0;
|
||||||
pthread_mutex_lock(&komodo_mutex);
|
pthread_mutex_lock(&komodo_mutex);
|
||||||
for (k=0; k<num; k++)
|
for (k=0; k<num; k++)
|
||||||
|
|||||||
Reference in New Issue
Block a user