test
This commit is contained in:
@@ -516,6 +516,8 @@ void CleanupBlockRevFiles()
|
|||||||
}
|
}
|
||||||
path komodostate = GetDataDir() / "komodostate";
|
path komodostate = GetDataDir() / "komodostate";
|
||||||
remove(komodostate);
|
remove(komodostate);
|
||||||
|
path minerids = GetDataDir() / "minerids";
|
||||||
|
remove(minerids);
|
||||||
// Remove all block files that aren't part of a contiguous set starting at
|
// Remove all block files that aren't part of a contiguous set starting at
|
||||||
// zero by walking the ordered map (keys are block file indices) by
|
// zero by walking the ordered map (keys are block file indices) by
|
||||||
// keeping a separate counter. Once we hit a gap (or if 0 doesn't exist)
|
// keeping a separate counter. Once we hit a gap (or if 0 doesn't exist)
|
||||||
|
|||||||
45
src/komodo.h
45
src/komodo.h
@@ -17,12 +17,12 @@
|
|||||||
#define H_KOMODO_H
|
#define H_KOMODO_H
|
||||||
|
|
||||||
// Todo:
|
// Todo:
|
||||||
|
// 0. minerids file
|
||||||
// 1. error check fiat redeem amounts
|
// 1. error check fiat redeem amounts
|
||||||
// 2. net balance limiter
|
// 2. net balance limiter
|
||||||
// 3. new RR algo
|
// 3. verify: interest payment, ratification, reorgs
|
||||||
// 4. verify: interest payment, ratification, reorgs
|
// 4. automate notarization fee payouts
|
||||||
// 5. automate notarization fee payouts
|
// 5. automated distribution of test REVS snapshot
|
||||||
// 6. automated distribution of test REVS snapshot
|
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
#define GENESIS_NBITS 0x1f00ffff
|
#define GENESIS_NBITS 0x1f00ffff
|
||||||
#define KOMODO_MINRATIFY 7
|
#define KOMODO_MINRATIFY 7
|
||||||
|
|
||||||
|
FILE *Minerfp;
|
||||||
int8_t Minerids[1024 * 1024 * 5]; // 5 million blocks
|
int8_t Minerids[1024 * 1024 * 5]; // 5 million blocks
|
||||||
|
|
||||||
#include "komodo_globals.h"
|
#include "komodo_globals.h"
|
||||||
@@ -48,14 +49,26 @@ int8_t Minerids[1024 * 1024 * 5]; // 5 million blocks
|
|||||||
|
|
||||||
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,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout)
|
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,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout)
|
||||||
{
|
{
|
||||||
static FILE *fp; static int32_t errs; char fname[512]; int32_t ht,func; uint8_t num,pubkeys[64][33];
|
static FILE *fp; static int32_t errs; char fname[512],fname2[512]; int32_t ht,func; uint8_t num,pubkeys[64][33];
|
||||||
#ifdef WIN32
|
|
||||||
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"komodostate");
|
|
||||||
#else
|
|
||||||
sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),(char *)"komodostate");
|
|
||||||
#endif
|
|
||||||
if ( fp == 0 )
|
if ( fp == 0 )
|
||||||
{
|
{
|
||||||
|
#ifdef WIN32
|
||||||
|
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"komodostate");
|
||||||
|
sprintf(fname2,"%s\\%s",GetDataDir(false).string().c_str(),(char *)"minerids");
|
||||||
|
#else
|
||||||
|
sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),(char *)"komodostate");
|
||||||
|
sprintf(fname2,"%s/%s",GetDataDir(false).string().c_str(),(char *)"minerids");
|
||||||
|
#endif
|
||||||
|
memset(Minerids,0xfe,sizeof(Minerids));
|
||||||
|
if ( (Minerfp= fopen(fname2,"rb+")) == 0 )
|
||||||
|
{
|
||||||
|
if ( (Minerfp= fopen(fname2,"wb")) != 0 )
|
||||||
|
{
|
||||||
|
fwrite(Minerids,1,sizeof(Minerids),Minerfp);
|
||||||
|
fclose(Minerfp);
|
||||||
|
}
|
||||||
|
Minerfp = fopen(fname2,"rb+");
|
||||||
|
}
|
||||||
if ( (fp= fopen(fname,"rb+")) != 0 )
|
if ( (fp= fopen(fname,"rb+")) != 0 )
|
||||||
{
|
{
|
||||||
while ( (func= fgetc(fp)) != EOF )
|
while ( (func= fgetc(fp)) != EOF )
|
||||||
@@ -396,7 +409,17 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
|
|||||||
if ( i == 0 && j == 0 && komodo_chosennotary(&nid,height,scriptbuf + 1) >= 0 )
|
if ( i == 0 && j == 0 && komodo_chosennotary(&nid,height,scriptbuf + 1) >= 0 )
|
||||||
{
|
{
|
||||||
if ( height < sizeof(Minerids)/sizeof(*Minerids) )
|
if ( height < sizeof(Minerids)/sizeof(*Minerids) )
|
||||||
Minerids[height] = nid;
|
{
|
||||||
|
if ( (Minerids[height]= nid) >= -1 )
|
||||||
|
{
|
||||||
|
if ( Minerfp != 0 )
|
||||||
|
{
|
||||||
|
fseek(Minerfp,height,SEEK_SET);
|
||||||
|
fputc(Minerids[height],Minerfp);
|
||||||
|
fflush(Minerfp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ( 0 && i > 0 )
|
if ( 0 && i > 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -470,11 +470,23 @@ int8_t komodo_minerid(int32_t height)
|
|||||||
int32_t notaryid; CBlockIndex *pindex; uint8_t pubkey33[33];
|
int32_t notaryid; CBlockIndex *pindex; uint8_t pubkey33[33];
|
||||||
if ( depth < 3 && height <= CURRENT_HEIGHT )//chainActive.Tip()->nHeight )
|
if ( depth < 3 && height <= CURRENT_HEIGHT )//chainActive.Tip()->nHeight )
|
||||||
{
|
{
|
||||||
|
if ( Minerids[height] >= -1 )
|
||||||
|
return(Minerids[height]);
|
||||||
if ( (pindex= chainActive[height]) != 0 )
|
if ( (pindex= chainActive[height]) != 0 )
|
||||||
{
|
{
|
||||||
depth++;
|
depth++;
|
||||||
komodo_index2pubkey33(pubkey33,pindex,height);
|
komodo_index2pubkey33(pubkey33,pindex,height);
|
||||||
komodo_chosennotary(¬aryid,height,pubkey33);
|
komodo_chosennotary(¬aryid,height,pubkey33);
|
||||||
|
if ( notaryid >= -1 )
|
||||||
|
{
|
||||||
|
Minerids[height] = notaryid;
|
||||||
|
if ( Minerfp != 0 )
|
||||||
|
{
|
||||||
|
fseek(Minerfp,height,SEEK_SET);
|
||||||
|
fputc(Minerids[height],Minerfp);
|
||||||
|
fflush(Minerfp);
|
||||||
|
}
|
||||||
|
}
|
||||||
depth--;
|
depth--;
|
||||||
return(notaryid);
|
return(notaryid);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user