Browse Source

Hush notarization database is too legit to quit

minor
Duke Leto 4 years ago
parent
commit
763c2def95
  1. 4
      src/init.cpp
  2. 8
      src/main.cpp
  3. 6
      src/notarizationdb.cpp
  4. 6
      src/notarizationdb.h
  5. 2
      src/test-hush/testutils.cpp

4
src/init.cpp

@ -1759,13 +1759,13 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
delete pcoinsdbview;
delete pcoinscatcher;
delete pblocktree;
delete pnotarisations;
delete pnotarizations;
pblocktree = new CBlockTreeDB(nBlockTreeDBCache, false, fReindex, dbCompression, dbMaxOpenFiles);
pcoinsdbview = new CCoinsViewDB(nCoinDBCache, false, fReindex);
pcoinscatcher = new CCoinsViewErrorCatcher(pcoinsdbview);
pcoinsTip = new CCoinsViewCache(pcoinscatcher);
pnotarisations = new NotarizationDB(100*1024*1024, false, fReindex);
pnotarizations = new NotarizationDB(100*1024*1024, false, fReindex);
if (fReindex) {

8
src/main.cpp

@ -2910,10 +2910,10 @@ void ConnectNotarizations(const CBlock &block, int height)
{
NotarisationsInBlock notarisations = ScanBlockNotarizations(block, height);
if (notarisations.size() > 0) {
CDBBatch batch = CDBBatch(*pnotarisations);
CDBBatch batch = CDBBatch(*pnotarizations);
batch.Write(block.GetHash(), notarisations);
WriteBackNotarisations(notarisations, batch);
pnotarisations->WriteBatch(batch, true);
pnotarizations->WriteBatch(batch, true);
LogPrintf("ConnectBlock: wrote %i block notarizations in block: %s\n",
notarisations.size(), block.GetHash().GetHex().data());
}
@ -2923,10 +2923,10 @@ void DisconnectNotarizations(const CBlock &block)
{
NotarisationsInBlock nibs;
if (GetBlockNotarisations(block.GetHash(), nibs)) {
CDBBatch batch = CDBBatch(*pnotarisations);
CDBBatch batch = CDBBatch(*pnotarizations);
batch.Erase(block.GetHash());
EraseBackNotarisations(nibs, batch);
pnotarisations->WriteBatch(batch, true);
pnotarizations->WriteBatch(batch, true);
LogPrintf("DisconnectTip: deleted %i block notarizations in block: %s\n",
nibs.size(), block.GetHash().GetHex().data());
}

6
src/notarizationdb.cpp

@ -9,7 +9,7 @@
#include "main.h"
#include <boost/foreach.hpp>
NotarizationDB *pnotarisations;
NotarizationDB *pnotarizations;
NotarizationDB::NotarizationDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper(GetDataDir() / "notarizations", nCacheSize, fMemory, fWipe, false, 64) { }
NotarisationsInBlock ScanBlockNotarizations(const CBlock &block, int nHeight)
@ -55,13 +55,13 @@ NotarisationsInBlock ScanBlockNotarizations(const CBlock &block, int nHeight)
bool GetBlockNotarisations(uint256 blockHash, NotarisationsInBlock &nibs)
{
return pnotarisations->Read(blockHash, nibs);
return pnotarizations->Read(blockHash, nibs);
}
bool GetBackNotarisation(uint256 notarisationHash, Notarisation &n)
{
return pnotarisations->Read(notarisationHash, n);
return pnotarizations->Read(notarisationHash, n);
}

6
src/notarizationdb.h

@ -8,13 +8,13 @@
#include "dbwrapper.h"
#include "cc/eval.h"
class NotarisationDB : public CDBWrapper
class NotarizationDB : public CDBWrapper
{
public:
NotarisationDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
NotarizationDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
};
extern NotarisationDB *pnotarisations;
extern NotarizationDB *pnotarizations;
typedef std::pair<uint256,NotarisationData> Notarisation;
typedef std::vector<Notarisation> NotarisationsInBlock;

2
src/test-hush/testutils.cpp

@ -56,7 +56,7 @@ void setupChain() {
pblocktree = new CBlockTreeDB(1 << 20, true);
CCoinsViewDB *pcoinsdbview = new CCoinsViewDB(1 << 23, true);
pcoinsTip = new CCoinsViewCache(pcoinsdbview);
pnotarisations = new NotarizationDB(1 << 20, true);
pnotarizations = new NotarizationDB(1 << 20, true);
InitBlockIndex();
}

Loading…
Cancel
Save