improve integrity check time

This commit is contained in:
Brannon King 2020-01-28 10:41:02 -07:00
parent d020cee7f5
commit 558f85e411
2 changed files with 13 additions and 3 deletions

View file

@ -436,11 +436,21 @@ uint256 CClaimTrieCacheBase::computeNodeHash(const std::string& name, int takeov
bool CClaimTrieCacheBase::checkConsistency() bool CClaimTrieCacheBase::checkConsistency()
{ {
// verify that all claims hash to the values on the nodes auto checkQuery = db << "PRAGMA quick_check";
for (auto&& row: checkQuery) {
std::string message;
row >> message;
if (message != "ok") {
logPrint << message << Clog::endl;
return false;
}
}
// not checking everything as it takes too long
auto query = db << "SELECT n.name, n.hash, " auto query = db << "SELECT n.name, n.hash, "
"IFNULL((SELECT CASE WHEN t.claimID IS NULL THEN 0 ELSE t.height END " "IFNULL((SELECT CASE WHEN t.claimID IS NULL THEN 0 ELSE t.height END "
"FROM takeover t WHERE t.name = n.name ORDER BY t.height DESC LIMIT 1), 0) FROM node n"; "FROM takeover t WHERE t.name = n.name ORDER BY t.height DESC LIMIT 1), 0) FROM node n "
"WHERE n.name IN (SELECT r.name FROM node r ORDER BY RANDOM() LIMIT 56789) OR LENGTH(n.parent) < 2";
for (auto&& row: query) { for (auto&& row: query) {
std::string name; std::string name;
uint256 hash; uint256 hash;

View file

@ -288,7 +288,7 @@ CLAIM_OUTPUT
"]", "]",
// GETCLAIMPROOFBYBID // GETCLAIMPROOFBYBID
S1("getclaimproofbyid \"" T_NAME "\" ( " T_BID " \"" T_BLOCKHASH R"(" ) S1("getclaimproofbybid \"" T_NAME "\" ( " T_BID " \"" T_BLOCKHASH R"(" )
Return the cryptographic proof that a name maps to a value or doesn't by a bid. Return the cryptographic proof that a name maps to a value or doesn't by a bid.
Arguments:)") Arguments:)")
S3("1. ", T_NAME, NAME_TEXT) S3("1. ", T_NAME, NAME_TEXT)