Browse Source

delete more sprout shite, faster syncing

pull/5/head
Duke Leto 4 years ago
parent
commit
fb1facc821
  1. 31
      src/coins.cpp
  2. 4
      src/txdb.cpp
  3. 13
      src/txdb.h
  4. 8
      src/txmempool.h

31
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 <assert.h>
/**
@ -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<SproutMerkleTree, CAnchorsSproutMap, CAnchorsSproutMap::iterator, CAnchorsSproutCacheEntry>(
@ -290,14 +286,6 @@ void CCoinsViewCache::AbstractPopAnchor(
void CCoinsViewCache::PopAnchor(const uint256 &newrt, ShieldedType type) {
switch (type) {
case SPROUT:
AbstractPopAnchor<SproutMerkleTree, CAnchorsSproutMap, CAnchorsSproutCacheEntry>(
newrt,
SPROUT,
cacheSproutAnchors,
hashSproutAnchor
);
break;
case SAPLING:
AbstractPopAnchor<SaplingMerkleTree, CAnchorsSaplingMap, CAnchorsSaplingCacheEntry>(
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<CAnchorsSproutMap, CAnchorsSproutMap::iterator, CAnchorsSproutCacheEntry>(mapSproutAnchors, cacheSproutAnchors, cachedCoinsUsage);
::BatchWriteAnchors<CAnchorsSaplingMap, CAnchorsSaplingMap::iterator, CAnchorsSaplingCacheEntry>(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;

4
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 <stdint.h>
#include <boost/thread.hpp>
using namespace std;

13
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 <map>
#include <string>
#include <utility>
@ -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 <std::string, CAmount> &addressAmounts, UniValue *ret);
};
#endif // BITCOIN_TXDB_H
#endif // HUSH_TXDB_H

8
src/txmempool.h

@ -19,11 +19,10 @@
* *
******************************************************************************/
#ifndef BITCOIN_TXMEMPOOL_H
#define BITCOIN_TXMEMPOOL_H
#ifndef HUSH_TXMEMPOOL_H
#define HUSH_TXMEMPOOL_H
#include <list>
#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<uint256, const CTransaction*> mapSproutNullifiers;
std::map<uint256, const CTransaction*> mapSaplingNullifiers;
@ -298,4 +298,4 @@ public:
bool HaveCoins(const uint256 &txid) const;
};
#endif // BITCOIN_TXMEMPOOL_H
#endif // HUSH_TXMEMPOOL_H

Loading…
Cancel
Save