From 9a025be1517ee35a45379d7ae1285051ca1d59f8 Mon Sep 17 00:00:00 2001 From: Jianping Wu Date: Wed, 12 Dec 2018 15:19:21 -0800 Subject: [PATCH] Implemented keva_filter. --- src/coins.cpp | 8 +- src/coins.h | 8 +- src/keva/common.cpp | 126 +++++++++----------- src/keva/common.h | 42 ++++--- src/keva/main.cpp | 23 +--- src/keva/main.h | 2 +- src/script/keva.h | 2 +- src/test/keva_tests.cpp | 17 ++- src/txdb.cpp | 31 ++--- src/txdb.h | 2 +- src/wallet/rpckeva.cpp | 247 +++++++++++++++++++++++++++++++++++++-- src/wallet/rpcwallet.cpp | 4 +- 12 files changed, 355 insertions(+), 157 deletions(-) diff --git a/src/coins.cpp b/src/coins.cpp index b9a74e712..fcc591513 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -13,7 +13,7 @@ std::vector CCoinsView::GetHeadBlocks() const { return std::vector& names) const { return false; } -CNameIterator* CCoinsView::IterateNames() const { assert (false); } +CKevaIterator* CCoinsView::IterateKeys(const valtype& nameSpace) const { assert (false); } bool CCoinsView::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, const CKevaCache &names) { return false; } CCoinsViewCursor *CCoinsView::Cursor() const { return nullptr; } bool CCoinsView::ValidateNameDB() const { return false; } @@ -38,7 +38,7 @@ bool CCoinsViewBacked::GetName(const valtype &nameSpace, const valtype &key, CKe bool CCoinsViewBacked::GetNamesForHeight(unsigned nHeight, std::set& names) const { return base->GetNamesForHeight(nHeight, names); } -CNameIterator* CCoinsViewBacked::IterateNames() const { return base->IterateNames(); } +CKevaIterator* CCoinsViewBacked::IterateKeys(const valtype& nameSpace) const { return base->IterateKeys(nameSpace); } void CCoinsViewBacked::SetBackend(CCoinsView &viewIn) { base = &viewIn; } bool CCoinsViewBacked::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, const CKevaCache &names) { return base->BatchWrite(mapCoins, hashBlock, names); @@ -190,8 +190,8 @@ bool CCoinsViewCache::GetNamesForHeight(unsigned nHeight, std::set& nam return true; } -CNameIterator* CCoinsViewCache::IterateNames() const { - return cacheNames.iterateNames(base->IterateNames()); +CKevaIterator* CCoinsViewCache::IterateKeys(const valtype& nameSpace) const { + return cacheNames.iterateKeys(base->IterateKeys(nameSpace)); } /* undo is set if the change is due to disconnecting blocks / going back in diff --git a/src/coins.h b/src/coins.h index 5e0f178e2..9a529c74c 100644 --- a/src/coins.h +++ b/src/coins.h @@ -173,8 +173,8 @@ public: // Query for names that were updated at the given height virtual bool GetNamesForHeight(unsigned nHeight, std::set& names) const; - // Get a name iterator. - virtual CNameIterator* IterateNames() const; + // Get a key iterator. + virtual CKevaIterator* IterateKeys(const valtype& nameSpace) const; //! Do a bulk modification (multiple Coin changes + BestBlock change). //! The passed mapCoins can be modified. @@ -209,7 +209,7 @@ public: bool GetNamespace(const valtype& nameSpace, CKevaData& data) const override; bool GetName(const valtype& nameSpace, const valtype& key, CKevaData& data) const override; bool GetNamesForHeight(unsigned nHeight, std::set& names) const override; - CNameIterator* IterateNames() const override; + CKevaIterator* IterateKeys(const valtype& nameSpace) const override; void SetBackend(CCoinsView &viewIn); bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, const CKevaCache &names) override; CCoinsViewCursor *Cursor() const override; @@ -251,7 +251,7 @@ public: bool GetNamespace(const valtype &nameSpace, CKevaData& data) const override; bool GetName(const valtype &nameSpace, const valtype &key, CKevaData& data) const override; bool GetNamesForHeight(unsigned nHeight, std::set& names) const override; - CNameIterator* IterateNames() const override; + CKevaIterator* IterateKeys(const valtype& nameSpace) const override; bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock, const CKevaCache &names) override; CCoinsViewCursor* Cursor() const override { throw std::logic_error("CCoinsViewCache cursor iteration not supported."); diff --git a/src/keva/common.cpp b/src/keva/common.cpp index ad2ab24e2..dceb0b602 100644 --- a/src/keva/common.cpp +++ b/src/keva/common.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -// Copyright (c) 2018 Jianping Wu +// Copyright (c) 2018 the Kevacoin Core Developers // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. @@ -10,9 +10,6 @@ #include