Commit 15be5dac authored by Ariel Rodriguez's avatar Ariel Rodriguez Committed by Brannon King
Browse files

Remove unnecessary height field in removeClaim method

parent cccdce02
...@@ -144,7 +144,8 @@ def main(): ...@@ -144,7 +144,8 @@ def main():
command.extend(lines) command.extend(lines)
command.extend(['-style=file', '-fallback-style=none']) command.extend(['-style=file', '-fallback-style=none'])
p = subprocess.Popen(command, stdout=subprocess.PIPE, p = subprocess.Popen(command, stdout=subprocess.PIPE,
stderr=None, stdin=subprocess.PIPE) stderr=None,
stdin=subprocess.PIPE)
stdout, stderr = p.communicate() stdout, stderr = p.communicate()
if p.returncode != 0: if p.returncode != 0:
sys.exit(p.returncode); sys.exit(p.returncode);
......
...@@ -151,7 +151,7 @@ template<typename K> bool CClaimTrie::keyTypeEmpty(char keyType, K& dummy) const ...@@ -151,7 +151,7 @@ template<typename K> bool CClaimTrie::keyTypeEmpty(char keyType, K& dummy) const
{ {
boost::scoped_ptr<CDBIterator> pcursor(const_cast<CDBWrapper*>(&db)->NewIterator()); boost::scoped_ptr<CDBIterator> pcursor(const_cast<CDBWrapper*>(&db)->NewIterator());
pcursor->SeekToFirst(); pcursor->SeekToFirst();
while (pcursor->Valid()) while (pcursor->Valid())
{ {
std::pair<char, K> key; std::pair<char, K> key;
...@@ -1197,7 +1197,7 @@ bool CClaimTrieCache::recursiveComputeMerkleHash(CClaimTrieNode* tnCurrent, std: ...@@ -1197,7 +1197,7 @@ bool CClaimTrieCache::recursiveComputeMerkleHash(CClaimTrieNode* tnCurrent, std:
vchToHash.insert(vchToHash.end(), it->second->hash.begin(), it->second->hash.end()); vchToHash.insert(vchToHash.end(), it->second->hash.begin(), it->second->hash.end());
} }
} }
CClaimValue claim; CClaimValue claim;
bool hasClaim = tnCurrent->getBestClaim(claim); bool hasClaim = tnCurrent->getBestClaim(claim);
...@@ -1301,7 +1301,7 @@ bool CClaimTrieCache::insertClaimIntoTrie(const std::string& name, CClaimValue c ...@@ -1301,7 +1301,7 @@ bool CClaimTrieCache::insertClaimIntoTrie(const std::string& name, CClaimValue c
currentNode = childNode->second; currentNode = childNode->second;
continue; continue;
} }
// This next substring doesn't exist in the cache and the next // This next substring doesn't exist in the cache and the next
// character doesn't exist in current node's children, so check // character doesn't exist in current node's children, so check
// if the current node is in the cache, and if it's not, copy // if the current node is in the cache, and if it's not, copy
...@@ -1402,7 +1402,7 @@ bool CClaimTrieCache::removeClaimFromTrie(const std::string& name, const COutPoi ...@@ -1402,7 +1402,7 @@ bool CClaimTrieCache::removeClaimFromTrie(const std::string& name, const COutPoi
bool fChanged = false; bool fChanged = false;
assert(currentNode != NULL); assert(currentNode != NULL);
bool success = false; bool success = false;
if (currentNode->claims.empty()) if (currentNode->claims.empty())
{ {
LogPrintf("%s: Asked to remove claim from node without claims\n", __func__); LogPrintf("%s: Asked to remove claim from node without claims\n", __func__);
...@@ -1478,7 +1478,7 @@ bool CClaimTrieCache::recursivePruneName(CClaimTrieNode* tnCurrent, unsigned int ...@@ -1478,7 +1478,7 @@ bool CClaimTrieCache::recursivePruneName(CClaimTrieNode* tnCurrent, unsigned int
// tnCurrent isn't necessarily in the cache. If it's not, it // tnCurrent isn't necessarily in the cache. If it's not, it
// has to be added to the cache, so nothing is changed in the // has to be added to the cache, so nothing is changed in the
// trie. If the current node is added to the cache, however, // trie. If the current node is added to the cache, however,
// that does not imply that the parent node must be altered to // that does not imply that the parent node must be altered to
// reflect that its child is now in the cache, since it // reflect that its child is now in the cache, since it
// already has a character in its child map which will be used // already has a character in its child map which will be used
// when calculating the merkle root. // when calculating the merkle root.
...@@ -1653,20 +1653,20 @@ bool CClaimTrieCache::removeClaimFromQueue(const std::string& name, const COutPo ...@@ -1653,20 +1653,20 @@ bool CClaimTrieCache::removeClaimFromQueue(const std::string& name, const COutPo
return false; return false;
} }
bool CClaimTrieCache::undoAddClaim(const std::string& name, const COutPoint& outPoint, int nHeight) const bool CClaimTrieCache::undoAddClaim(const std::string& name, const COutPoint& outPoint) const
{ {
int throwaway; int throwaway;
return removeClaim(name, outPoint, nHeight, throwaway, false); return removeClaim(name, outPoint, throwaway, false);
} }
bool CClaimTrieCache::spendClaim(const std::string& name, const COutPoint& outPoint, int nHeight, int& nValidAtHeight) const bool CClaimTrieCache::spendClaim(const std::string& name, const COutPoint& outPoint, int& nValidAtHeight) const
{ {
return removeClaim(name, outPoint, nHeight, nValidAtHeight, true); return removeClaim(name, outPoint, nValidAtHeight, true);
} }
bool CClaimTrieCache::removeClaim(const std::string& name, const COutPoint& outPoint, int nHeight, int& nValidAtHeight, bool fCheckTakeover) const bool CClaimTrieCache::removeClaim(const std::string& name, const COutPoint& outPoint, int& nValidAtHeight, bool fCheckTakeover) const
{ {
LogPrintf("%s: name: %s, txhash: %s, nOut: %s, nHeight: %s, nCurrentHeight: %s\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nHeight, nCurrentHeight); LogPrintf("%s: name: %s, txhash: %s, nOut: %s, nCurrentHeight: %s\n", __func__, name, outPoint.hash.GetHex(), outPoint.n, nCurrentHeight);
bool removed = false; bool removed = false;
CClaimValue claim; CClaimValue claim;
if (removeClaimFromQueue(name, outPoint, claim)) if (removeClaimFromQueue(name, outPoint, claim))
...@@ -1680,7 +1680,7 @@ bool CClaimTrieCache::removeClaim(const std::string& name, const COutPoint& outP ...@@ -1680,7 +1680,7 @@ bool CClaimTrieCache::removeClaim(const std::string& name, const COutPoint& outP
if (removed == true) if (removed == true)
{ {
nValidAtHeight = claim.nValidAtHeight; nValidAtHeight = claim.nValidAtHeight;
int expirationHeight = nHeight + base->nExpirationTime; int expirationHeight = claim.nHeight + base->nExpirationTime;
removeFromExpirationQueue(name, outPoint, expirationHeight); removeFromExpirationQueue(name, outPoint, expirationHeight);
claimsToDelete.insert(claim); claimsToDelete.insert(claim);
} }
...@@ -2184,7 +2184,7 @@ bool CClaimTrieCache::incrementBlock(insertUndoType& insertUndo, claimQueueRowTy ...@@ -2184,7 +2184,7 @@ bool CClaimTrieCache::incrementBlock(insertUndoType& insertUndo, claimQueueRowTy
itSupportExpirationRow->second.clear(); itSupportExpirationRow->second.clear();
} }
// check each potentially taken over name to see if a takeover occurred. // check each potentially taken over name to see if a takeover occurred.
// if it did, then check the claim and support insertion queues for // if it did, then check the claim and support insertion queues for
// the names that have been taken over, immediately insert all claim and // the names that have been taken over, immediately insert all claim and
// supports for those names, and stick them in the insertUndo or // supports for those names, and stick them in the insertUndo or
// insertSupportUndo vectors, with the nValidAtHeight they had prior to // insertSupportUndo vectors, with the nValidAtHeight they had prior to
...@@ -2275,7 +2275,7 @@ bool CClaimTrieCache::incrementBlock(insertUndoType& insertUndo, claimQueueRowTy ...@@ -2275,7 +2275,7 @@ bool CClaimTrieCache::incrementBlock(insertUndoType& insertUndo, claimQueueRowTy
// remove all claims from the queue for that name // remove all claims from the queue for that name
itQueueNameRow->second.clear(); itQueueNameRow->second.clear();
} }
// //
// Then, get all supports in the queue for that name // Then, get all supports in the queue for that name
queueNameType::iterator itSupportQueueNameRow = getSupportQueueCacheNameRow(*itNamesToCheck, false); queueNameType::iterator itSupportQueueNameRow = getSupportQueueCacheNameRow(*itNamesToCheck, false);
if (itSupportQueueNameRow != supportQueueNameCache.end()) if (itSupportQueueNameRow != supportQueueNameCache.end())
...@@ -2390,7 +2390,7 @@ bool CClaimTrieCache::decrementBlock(insertUndoType& insertUndo, claimQueueRowTy ...@@ -2390,7 +2390,7 @@ bool CClaimTrieCache::decrementBlock(insertUndoType& insertUndo, claimQueueRowTy
assert(removeClaimFromTrie(itInsertUndo->name, itInsertUndo->outPoint, claim, false)); assert(removeClaimFromTrie(itInsertUndo->name, itInsertUndo->outPoint, claim, false));
queueNameType::iterator itQueueNameRow = getQueueCacheNameRow(itInsertUndo->name, true); queueNameType::iterator itQueueNameRow = getQueueCacheNameRow(itInsertUndo->name, true);
itQueueRow->second.push_back(std::make_pair(itInsertUndo->name, claim)); itQueueRow->second.push_back(std::make_pair(itInsertUndo->name, claim));
itQueueNameRow->second.push_back(outPointHeightType(itInsertUndo->outPoint, itInsertUndo->nHeight)); itQueueNameRow->second.push_back(outPointHeightType(itInsertUndo->outPoint, itInsertUndo->nHeight));
} }
for (std::vector<std::pair<std::string, int> >::iterator itTakeoverHeightUndo = takeoverHeightUndo.begin(); itTakeoverHeightUndo != takeoverHeightUndo.end(); ++itTakeoverHeightUndo) for (std::vector<std::pair<std::string, int> >::iterator itTakeoverHeightUndo = takeoverHeightUndo.begin(); itTakeoverHeightUndo != takeoverHeightUndo.end(); ++itTakeoverHeightUndo)
......
...@@ -212,7 +212,6 @@ struct nameOutPointHeightType ...@@ -212,7 +212,6 @@ struct nameOutPointHeightType
nameOutPointHeightType(std::string name, COutPoint outPoint, int nHeight) nameOutPointHeightType(std::string name, COutPoint outPoint, int nHeight)
: name(name), outPoint(outPoint), nHeight(nHeight) {} : name(name), outPoint(outPoint), nHeight(nHeight) {}
ADD_SERIALIZE_METHODS; ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation> template <typename Stream, typename Operation>
...@@ -323,6 +322,7 @@ public: ...@@ -323,6 +322,7 @@ public:
bool getLastTakeoverForName(const std::string& name, int& lastTakeoverHeight) const; bool getLastTakeoverForName(const std::string& name, int& lastTakeoverHeight) const;
claimsForNameType getClaimsForName(const std::string& name) const; claimsForNameType getClaimsForName(const std::string& name) const;
CAmount getEffectiveAmountForClaim(const std::string& name, const uint160& claimId, std::vector<CSupportValue>* supports = NULL) const; CAmount getEffectiveAmountForClaim(const std::string& name, const uint160& claimId, std::vector<CSupportValue>* supports = NULL) const;
CAmount getEffectiveAmountForClaim(const claimsForNameType& claims, const uint160& claimId, std::vector<CSupportValue>* supports = NULL) const; CAmount getEffectiveAmountForClaim(const claimsForNameType& claims, const uint160& claimId, std::vector<CSupportValue>* supports = NULL) const;
...@@ -484,10 +484,8 @@ public: ...@@ -484,10 +484,8 @@ public:
bool addClaim(const std::string& name, const COutPoint& outPoint, bool addClaim(const std::string& name, const COutPoint& outPoint,
uint160 claimId, CAmount nAmount, int nHeight) const; uint160 claimId, CAmount nAmount, int nHeight) const;
bool undoAddClaim(const std::string& name, const COutPoint& outPoint, bool undoAddClaim(const std::string& name, const COutPoint& outPoint) const;
int nHeight) const; bool spendClaim(const std::string& name, const COutPoint& outPoint, int& nValidAtHeight) const;
bool spendClaim(const std::string& name, const COutPoint& outPoint,
int nHeight, int& nValidAtHeight) const;
bool undoSpendClaim(const std::string& name, const COutPoint& outPoint, bool undoSpendClaim(const std::string& name, const COutPoint& outPoint,
uint160 claimId, CAmount nAmount, int nHeight, uint160 claimId, CAmount nAmount, int nHeight,
int nValidAtHeight) const; int nValidAtHeight) const;
...@@ -559,7 +557,7 @@ protected: ...@@ -559,7 +557,7 @@ protected:
mutable queueNameType supportQueueNameCache; mutable queueNameType supportQueueNameCache;
mutable expirationQueueType supportExpirationQueueCache; mutable expirationQueueType supportExpirationQueueCache;
mutable std::set<std::string> namesToCheckForTakeover; mutable std::set<std::string> namesToCheckForTakeover;
mutable std::map<std::string, int> cacheTakeoverHeights; mutable std::map<std::string, int> cacheTakeoverHeights;
mutable int nCurrentHeight; // Height of the block that is being worked on, which is mutable int nCurrentHeight; // Height of the block that is being worked on, which is
// one greater than the height of the chain's tip // one greater than the height of the chain's tip
mutable claimIndexElementListType claimsToAdd; mutable claimIndexElementListType claimsToAdd;
...@@ -578,9 +576,7 @@ protected: ...@@ -578,9 +576,7 @@ protected:
bool clear() const; bool clear() const;
bool removeClaim(const std::string& name, const COutPoint& outPoint, bool removeClaim(const std::string& name, const COutPoint& outPoint, int& nValidAtHeight, bool fCheckTakeover) const;
int nHeight, int& nValidAtHeight, bool fCheckTakeover) const;
bool addClaimToQueues(const std::string& name, CClaimValue& claim) const; bool addClaimToQueues(const std::string& name, CClaimValue& claim) const;
bool removeClaimFromQueue(const std::string& name, const COutPoint& outPoint, bool removeClaimFromQueue(const std::string& name, const COutPoint& outPoint,
CClaimValue& claim) const; CClaimValue& claim) const;
......
...@@ -963,13 +963,12 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state) ...@@ -963,13 +963,12 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
if (!MoneyRange(nValueOut)) if (!MoneyRange(nValueOut))
return state.DoS(100, false, REJECT_INVALID, "bad-txns-txouttotal-toolarge"); return state.DoS(100, false, REJECT_INVALID, "bad-txns-txouttotal-toolarge");
// check claimtrie transactions // check claimtrie transactions
if (ClaimScriptSize(txout.scriptPubKey) > MAX_CLAIM_SCRIPT_SIZE) if (ClaimScriptSize(txout.scriptPubKey) > MAX_CLAIM_SCRIPT_SIZE)
return state.DoS(100, false, REJECT_INVALID, "bad-txns-claimscriptsize-toolarge"); return state.DoS(100, false, REJECT_INVALID, "bad-txns-claimscriptsize-toolarge");
if (ClaimNameSize(txout.scriptPubKey) > MAX_CLAIM_NAME_SIZE) if (ClaimNameSize(txout.scriptPubKey) > MAX_CLAIM_NAME_SIZE)
return state.DoS(100, false, REJECT_INVALID, "bad-txns-claimscriptname-toolarge"); return state.DoS(100, false, REJECT_INVALID, "bad-txns-claimscriptname-toolarge");
} }
// Check for duplicate inputs // Check for duplicate inputs
...@@ -2194,8 +2193,7 @@ bool DisconnectBlock(const CBlock& block, CValidationState& state, const CBlockI ...@@ -2194,8 +2193,7 @@ bool DisconnectBlock(const CBlock& block, CValidationState& state, const CBlockI
} }
std::string name(vvchParams[0].begin(), vvchParams[0].end()); std::string name(vvchParams[0].begin(), vvchParams[0].end());
LogPrintf("%s: (txid: %s, nOut: %d) Trying to remove %s from the claim trie due to its block being disconnected\n", __func__, hash.ToString(), i, name.c_str()); LogPrintf("%s: (txid: %s, nOut: %d) Trying to remove %s from the claim trie due to its block being disconnected\n", __func__, hash.ToString(), i, name.c_str());
if (!trieCache.undoAddClaim(name, COutPoint(hash, i), pindex->nHeight)) if (!trieCache.undoAddClaim(name, COutPoint(hash, i))) {
{
LogPrintf("%s: Could not find the claim in the trie or the cache\n", __func__); LogPrintf("%s: Could not find the claim in the trie or the cache\n", __func__);
} }
} }
...@@ -2503,7 +2501,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin ...@@ -2503,7 +2501,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
flags |= SCRIPT_VERIFY_CHECKSEQUENCEVERIFY; flags |= SCRIPT_VERIFY_CHECKSEQUENCEVERIFY;
nLockTimeFlags |= LOCKTIME_VERIFY_SEQUENCE; nLockTimeFlags |= LOCKTIME_VERIFY_SEQUENCE;
} }
// v 13 LBRYcrd hard fork to extend expiration time // v 13 LBRYcrd hard fork to extend expiration time
if (pindex->nHeight == Params().GetConsensus().nExtendedClaimExpirationForkHeight) if (pindex->nHeight == Params().GetConsensus().nExtendedClaimExpirationForkHeight)
{ {
...@@ -2588,7 +2586,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin ...@@ -2588,7 +2586,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
typedef std::vector<std::pair<std::string, uint160> > spentClaimsType; typedef std::vector<std::pair<std::string, uint160> > spentClaimsType;
spentClaimsType spentClaims; spentClaimsType spentClaims;
for (unsigned int i = 0; i < tx.vin.size(); ++i) for (unsigned int i = 0; i < tx.vin.size(); ++i)
{ {
const CTxIn& txin = tx.vin[i]; const CTxIn& txin = tx.vin[i];
...@@ -2625,8 +2623,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin ...@@ -2625,8 +2623,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
std::string name(vvchParams[0].begin(), vvchParams[0].end()); std::string name(vvchParams[0].begin(), vvchParams[0].end());
int nValidAtHeight; int nValidAtHeight;
LogPrintf("%s: Removing %s from the claim trie. Tx: %s, nOut: %d\n", __func__, name, txin.prevout.hash.GetHex(), txin.prevout.n); LogPrintf("%s: Removing %s from the claim trie. Tx: %s, nOut: %d\n", __func__, name, txin.prevout.hash.GetHex(), txin.prevout.n);
if (trieCache.spendClaim(name, COutPoint(txin.prevout.hash, txin.prevout.n), coins->nHeight, nValidAtHeight)) if (trieCache.spendClaim(name, COutPoint(txin.prevout.hash, txin.prevout.n), nValidAtHeight)) {
{
mClaimUndoHeights[i] = nValidAtHeight; mClaimUndoHeights[i] = nValidAtHeight;
std::pair<std::string, uint160> entry(name, claimId); std::pair<std::string, uint160> entry(name, claimId);
spentClaims.push_back(entry); spentClaims.push_back(entry);
...@@ -2649,7 +2646,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin ...@@ -2649,7 +2646,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
} }
} }
} }
for (unsigned int i = 0; i < tx.vout.size(); ++i) for (unsigned int i = 0; i < tx.vout.size(); ++i)
{ {
const CTxOut& txout = tx.vout[i]; const CTxOut& txout = tx.vout[i];
...@@ -4218,8 +4215,8 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview, ...@@ -4218,8 +4215,8 @@ bool CVerifyDB::VerifyDB(const CChainParams& chainparams, CCoinsView *coinsview,
return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString()); return error("VerifyDB(): *** ReadBlockFromDisk failed at %d, hash=%s", pindex->nHeight, pindex->GetBlockHash().ToString());
// check level 1: verify block validity // check level 1: verify block validity
if (nCheckLevel >= 1 && !CheckBlock(block, state)) if (nCheckLevel >= 1 && !CheckBlock(block, state))
return error("%s: *** found bad block at %d, hash=%s (%s)\n", __func__, return error("%s: *** found bad block at %d, hash=%s (%s)\n", __func__,
pindex->nHeight, pindex->GetBlockHash().ToString(), FormatStateMessage(state)); pindex->nHeight, pindex->GetBlockHash().ToString(), FormatStateMessage(state));
// check level 2: verify undo validity // check level 2: verify undo validity
if (nCheckLevel >= 2 && pindex) { if (nCheckLevel >= 2 && pindex) {
CBlockUndo undo; CBlockUndo undo;
...@@ -4348,7 +4345,7 @@ bool LoadBlockIndex() ...@@ -4348,7 +4345,7 @@ bool LoadBlockIndex()
return true; return true;
} }
bool InitBlockIndex(const CChainParams& chainparams) bool InitBlockIndex(const CChainParams& chainparams)
{ {
LOCK(cs_main); LOCK(cs_main);
......
...@@ -294,8 +294,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s ...@@ -294,8 +294,7 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s
} }
std::string name(vvchParams[0].begin(), vvchParams[0].end()); std::string name(vvchParams[0].begin(), vvchParams[0].end());
int throwaway; int throwaway;
if (trieCache.spendClaim(name, COutPoint(txin.prevout.hash, txin.prevout.n), nTxinHeight, throwaway)) if (trieCache.spendClaim(name, COutPoint(txin.prevout.hash, txin.prevout.n), throwaway)) {
{
std::pair<std::string, uint160> entry(name, claimId); std::pair<std::string, uint160> entry(name, claimId);
spentClaims.push_back(entry); spentClaims.push_back(entry);
} }
...@@ -316,11 +315,11 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s ...@@ -316,11 +315,11 @@ CBlockTemplate* CreateNewBlock(const CChainParams& chainparams, const CScript& s
} }
} }
} }
for (unsigned int i = 0; i < tx.vout.size(); ++i) for (unsigned int i = 0; i < tx.vout.size(); ++i)
{ {
const CTxOut& txout = tx.vout[i]; const CTxOut& txout = tx.vout[i];
std::vector<std::vector<unsigned char> > vvchParams; std::vector<std::vector<unsigned char> > vvchParams;
int op; int op;
if (DecodeClaimScript(txout.scriptPubKey, op, vvchParams)) if (DecodeClaimScript(txout.scriptPubKey, op, vvchParams))
...@@ -568,7 +567,7 @@ void static BitcoinMiner(const CChainParams& chainparams) ...@@ -568,7 +567,7 @@ void static BitcoinMiner(const CChainParams& chainparams)
while (true) while (true)
{ {
unsigned int nHashesDone = 0; unsigned int nHashesDone = 0;
// Check if something found // Check if something found
while (true) while (true)
{ {
...@@ -599,7 +598,7 @@ void static BitcoinMiner(const CChainParams& chainparams) ...@@ -599,7 +598,7 @@ void static BitcoinMiner(const CChainParams& chainparams)
} }
if (found) if (found)
break; break;
// Meter hashes/sec // Meter hashes/sec
static int64_t nHashCounter; static int64_t nHashCounter;
if (nHPSTimerStart == 0) if (nHPSTimerStart == 0)
......
...@@ -24,37 +24,37 @@ using namespace std; ...@@ -24,37 +24,37 @@ using namespace std;
BOOST_FIXTURE_TEST_SUITE(claimtriebranching_tests, RegTestingSetup) BOOST_FIXTURE_TEST_SUITE(claimtriebranching_tests, RegTestingSetup)
//is a claim in queue //is a claim in queue
boost::test_tools::predicate_result boost::test_tools::predicate_result
is_claim_in_queue(std::string name, const CTransaction &tx) is_claim_in_queue(std::string name, const CTransaction &tx)
{ {
COutPoint outPoint(tx.GetHash(), 0); COutPoint outPoint(tx.GetHash(), 0);
int validAtHeight; int validAtHeight;
bool have_claim = pclaimTrie->haveClaimInQueue(name,outPoint,validAtHeight); bool have_claim = pclaimTrie->haveClaimInQueue(name, outPoint, validAtHeight);
if (have_claim){ if (have_claim){
return true; return true;
} }
else{ else{
boost::test_tools::predicate_result res(false); boost::test_tools::predicate_result res(false);
res.message()<<"Is not a claim in queue."; res.message() << "Is not a claim in queue.";
return res; return res;
} }
} }
// check if tx is best claim based on outpoint // check if tx is best claim based on outpoint
boost::test_tools::predicate_result boost::test_tools::predicate_result
is_best_claim(std::string name, const CTransaction &tx) is_best_claim(std::string name, const CTransaction &tx)
{ {
CClaimValue val; CClaimValue val;
COutPoint outPoint(tx.GetHash(), 0); COutPoint outPoint(tx.GetHash(), 0);
bool have_claim = pclaimTrie->haveClaim(name,outPoint); bool have_claim = pclaimTrie->haveClaim(name, outPoint);
bool have_info = pclaimTrie->getInfoForName(name, val); bool have_info = pclaimTrie->getInfoForName(name, val);
if (have_claim && have_info && val.outPoint == outPoint){ if (have_claim && have_info && val.outPoint == outPoint){
return true; return true;
} }
else{ else{
boost::test_tools::predicate_result res(false); boost::test_tools::predicate_result res(false);
res.message()<<"Is not best claim"; res.message() << "Is not best claim";
return res; return res;
} }
} }
...@@ -154,13 +154,13 @@ bool CreateCoinbases(unsigned int num_coinbases, std::vector<CTransaction>& coin ...@@ -154,13 +154,13 @@ bool CreateCoinbases(unsigned int num_coinbases, std::vector<CTransaction>& coin
} }
// Test Fixtures // Test Fixtures
struct ClaimTrieChainFixture{ struct ClaimTrieChainFixture{
std::vector<CTransaction> coinbase_txs; std::vector<CTransaction> coinbase_txs;
std::vector<int> marks; std::vector<int> marks;
int coinbase_txs_used; int coinbase_txs_used;
unsigned int num_txs; unsigned int num_txs;
unsigned int num_txs_for_next_block; unsigned int num_txs_for_next_block;
// these will take on regtest parameters // these will take on regtest parameters
const int expirationForkHeight; const int expirationForkHeight;
...@@ -177,7 +177,7 @@ struct ClaimTrieChainFixture{ ...@@ -177,7 +177,7 @@ struct ClaimTrieChainFixture{
ENTER_CRITICAL_SECTION(cs_main); ENTER_CRITICAL_SECTION(cs_main);
BOOST_CHECK(pclaimTrie->nCurrentHeight == chainActive.Height() + 1); BOOST_CHECK(pclaimTrie->nCurrentHeight == chainActive.Height() + 1);
num_txs_for_next_block = 0; num_txs_for_next_block = 0;
num_txs = 0; num_txs = 0;
coinbase_txs_used = 0; coinbase_txs_used = 0;
// generate coinbases to spend // generate coinbases to spend
CreateCoinbases(40, coinbase_txs); CreateCoinbases(40, coinbase_txs);
...@@ -205,30 +205,29 @@ struct ClaimTrieChainFixture{ ...@@ -205,30 +205,29 @@ struct ClaimTrieChainFixture{
BOOST_CHECK(AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, &txFeeRate)); BOOST_CHECK(AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, &txFeeRate));
} }
//spend a bid into some non claimtrie related unspent //spend a bid into some non claimtrie related unspent
CMutableTransaction Spend(const CTransaction &prev){ CMutableTransaction Spend(const CTransaction &prev){
uint32_t prevout = 0; uint32_t prevout = 0;
CMutableTransaction tx = BuildTransaction(prev,prevout); CMutableTransaction tx = BuildTransaction(prev, prevout);
tx.vout[0].scriptPubKey = CScript() << OP_TRUE; tx.vout[0].scriptPubKey = CScript() << OP_TRUE;
tx.vout[0].nValue = 1; tx.vout[0].nValue = 1;
CommitTx(tx); CommitTx(tx);
return tx; return tx;
} }
//make claim at the current block //make claim at the current block
CMutableTransaction MakeClaim(const CTransaction &prev, std::string name, std::string value, CMutableTransaction MakeClaim(const CTransaction& prev, std::string name, std::string value, CAmount quantity)
CAmount quantity)
{ {
uint32_t prevout = 0; uint32_t prevout = 0;
CMutableTransaction tx = BuildTransaction(prev,prevout); CMutableTransaction tx = BuildTransaction(prev,prevout);
tx.vout[0].scriptPubKey = ClaimNameScript(name,value); tx.vout[0].scriptPubKey = ClaimNameScript(name, value);
tx.vout[0].nValue = quantity; tx.vout[0].nValue = quantity;
CommitTx(tx); CommitTx(tx);
return tx; return tx;
} }
CMutableTransaction MakeClaim(const CTransaction& prev, std::string name, std::string value) CMutableTransaction MakeClaim(const CTransaction& prev, std::string name, std::string value)
...@@ -243,10 +242,10 @@ struct ClaimTrieChainFixture{ ...@@ -243,10 +242,10 @@ struct ClaimTrieChainFixture{
uint32_t prevout = 0; uint32_t prevout = 0;
CMutableTransaction tx = BuildTransaction(prev,prevout); CMutableTransaction tx = BuildTransaction(prev,prevout);
tx.vout[0].scriptPubKey = SupportClaimScript(name,claimId); tx.vout[0].scriptPubKey = SupportClaimScript(name, claimId);
tx.vout[0].nValue = quantity; tx.vout[0].nValue = quantity;
CommitTx(tx);