@@ -117,7 +117,7 @@ CClaimTrie::CClaimTrie(std::size_t cacheBytes, bool fWipe, int height,
117117CClaimTrieCacheBase::~CClaimTrieCacheBase ()
118118{
119119 if (transacting) {
120- db << " rollback " ;
120+ db << " ROLLBACK " ;
121121 transacting = false ;
122122 }
123123 claimHashQuery.used (true );
@@ -438,14 +438,6 @@ void completeHash(uint256& partialHash, const std::string& key, int to)
438438 partialHash = Hash (it, it + 1 , partialHash.begin (), partialHash.end ());
439439}
440440
441- uint256 verifyEmptyTrie (const std::string& name)
442- {
443- if (!name.empty ())
444- logPrint << " Corrupt trie near: " << name << Clog::endl;
445- assert (name.empty ());
446- return emptyTrieHash;
447- }
448-
449441uint256 CClaimTrieCacheBase::computeNodeHash (const std::string& name, int takeoverHeight)
450442{
451443 const auto pos = name.size ();
@@ -466,7 +458,7 @@ uint256 CClaimTrieCacheBase::computeNodeHash(const std::string& name, int takeov
466458 }
467459 }
468460
469- return vchToHash.empty () ? verifyEmptyTrie (name) : Hash (vchToHash.begin (), vchToHash.end ());
461+ return vchToHash.empty () ? emptyTrieHash : Hash (vchToHash.begin (), vchToHash.end ());
470462}
471463
472464bool CClaimTrieCacheBase::checkConsistency ()
@@ -696,22 +688,24 @@ bool CClaimTrieCacheBase::addSupport(const std::string& name, const COutPoint& o
696688bool CClaimTrieCacheBase::removeClaim (const uint160& claimId, const COutPoint& outPoint, std::string& nodeName,
697689 int & validHeight, int & originalHeight)
698690{
699- ensureTransacting ();
700-
701691 // this gets tricky in that we may be removing an update
702692 // when going forward we spend a claim (aka, call removeClaim) before updating it (aka, call addClaim)
703693 // when going backwards we first remove the update by calling removeClaim
704694 // we then undo the spend of the previous one by calling addClaim with the original data
705695 // in order to maintain the proper takeover height the updater will need to use our height returned here
706696
707- auto query = db << " SELECT nodeName, activationHeight, originalHeight FROM claim WHERE claimID = ? AND txID = ? AND txN = ? AND expirationHeight >= ?"
697+ auto query = db << " SELECT nodeName, activationHeight, originalHeight FROM claim "
698+ " WHERE claimID = ? AND txID = ? AND txN = ? AND expirationHeight >= ?"
708699 << claimId << outPoint.hash << outPoint.n << nNextHeight;
709700 auto it = query.begin ();
710701 if (it == query.end ())
711702 return false ;
712703
713704 *it >> nodeName >> validHeight >> originalHeight;
714- db << " DELETE FROM claim WHERE claimID = ? AND txID = ? and txN = ?" << claimId << outPoint.hash << outPoint.n ;
705+
706+ ensureTransacting ();
707+ db << " DELETE FROM claim WHERE claimID = ? AND txID = ? AND txN = ?"
708+ << claimId << outPoint.hash << outPoint.n ;
715709 if (!db.rows_modified ())
716710 return false ;
717711
0 commit comments