From 855dc114e9c1f7ae259e18685ca081cf92260b9d Mon Sep 17 00:00:00 2001 From: Jianping Wu Date: Tue, 18 Sep 2018 16:08:17 -0700 Subject: [PATCH] WIP: support two OPs. --- src/keva/main.cpp | 57 ------------ src/keva/main.h | 15 --- src/script/keva.cpp | 75 +++++++++++++++ src/script/keva.h | 207 +++++++++++++++++++++++++++++++++++++++++ src/script/script.h | 2 + src/wallet/rpckeva.cpp | 80 +++++++++++++++- 6 files changed, 359 insertions(+), 77 deletions(-) create mode 100644 src/script/keva.cpp diff --git a/src/keva/main.cpp b/src/keva/main.cpp index 1052d13b6..168304c21 100644 --- a/src/keva/main.cpp +++ b/src/keva/main.cpp @@ -18,21 +18,6 @@ #include -/* ************************************************************************** */ -/* CNameData. */ - -bool -CNameData::isExpired () const -{ - return isExpired (chainActive.Height ()); -} - -bool -CNameData::isExpired (unsigned h) const -{ - return ::isExpired (nHeight, h); -} - /* ************************************************************************** */ /* CNameTxUndo. */ @@ -152,48 +137,6 @@ CKevaMemPool::removeConflicts (const CTransaction& tx) } } -void -CKevaMemPool::removeUnexpireConflicts (const std::set& unexpired) -{ - AssertLockHeld (pool.cs); - - for (const auto& name : unexpired) - { - LogPrint (BCLog::NAMES, "unexpired: %s, mempool: %u\n", - ValtypeToString (name).c_str (), mapNameRegs.count (name)); - - const NameTxMap::const_iterator mit = mapNameRegs.find (name); - if (mit != mapNameRegs.end ()) - { - const CTxMemPool::txiter mit2 = pool.mapTx.find (mit->second); - assert (mit2 != pool.mapTx.end ()); - pool.removeRecursive (mit2->GetTx (), - MemPoolRemovalReason::NAME_CONFLICT); - } - } -} - -void -CKevaMemPool::removeExpireConflicts (const std::set& expired) -{ - AssertLockHeld (pool.cs); - - for (const auto& name : expired) - { - LogPrint (BCLog::NAMES, "expired: %s, mempool: %u\n", - ValtypeToString (name).c_str (), mapNameUpdates.count (name)); - - const NameTxMap::const_iterator mit = mapNameUpdates.find (name); - if (mit != mapNameUpdates.end ()) - { - const CTxMemPool::txiter mit2 = pool.mapTx.find (mit->second); - assert (mit2 != pool.mapTx.end ()); - pool.removeRecursive (mit2->GetTx (), - MemPoolRemovalReason::NAME_CONFLICT); - } - } -} - void CKevaMemPool::check (const CCoinsView& coins) const { diff --git a/src/keva/main.h b/src/keva/main.h index 038bfa1f7..01415f4db 100644 --- a/src/keva/main.h +++ b/src/keva/main.h @@ -201,21 +201,6 @@ public: */ void removeConflicts (const CTransaction& tx); - /** - * Remove conflicts in the mempool due to unexpired names. This removes - * conflicting name registrations that are no longer possible. - * @param unexpired The set of unexpired names. - * @param removed Put removed tx here. - */ - void removeUnexpireConflicts (const std::set& unexpired); - /** - * Remove conflicts in the mempool due to expired names. This removes - * conflicting name updates that are no longer possible. - * @param expired The set of expired names. - * @param removed Put removed tx here. - */ - void removeExpireConflicts (const std::set& expired); - /** * Perform sanity checks. Throws if it fails. * @param coins The coins view this represents. diff --git a/src/script/keva.cpp b/src/script/keva.cpp new file mode 100644 index 000000000..2f3f65f9d --- /dev/null +++ b/src/script/keva.cpp @@ -0,0 +1,75 @@ +// Copyright (c) 2014-2017 Daniel Kraft +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include