Test
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
|
||||
#include "komodo_defs.h"
|
||||
|
||||
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 komodo_init(int32_t height);
|
||||
|
||||
@@ -1696,3 +1696,24 @@ struct komodo_state *komodo_stateptr(char *symbol,char *dest)
|
||||
komodo_nameset(symbol,dest,ASSETCHAINS_SYMBOL);
|
||||
return(komodo_stateptrget(symbol));
|
||||
}
|
||||
|
||||
void komodo_prefetch(FILE *fp)
|
||||
{
|
||||
long fsize,fpos; int32_t incr = 16*1024*1024;
|
||||
fpos = ftell(fp);
|
||||
fseek(fp,0,SEEK_END);
|
||||
fsize = ftell(fp);
|
||||
if ( fsize > incr )
|
||||
{
|
||||
char *ignore = (char *)malloc(incr);
|
||||
if ( ignore != 0 )
|
||||
{
|
||||
rewind(fp);
|
||||
while ( fread(ignore,1,incr,fp) == incr ) // prefetch
|
||||
fprintf(stderr,".");
|
||||
free(ignore);
|
||||
}
|
||||
}
|
||||
fseek(fp,fpos,SEEK_SET);
|
||||
}
|
||||
|
||||
|
||||
20
src/main.cpp
20
src/main.cpp
@@ -4310,10 +4310,9 @@ bool CheckDiskSpace(uint64_t nAdditionalBytes)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly)
|
||||
{
|
||||
static int32_t didinit[64]; long fsize,fpos; int32_t incr = 16*1024*1024;
|
||||
static int32_t didinit[64];
|
||||
if (pos.IsNull())
|
||||
return NULL;
|
||||
boost::filesystem::path path = GetBlockPosFilename(pos, prefix);
|
||||
@@ -4327,22 +4326,7 @@ FILE* OpenDiskFile(const CDiskBlockPos &pos, const char *prefix, bool fReadOnly)
|
||||
}
|
||||
if ( pos.nFile < sizeof(didinit)/sizeof(*didinit) && didinit[pos.nFile] == 0 && strcmp(prefix,(char *)"blk") == 0 )
|
||||
{
|
||||
fpos = ftell(file);
|
||||
fseek(file,0,SEEK_END);
|
||||
fsize = ftell(file);
|
||||
if ( fsize > incr )
|
||||
{
|
||||
char *ignore = (char *)malloc(incr);
|
||||
if ( ignore != 0 )
|
||||
{
|
||||
rewind(file);
|
||||
while ( fread(ignore,1,incr,file) == incr ) // prefetch
|
||||
fprintf(stderr,".");
|
||||
free(ignore);
|
||||
// fprintf(stderr,"blk.%d loaded %ld bytes set fpos.%ld loading.%d\n",(int)pos.nFile,(long)ftell(file),(long)fpos,KOMODO_LOADINGBLOCKS);
|
||||
}
|
||||
}
|
||||
fseek(file,fpos,SEEK_SET);
|
||||
komodo_prefetch(file);
|
||||
didinit[pos.nFile] = 1;
|
||||
}
|
||||
if (pos.nPos) {
|
||||
|
||||
@@ -3041,15 +3041,25 @@ CAmount CWallet::GetMinimumFee(unsigned int nTxBytes, unsigned int nConfirmTarge
|
||||
}
|
||||
|
||||
|
||||
|
||||
void komodo_prefetch(FILE *fp);
|
||||
|
||||
DBErrors CWallet::LoadWallet(bool& fFirstRunRet)
|
||||
{
|
||||
if (!fFileBacked)
|
||||
return DB_LOAD_OK;
|
||||
fFirstRunRet = false;
|
||||
DBErrors nLoadWalletRet = CWalletDB(strWalletFile,"cr+").LoadWallet(this);
|
||||
fprintf(stderr,"loading wallet %s %u\n",strWalletFile.c_str(),(uint32_t)time(NULL));
|
||||
{
|
||||
FILE *fp;
|
||||
if ( (fp= fopen(strWalletFile.c_str(),"rb")) != 0 )
|
||||
{
|
||||
komodo_prefetch(fp);
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
fprintf(stderr,"prefetched wallet %s %u\n",strWalletFile.c_str(),(uint32_t)time(NULL));
|
||||
DBErrors nLoadWalletRet = CWalletDB(strWalletFile,"cr+").LoadWallet(this);
|
||||
fprintf(stderr,"loaded wallet %s %u\n",strWalletFile.c_str(),(uint32_t)time(NULL));
|
||||
if (nLoadWalletRet == DB_NEED_REWRITE)
|
||||
{
|
||||
if (CDB::Rewrite(strWalletFile, "\x04pool"))
|
||||
|
||||
Reference in New Issue
Block a user