wip
This commit is contained in:
46
src/notarisationdb.cpp
Normal file
46
src/notarisationdb.cpp
Normal file
@@ -0,0 +1,46 @@
|
||||
#include "leveldbwrapper.h"
|
||||
#include "notarisationdb.h"
|
||||
#include "uint256.h"
|
||||
#include "cc/eval.h"
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
|
||||
NotarisationDB *pnotarisations;
|
||||
|
||||
|
||||
NotarisationDB::NotarisationDB(size_t nCacheSize, bool fMemory, bool fWipe) : CLevelDBWrapper(GetDataDir() / "notarisations", nCacheSize, fMemory, fWipe, false, 64) {
|
||||
}
|
||||
|
||||
NotarisationsInBlock GetNotarisationsInBlock(const CBlock &block, int nHeight)
|
||||
{
|
||||
EvalRef eval;
|
||||
NotarisationsInBlock vNotarisations;
|
||||
bool IsBackNotarisation = ASSETCHAINS_SYMBOL[0] != 0;
|
||||
|
||||
for (unsigned int i = 0; i < block.vtx.size(); i++) {
|
||||
CTransaction tx = block.vtx[i];
|
||||
if (eval->CheckNotaryInputs(tx, nHeight, block.nTime)) {
|
||||
NotarisationData data(IsBackNotarisation);
|
||||
if (ParseNotarisationOpReturn(tx, data))
|
||||
vNotarisations.push_back(std::make_pair(tx.GetHash(), data));
|
||||
else
|
||||
fprintf(stderr, "Warning: Couldn't parse notarisation for tx: %s at height %i\n",
|
||||
tx.GetHash().GetHex().data(), nHeight);
|
||||
}
|
||||
}
|
||||
return vNotarisations;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Write an index of KMD notarisation id -> backnotarisation
|
||||
*/
|
||||
void WriteBackNotarisations(NotarisationsInBlock notarisations)
|
||||
{
|
||||
BOOST_FOREACH(Notarisation &n, notarisations)
|
||||
{
|
||||
if (n.second.IsBackNotarisation)
|
||||
pnotarisations->Write(n.second.txHash, n);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user