delete more sprout shite, faster syncing
This commit is contained in:
@@ -19,14 +19,12 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "coins.h"
|
#include "coins.h"
|
||||||
|
|
||||||
#include "memusage.h"
|
#include "memusage.h"
|
||||||
#include "random.h"
|
#include "random.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
#include "policy/fees.h"
|
#include "policy/fees.h"
|
||||||
#include "hush_defs.h"
|
#include "hush_defs.h"
|
||||||
#include "importcoin.h"
|
#include "importcoin.h"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -112,9 +110,7 @@ CCoinsViewCache::~CCoinsViewCache()
|
|||||||
|
|
||||||
size_t CCoinsViewCache::DynamicMemoryUsage() const {
|
size_t CCoinsViewCache::DynamicMemoryUsage() const {
|
||||||
return memusage::DynamicUsage(cacheCoins) +
|
return memusage::DynamicUsage(cacheCoins) +
|
||||||
memusage::DynamicUsage(cacheSproutAnchors) +
|
|
||||||
memusage::DynamicUsage(cacheSaplingAnchors) +
|
memusage::DynamicUsage(cacheSaplingAnchors) +
|
||||||
memusage::DynamicUsage(cacheSproutNullifiers) +
|
|
||||||
memusage::DynamicUsage(cacheSaplingNullifiers) +
|
memusage::DynamicUsage(cacheSaplingNullifiers) +
|
||||||
cachedCoinsUsage;
|
cachedCoinsUsage;
|
||||||
}
|
}
|
||||||
@@ -162,10 +158,9 @@ bool CCoinsViewCache::GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &t
|
|||||||
|
|
||||||
bool CCoinsViewCache::GetNullifier(const uint256 &nullifier, ShieldedType type) const {
|
bool CCoinsViewCache::GetNullifier(const uint256 &nullifier, ShieldedType type) const {
|
||||||
CNullifiersMap* cacheToUse;
|
CNullifiersMap* cacheToUse;
|
||||||
|
// SAPLING is the only current supported type but we may
|
||||||
|
// have more in The Future
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SPROUT:
|
|
||||||
cacheToUse = &cacheSproutNullifiers;
|
|
||||||
break;
|
|
||||||
case SAPLING:
|
case SAPLING:
|
||||||
cacheToUse = &cacheSaplingNullifiers;
|
cacheToUse = &cacheSaplingNullifiers;
|
||||||
break;
|
break;
|
||||||
@@ -219,6 +214,7 @@ void CCoinsViewCache::AbstractPushAnchor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: delete
|
||||||
template<> void CCoinsViewCache::PushAnchor(const SproutMerkleTree &tree)
|
template<> void CCoinsViewCache::PushAnchor(const SproutMerkleTree &tree)
|
||||||
{
|
{
|
||||||
AbstractPushAnchor<SproutMerkleTree, CAnchorsSproutMap, CAnchorsSproutMap::iterator, CAnchorsSproutCacheEntry>(
|
AbstractPushAnchor<SproutMerkleTree, CAnchorsSproutMap, CAnchorsSproutMap::iterator, CAnchorsSproutCacheEntry>(
|
||||||
@@ -290,14 +286,6 @@ void CCoinsViewCache::AbstractPopAnchor(
|
|||||||
|
|
||||||
void CCoinsViewCache::PopAnchor(const uint256 &newrt, ShieldedType type) {
|
void CCoinsViewCache::PopAnchor(const uint256 &newrt, ShieldedType type) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SPROUT:
|
|
||||||
AbstractPopAnchor<SproutMerkleTree, CAnchorsSproutMap, CAnchorsSproutCacheEntry>(
|
|
||||||
newrt,
|
|
||||||
SPROUT,
|
|
||||||
cacheSproutAnchors,
|
|
||||||
hashSproutAnchor
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case SAPLING:
|
case SAPLING:
|
||||||
AbstractPopAnchor<SaplingMerkleTree, CAnchorsSaplingMap, CAnchorsSaplingCacheEntry>(
|
AbstractPopAnchor<SaplingMerkleTree, CAnchorsSaplingMap, CAnchorsSaplingCacheEntry>(
|
||||||
newrt,
|
newrt,
|
||||||
@@ -388,11 +376,6 @@ uint256 CCoinsViewCache::GetBestBlock() const {
|
|||||||
|
|
||||||
uint256 CCoinsViewCache::GetBestAnchor(ShieldedType type) const {
|
uint256 CCoinsViewCache::GetBestAnchor(ShieldedType type) const {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case SPROUT:
|
|
||||||
if (hashSproutAnchor.IsNull())
|
|
||||||
hashSproutAnchor = base->GetBestAnchor(type);
|
|
||||||
return hashSproutAnchor;
|
|
||||||
break;
|
|
||||||
case SAPLING:
|
case SAPLING:
|
||||||
if (hashSaplingAnchor.IsNull())
|
if (hashSaplingAnchor.IsNull())
|
||||||
hashSaplingAnchor = base->GetBestAnchor(type);
|
hashSaplingAnchor = base->GetBestAnchor(type);
|
||||||
@@ -508,24 +491,20 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins,
|
|||||||
mapCoins.erase(itOld);
|
mapCoins.erase(itOld);
|
||||||
}
|
}
|
||||||
|
|
||||||
//::BatchWriteAnchors<CAnchorsSproutMap, CAnchorsSproutMap::iterator, CAnchorsSproutCacheEntry>(mapSproutAnchors, cacheSproutAnchors, cachedCoinsUsage);
|
|
||||||
::BatchWriteAnchors<CAnchorsSaplingMap, CAnchorsSaplingMap::iterator, CAnchorsSaplingCacheEntry>(mapSaplingAnchors, cacheSaplingAnchors, cachedCoinsUsage);
|
::BatchWriteAnchors<CAnchorsSaplingMap, CAnchorsSaplingMap::iterator, CAnchorsSaplingCacheEntry>(mapSaplingAnchors, cacheSaplingAnchors, cachedCoinsUsage);
|
||||||
|
|
||||||
//::BatchWriteNullifiers(mapSproutNullifiers, cacheSproutNullifiers);
|
|
||||||
::BatchWriteNullifiers(mapSaplingNullifiers, cacheSaplingNullifiers);
|
::BatchWriteNullifiers(mapSaplingNullifiers, cacheSaplingNullifiers);
|
||||||
|
|
||||||
hashSproutAnchor = hashSproutAnchorIn;
|
hashSproutAnchor = hashSproutAnchorIn;
|
||||||
hashSaplingAnchor = hashSaplingAnchorIn;
|
hashSaplingAnchor = hashSaplingAnchorIn;
|
||||||
hashBlock = hashBlockIn;
|
hashBlock = hashBlockIn;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CCoinsViewCache::Flush() {
|
bool CCoinsViewCache::Flush() {
|
||||||
bool fOk = base->BatchWrite(cacheCoins, hashBlock, hashSproutAnchor, hashSaplingAnchor, cacheSproutAnchors, cacheSaplingAnchors, cacheSproutNullifiers, cacheSaplingNullifiers);
|
bool fOk = base->BatchWrite(cacheCoins, hashBlock, hashSproutAnchor, hashSaplingAnchor, cacheSproutAnchors, cacheSaplingAnchors, cacheSproutNullifiers, cacheSaplingNullifiers);
|
||||||
cacheCoins.clear();
|
cacheCoins.clear();
|
||||||
//cacheSproutAnchors.clear();
|
|
||||||
cacheSaplingAnchors.clear();
|
cacheSaplingAnchors.clear();
|
||||||
//cacheSproutNullifiers.clear();
|
|
||||||
cacheSaplingNullifiers.clear();
|
cacheSaplingNullifiers.clear();
|
||||||
cachedCoinsUsage = 0;
|
cachedCoinsUsage = 0;
|
||||||
return fOk;
|
return fOk;
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
// Copyright (c) 2009-2010 Satoshi Nakamoto
|
||||||
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
// Copyright (c) 2009-2014 The Bitcoin Core developers
|
||||||
// Copyright (c) 2019-2020 The Hush developers
|
// Copyright (c) 2019-2020 The Hush developers
|
||||||
|
|
||||||
// Distributed under the GPLv3 software license, see the accompanying
|
// Distributed under the GPLv3 software license, see the accompanying
|
||||||
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
// file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html
|
||||||
|
|
||||||
@@ -21,16 +20,13 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "txdb.h"
|
#include "txdb.h"
|
||||||
|
|
||||||
#include "chainparams.h"
|
#include "chainparams.h"
|
||||||
#include "hash.h"
|
#include "hash.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "pow.h"
|
#include "pow.h"
|
||||||
#include "uint256.h"
|
#include "uint256.h"
|
||||||
#include "core_io.h"
|
#include "core_io.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|||||||
13
src/txdb.h
13
src/txdb.h
@@ -18,13 +18,14 @@
|
|||||||
* Removal or modification of this copyright notice is prohibited. *
|
* Removal or modification of this copyright notice is prohibited. *
|
||||||
* *
|
* *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
// jl777 is a KYC traitor and he told me that I knew more about the tx db than
|
||||||
|
// he did, lulz -- Duke
|
||||||
|
|
||||||
#ifndef BITCOIN_TXDB_H
|
#ifndef HUSH_TXDB_H
|
||||||
#define BITCOIN_TXDB_H
|
#define HUSH_TXDB_H
|
||||||
|
|
||||||
#include "coins.h"
|
#include "coins.h"
|
||||||
#include "dbwrapper.h"
|
#include "dbwrapper.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
@@ -48,7 +49,7 @@ struct CSpentIndexValue;
|
|||||||
class uint256;
|
class uint256;
|
||||||
|
|
||||||
//! -dbcache default (MiB)
|
//! -dbcache default (MiB)
|
||||||
static const int64_t nDefaultDbCache = 450;
|
static const int64_t nDefaultDbCache = 512;
|
||||||
//! max. -dbcache (MiB)
|
//! max. -dbcache (MiB)
|
||||||
static const int64_t nMaxDbCache = sizeof(void*) > 4 ? 16384 : 1024;
|
static const int64_t nMaxDbCache = sizeof(void*) > 4 ? 16384 : 1024;
|
||||||
//! min. -dbcache in (MiB)
|
//! min. -dbcache in (MiB)
|
||||||
@@ -63,13 +64,13 @@ protected:
|
|||||||
public:
|
public:
|
||||||
CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
|
CCoinsViewDB(size_t nCacheSize, bool fMemory = false, bool fWipe = false);
|
||||||
|
|
||||||
//bool GetSproutAnchorAt(const uint256 &rt, SproutMerkleTree &tree) const;
|
|
||||||
bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const;
|
bool GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &tree) const;
|
||||||
bool GetNullifier(const uint256 &nf, ShieldedType type) const;
|
bool GetNullifier(const uint256 &nf, ShieldedType type) const;
|
||||||
bool GetCoins(const uint256 &txid, CCoins &coins) const;
|
bool GetCoins(const uint256 &txid, CCoins &coins) const;
|
||||||
bool HaveCoins(const uint256 &txid) const;
|
bool HaveCoins(const uint256 &txid) const;
|
||||||
uint256 GetBestBlock() const;
|
uint256 GetBestBlock() const;
|
||||||
uint256 GetBestAnchor(ShieldedType type) const;
|
uint256 GetBestAnchor(ShieldedType type) const;
|
||||||
|
// TODO: get rid of this fucking sprout shite
|
||||||
bool BatchWrite(CCoinsMap &mapCoins,
|
bool BatchWrite(CCoinsMap &mapCoins,
|
||||||
const uint256 &hashBlock,
|
const uint256 &hashBlock,
|
||||||
const uint256 &hashSproutAnchor,
|
const uint256 &hashSproutAnchor,
|
||||||
@@ -120,4 +121,4 @@ public:
|
|||||||
bool Snapshot2(std::map <std::string, CAmount> &addressAmounts, UniValue *ret);
|
bool Snapshot2(std::map <std::string, CAmount> &addressAmounts, UniValue *ret);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_TXDB_H
|
#endif // HUSH_TXDB_H
|
||||||
|
|||||||
@@ -19,11 +19,10 @@
|
|||||||
* *
|
* *
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#ifndef BITCOIN_TXMEMPOOL_H
|
#ifndef HUSH_TXMEMPOOL_H
|
||||||
#define BITCOIN_TXMEMPOOL_H
|
#define HUSH_TXMEMPOOL_H
|
||||||
|
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include "addressindex.h"
|
#include "addressindex.h"
|
||||||
#include "spentindex.h"
|
#include "spentindex.h"
|
||||||
#include "amount.h"
|
#include "amount.h"
|
||||||
@@ -153,6 +152,7 @@ private:
|
|||||||
uint64_t nRecentlyAddedSequence = 0;
|
uint64_t nRecentlyAddedSequence = 0;
|
||||||
uint64_t nNotifiedSequence = 0;
|
uint64_t nNotifiedSequence = 0;
|
||||||
|
|
||||||
|
//TODO: remove, requires refactoring
|
||||||
std::map<uint256, const CTransaction*> mapSproutNullifiers;
|
std::map<uint256, const CTransaction*> mapSproutNullifiers;
|
||||||
std::map<uint256, const CTransaction*> mapSaplingNullifiers;
|
std::map<uint256, const CTransaction*> mapSaplingNullifiers;
|
||||||
|
|
||||||
@@ -298,4 +298,4 @@ public:
|
|||||||
bool HaveCoins(const uint256 &txid) const;
|
bool HaveCoins(const uint256 &txid) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // BITCOIN_TXMEMPOOL_H
|
#endif // HUSH_TXMEMPOOL_H
|
||||||
|
|||||||
Reference in New Issue
Block a user