changed sync requirement, use hash_bytes
This commit is contained in:
parent
80237390ff
commit
a050ee1e61
7 changed files with 13 additions and 10 deletions
|
@ -105,14 +105,15 @@ namespace sqlite
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int sync(database& db, std::size_t attempts = 200)
|
inline int sync(database& db, std::size_t attempts = 20)
|
||||||
{
|
{
|
||||||
int code = SQLITE_OK;
|
int code = SQLITE_OK;
|
||||||
for (auto i = 0u; i < attempts; ++i) {
|
for (auto i = 0u; i < attempts; ++i) {
|
||||||
code = sqlite3_wal_checkpoint_v2(db.connection().get(), nullptr, SQLITE_CHECKPOINT_FULL, nullptr, nullptr);
|
code = sqlite3_wal_checkpoint_v2(db.connection().get(), nullptr, SQLITE_CHECKPOINT_FULL, nullptr, nullptr);
|
||||||
if (code != SQLITE_OK) {
|
if (code != SQLITE_OK) {
|
||||||
|
sqlite3_wal_checkpoint_v2(db.connection().get(), nullptr, SQLITE_CHECKPOINT_PASSIVE, nullptr, nullptr);
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
std::this_thread::sleep_for(100ms);
|
std::this_thread::sleep_for(200ms);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
#include <blob.h>
|
#include <blob.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
#include <primitives/robin_hood.h>
|
||||||
|
|
||||||
class uint160 : public CBaseBlob<160>
|
class uint160 : public CBaseBlob<160>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@ -47,7 +49,7 @@ namespace std {
|
||||||
{
|
{
|
||||||
size_t operator()(const uint160& k) const
|
size_t operator()(const uint160& k) const
|
||||||
{
|
{
|
||||||
return *reinterpret_cast<const size_t*>(k.begin());
|
return robin_hood::hash_bytes(k.begin(), k.size());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -56,7 +58,7 @@ namespace std {
|
||||||
{
|
{
|
||||||
size_t operator()(const uint256& k) const
|
size_t operator()(const uint256& k) const
|
||||||
{
|
{
|
||||||
return *reinterpret_cast<const size_t*>(k.begin());
|
return robin_hood::hash_bytes(k.begin(), k.size());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ namespace std {
|
||||||
{
|
{
|
||||||
size_t operator()(const CKeyID& k) const
|
size_t operator()(const CKeyID& k) const
|
||||||
{
|
{
|
||||||
return *reinterpret_cast<const size_t*>(k.begin());
|
return robin_hood::hash_bytes(k.begin(), k.size());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace std {
|
||||||
{
|
{
|
||||||
size_t operator()(const CScriptID& k) const
|
size_t operator()(const CScriptID& k) const
|
||||||
{
|
{
|
||||||
return *reinterpret_cast<const size_t*>(k.begin());
|
return robin_hood::hash_bytes(k.begin(), k.size());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,7 +148,7 @@ bool CCoinsViewDB::BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBloc
|
||||||
code = sqlite::sync(db);
|
code = sqlite::sync(db);
|
||||||
if (code != SQLITE_OK) {
|
if (code != SQLITE_OK) {
|
||||||
LogPrintf("%s: Error syncing coin database. SQLite error: %d\n", __func__, code);
|
LogPrintf("%s: Error syncing coin database. SQLite error: %d\n", __func__, code);
|
||||||
return false;
|
// don't return false as it may happen if someone else is reading our DB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -338,7 +338,7 @@ bool CBlockTreeDB::BatchWrite(const std::vector<std::pair<int, const CBlockFileI
|
||||||
code = sqlite::sync(db);
|
code = sqlite::sync(db);
|
||||||
if (code != SQLITE_OK) {
|
if (code != SQLITE_OK) {
|
||||||
LogPrintf("%s: Error syncing block database. SQLite error: %d\n", __func__, code);
|
LogPrintf("%s: Error syncing block database. SQLite error: %d\n", __func__, code);
|
||||||
return false;
|
// don't return false here as this may happen if someone else is reading our DB
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -2206,7 +2206,7 @@ bool static FlushStateToDisk(const CChainParams& chainparams, CValidationState &
|
||||||
if (!CheckDiskSpace(48 * 2 * 2 * pcoinsTip->GetCacheSize()))
|
if (!CheckDiskSpace(48 * 2 * 2 * pcoinsTip->GetCacheSize()))
|
||||||
return state.Error("out of disk space");
|
return state.Error("out of disk space");
|
||||||
if (syncToDisk && !pclaimTrie->SyncToDisk())
|
if (syncToDisk && !pclaimTrie->SyncToDisk())
|
||||||
return state.Error("Failed to write to claim trie database");
|
LogPrintf("Failed to sync claim trie database to disk");
|
||||||
// Flush the chainstate (which may refer to block index entries).
|
// Flush the chainstate (which may refer to block index entries).
|
||||||
if (!pcoinsTip->Flush(syncToDisk))
|
if (!pcoinsTip->Flush(syncToDisk))
|
||||||
return AbortNode(state, "Failed to write to coin database");
|
return AbortNode(state, "Failed to write to coin database");
|
||||||
|
|
|
@ -148,7 +148,7 @@ extern std::atomic_bool g_is_mempool_loaded;
|
||||||
|
|
||||||
struct BlockMapHasher {
|
struct BlockMapHasher {
|
||||||
std::size_t operator()(const CBlockIndex* block) const {
|
std::size_t operator()(const CBlockIndex* block) const {
|
||||||
return *reinterpret_cast<const std::size_t*>(block->hash.begin());
|
return robin_hood::hash_bytes(block->hash.begin(), block->hash.size());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue