Optimize the scanning of ntz's
This commit is contained in:
@@ -10,15 +10,19 @@
|
|||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
NotarisationDB *pnotarisations;
|
NotarisationDB *pnotarisations;
|
||||||
|
NotarisationDB::NotarisationDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper(GetDataDir() / "notarizations", nCacheSize, fMemory, fWipe, false, 64) { }
|
||||||
NotarisationDB::NotarisationDB(size_t nCacheSize, bool fMemory, bool fWipe) : CDBWrapper(GetDataDir() / "notarisations", nCacheSize, fMemory, fWipe, false, 64) { }
|
|
||||||
|
|
||||||
|
|
||||||
NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight)
|
NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight)
|
||||||
{
|
{
|
||||||
EvalRef eval;
|
EvalRef eval;
|
||||||
NotarisationsInBlock vNotarisations;
|
NotarisationsInBlock vNotarisations;
|
||||||
int timestamp = block.nTime;
|
int timestamp = block.nTime;
|
||||||
|
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
|
||||||
|
|
||||||
|
// No valid ntz's before this height
|
||||||
|
if(ishush3 && (nHeight <= 340420)) {
|
||||||
|
return vNotarisations;
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < block.vtx.size(); i++) {
|
for (unsigned int i = 0; i < block.vtx.size(); i++) {
|
||||||
CTransaction tx = block.vtx[i];
|
CTransaction tx = block.vtx[i];
|
||||||
@@ -44,18 +48,11 @@ NotarisationsInBlock ScanBlockNotarisations(const CBlock &block, int nHeight)
|
|||||||
// data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth);
|
// data.symbol, tx.GetHash().GetHex().data(), data.ccId, data.MoMDepth);
|
||||||
//if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data());
|
//if (!data.MoMoM.IsNull()) printf("MoMoM:%s\n", data.MoMoM.GetHex().data());
|
||||||
} else
|
} else
|
||||||
LogPrintf("WARNING: Couldn't parse notarisation for tx: %s at height %i\n",
|
LogPrintf("WARNING: Couldn't parse notarisation for tx: %s at height %i\n", tx.GetHash().GetHex().data(), nHeight);
|
||||||
tx.GetHash().GetHex().data(), nHeight);
|
|
||||||
}
|
}
|
||||||
return vNotarisations;
|
return vNotarisations;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsTXSCL(const char* symbol)
|
|
||||||
{
|
|
||||||
return strlen(symbol) >= 5 && strncmp(symbol, "TXSCL", 5) == 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
bool GetBlockNotarisations(uint256 blockHash, NotarisationsInBlock &nibs)
|
bool GetBlockNotarisations(uint256 blockHash, NotarisationsInBlock &nibs)
|
||||||
{
|
{
|
||||||
return pnotarisations->Read(blockHash, nibs);
|
return pnotarisations->Read(blockHash, nibs);
|
||||||
@@ -69,7 +66,7 @@ bool GetBackNotarisation(uint256 notarisationHash, Notarisation &n)
|
|||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Write an index of KMD notarisation id -> backnotarisation
|
* Write an index of HUSH notarisation id -> backnotarisation
|
||||||
*/
|
*/
|
||||||
void WriteBackNotarisations(const NotarisationsInBlock notarisations, CDBBatch &batch)
|
void WriteBackNotarisations(const NotarisationsInBlock notarisations, CDBBatch &batch)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
#ifndef NOTARISATIONDB_H
|
// Copyright (c) 2019-2020 The Hush developers
|
||||||
#define NOTARISATIONDB_H
|
// Distributed under the GPLv3 software license, see the accompanying
|
||||||
|
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||||
|
#ifndef HUSH_NOTARISATIONDB_H
|
||||||
|
#define HUSH_NOTARISATIONDB_H
|
||||||
|
|
||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
#include "dbwrapper.h"
|
#include "dbwrapper.h"
|
||||||
#include "cc/eval.h"
|
#include "cc/eval.h"
|
||||||
|
|
||||||
|
|
||||||
class NotarisationDB : public CDBWrapper
|
class NotarisationDB : public CDBWrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
NotarisationDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
|
NotarisationDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
extern NotarisationDB *pnotarisations;
|
extern NotarisationDB *pnotarisations;
|
||||||
|
|
||||||
typedef std::pair<uint256,NotarisationData> Notarisation;
|
typedef std::pair<uint256,NotarisationData> Notarisation;
|
||||||
typedef std::vector<Notarisation> NotarisationsInBlock;
|
typedef std::vector<Notarisation> NotarisationsInBlock;
|
||||||
|
|
||||||
@@ -25,6 +25,5 @@ void WriteBackNotarisations(const NotarisationsInBlock notarisations, CDBBatch &
|
|||||||
void EraseBackNotarisations(const NotarisationsInBlock notarisations, CDBBatch &batch);
|
void EraseBackNotarisations(const NotarisationsInBlock notarisations, CDBBatch &batch);
|
||||||
int ScanNotarisationsDB(int height, std::string symbol, int scanLimitBlocks, Notarisation& out);
|
int ScanNotarisationsDB(int height, std::string symbol, int scanLimitBlocks, Notarisation& out);
|
||||||
int ScanNotarisationsDB2(int height, std::string symbol, int scanLimitBlocks, Notarisation& out);
|
int ScanNotarisationsDB2(int height, std::string symbol, int scanLimitBlocks, Notarisation& out);
|
||||||
bool IsTXSCL(const char* symbol);
|
|
||||||
|
|
||||||
#endif /* NOTARISATIONDB_H */
|
#endif /* HUSH_NOTARISATIONDB_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user