Hush witness rework, many thanks to @CryptoForge for this awesome code https://github.com/Cryptoforge-alt/pirate/tree/pirate_witness_rework

This commit is contained in:
DenioD
2020-02-15 14:14:39 +01:00
parent 4c39efccce
commit 6c48397cf3
11 changed files with 1233 additions and 281 deletions

View File

@@ -105,7 +105,7 @@ bool CDBEnv::Open(const boost::filesystem::path& pathIn)
nEnvFlags |= DB_PRIVATE;
dbenv->set_lg_dir(pathLogDir.string().c_str());
dbenv->set_cachesize(0, 0x100000, 1); // 1 MiB should be enough for just the wallet
dbenv->set_cachesize(1, 0x100000, 1); // 1 MiB should be enough for just the wallet, Increased by 1 GB
dbenv->set_lg_bsize(0x10000);
dbenv->set_lg_max(1048576);
dbenv->set_lk_max_locks(40000);
@@ -181,6 +181,55 @@ CDBEnv::VerifyResult CDBEnv::Verify(const std::string& strFile, bool (*recoverFu
return (fRecovered ? RECOVER_OK : RECOVER_FAIL);
}
bool CDBEnv::Compact(const std::string& strFile)
{
LOCK(cs_db);
DB_COMPACT dbcompact;
dbcompact.compact_fillpercent = 80;
dbcompact.compact_pages = DB_MAX_PAGES;
dbcompact.compact_timeout = 0;
DB_COMPACT *pdbcompact;
pdbcompact = &dbcompact;
int result = 1;
if (mapDb[strFile] != NULL) {
Db* pdb = mapDb[strFile];
result = pdb->compact(NULL, NULL, NULL, pdbcompact, DB_FREE_SPACE, NULL);
delete pdb;
mapDb[strFile] = NULL;
switch (result)
{
case DB_LOCK_DEADLOCK:
LogPrint("db","Deadlock %i\n", result);
break;
case DB_LOCK_NOTGRANTED:
LogPrint("db","Lock Not Granted %i\n", result);
break;
case DB_REP_HANDLE_DEAD:
LogPrint("db","Handle Dead %i\n", result);
break;
case DB_REP_LOCKOUT:
LogPrint("db","Rep Lockout %i\n", result);
break;
case EACCES:
LogPrint("db","Eacces %i\n", result);
break;
case EINVAL:
LogPrint("db","Error Invalid %i\n", result);
break;
case 0:
LogPrint("db","Wallet Compact Sucessful\n");
break;
default:
LogPrint("db","Compact result int %i\n", result);
}
}
return (result == 0);
}
bool CDBEnv::Salvage(const std::string& strFile, bool fAggressive, std::vector<CDBEnv::KeyValPair>& vResult)
{
LOCK(cs_db);