From fb1facc82191cd7140d08731ff4cc008dd1ccbe4 Mon Sep 17 00:00:00 2001 From: Duke Leto Date: Fri, 4 Dec 2020 08:36:28 -0500 Subject: [PATCH] delete more sprout shite, faster syncing --- src/coins.cpp | 31 +++++-------------------------- src/txdb.cpp | 4 ---- src/txdb.h | 13 +++++++------ src/txmempool.h | 8 ++++---- 4 files changed, 16 insertions(+), 40 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index 1231b101e..95600f224 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -19,14 +19,12 @@ ******************************************************************************/ #include "coins.h" - #include "memusage.h" #include "random.h" #include "version.h" #include "policy/fees.h" #include "hush_defs.h" #include "importcoin.h" - #include /** @@ -112,9 +110,7 @@ CCoinsViewCache::~CCoinsViewCache() size_t CCoinsViewCache::DynamicMemoryUsage() const { return memusage::DynamicUsage(cacheCoins) + - memusage::DynamicUsage(cacheSproutAnchors) + memusage::DynamicUsage(cacheSaplingAnchors) + - memusage::DynamicUsage(cacheSproutNullifiers) + memusage::DynamicUsage(cacheSaplingNullifiers) + cachedCoinsUsage; } @@ -162,10 +158,9 @@ bool CCoinsViewCache::GetSaplingAnchorAt(const uint256 &rt, SaplingMerkleTree &t bool CCoinsViewCache::GetNullifier(const uint256 &nullifier, ShieldedType type) const { CNullifiersMap* cacheToUse; + // SAPLING is the only current supported type but we may + // have more in The Future switch (type) { - case SPROUT: - cacheToUse = &cacheSproutNullifiers; - break; case SAPLING: cacheToUse = &cacheSaplingNullifiers; break; @@ -219,6 +214,7 @@ void CCoinsViewCache::AbstractPushAnchor( } } +//TODO: delete template<> void CCoinsViewCache::PushAnchor(const SproutMerkleTree &tree) { AbstractPushAnchor( @@ -290,14 +286,6 @@ void CCoinsViewCache::AbstractPopAnchor( void CCoinsViewCache::PopAnchor(const uint256 &newrt, ShieldedType type) { switch (type) { - case SPROUT: - AbstractPopAnchor( - newrt, - SPROUT, - cacheSproutAnchors, - hashSproutAnchor - ); - break; case SAPLING: AbstractPopAnchor( newrt, @@ -388,11 +376,6 @@ uint256 CCoinsViewCache::GetBestBlock() const { uint256 CCoinsViewCache::GetBestAnchor(ShieldedType type) const { switch (type) { - case SPROUT: - if (hashSproutAnchor.IsNull()) - hashSproutAnchor = base->GetBestAnchor(type); - return hashSproutAnchor; - break; case SAPLING: if (hashSaplingAnchor.IsNull()) hashSaplingAnchor = base->GetBestAnchor(type); @@ -508,24 +491,20 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins, mapCoins.erase(itOld); } - //::BatchWriteAnchors(mapSproutAnchors, cacheSproutAnchors, cachedCoinsUsage); ::BatchWriteAnchors(mapSaplingAnchors, cacheSaplingAnchors, cachedCoinsUsage); - //::BatchWriteNullifiers(mapSproutNullifiers, cacheSproutNullifiers); ::BatchWriteNullifiers(mapSaplingNullifiers, cacheSaplingNullifiers); - hashSproutAnchor = hashSproutAnchorIn; + hashSproutAnchor = hashSproutAnchorIn; hashSaplingAnchor = hashSaplingAnchorIn; - hashBlock = hashBlockIn; + hashBlock = hashBlockIn; return true; } bool CCoinsViewCache::Flush() { bool fOk = base->BatchWrite(cacheCoins, hashBlock, hashSproutAnchor, hashSaplingAnchor, cacheSproutAnchors, cacheSaplingAnchors, cacheSproutNullifiers, cacheSaplingNullifiers); cacheCoins.clear(); - //cacheSproutAnchors.clear(); cacheSaplingAnchors.clear(); - //cacheSproutNullifiers.clear(); cacheSaplingNullifiers.clear(); cachedCoinsUsage = 0; return fOk; diff --git a/src/txdb.cpp b/src/txdb.cpp index b007b96d0..fdae60306 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -1,7 +1,6 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto // Copyright (c) 2009-2014 The Bitcoin Core developers // Copyright (c) 2019-2020 The Hush developers - // Distributed under the GPLv3 software license, see the accompanying // file COPYING or https://www.gnu.org/licenses/gpl-3.0.en.html @@ -21,16 +20,13 @@ ******************************************************************************/ #include "txdb.h" - #include "chainparams.h" #include "hash.h" #include "main.h" #include "pow.h" #include "uint256.h" #include "core_io.h" - #include - #include using namespace std; diff --git a/src/txdb.h b/src/txdb.h index 4af616d58..b36f20151 100644 --- a/src/txdb.h +++ b/src/txdb.h @@ -18,13 +18,14 @@ * 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 -#define BITCOIN_TXDB_H +#ifndef HUSH_TXDB_H +#define HUSH_TXDB_H #include "coins.h" #include "dbwrapper.h" - #include #include #include @@ -48,7 +49,7 @@ struct CSpentIndexValue; class uint256; //! -dbcache default (MiB) -static const int64_t nDefaultDbCache = 450; +static const int64_t nDefaultDbCache = 512; //! max. -dbcache (MiB) static const int64_t nMaxDbCache = sizeof(void*) > 4 ? 16384 : 1024; //! min. -dbcache in (MiB) @@ -63,13 +64,13 @@ protected: public: 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 GetNullifier(const uint256 &nf, ShieldedType type) const; bool GetCoins(const uint256 &txid, CCoins &coins) const; bool HaveCoins(const uint256 &txid) const; uint256 GetBestBlock() const; uint256 GetBestAnchor(ShieldedType type) const; + // TODO: get rid of this fucking sprout shite bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, const uint256 &hashSproutAnchor, @@ -120,4 +121,4 @@ public: bool Snapshot2(std::map &addressAmounts, UniValue *ret); }; -#endif // BITCOIN_TXDB_H +#endif // HUSH_TXDB_H diff --git a/src/txmempool.h b/src/txmempool.h index 966ee087b..f98680dcb 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -19,11 +19,10 @@ * * ******************************************************************************/ -#ifndef BITCOIN_TXMEMPOOL_H -#define BITCOIN_TXMEMPOOL_H +#ifndef HUSH_TXMEMPOOL_H +#define HUSH_TXMEMPOOL_H #include - #include "addressindex.h" #include "spentindex.h" #include "amount.h" @@ -153,6 +152,7 @@ private: uint64_t nRecentlyAddedSequence = 0; uint64_t nNotifiedSequence = 0; + //TODO: remove, requires refactoring std::map mapSproutNullifiers; std::map mapSaplingNullifiers; @@ -298,4 +298,4 @@ public: bool HaveCoins(const uint256 &txid) const; }; -#endif // BITCOIN_TXMEMPOOL_H +#endif // HUSH_TXMEMPOOL_H