Use fully static linkage #364
5 changed files with 70 additions and 10 deletions
|
@ -417,4 +417,4 @@ bool CClaimTrieCacheHashFork::finalizeDecrement()
|
|||
bool CClaimTrieCacheHashFork::allowSupportMetadata() const
|
||||
{
|
||||
return nNextHeight >= base->nAllClaimsInMerkleForkHeight;
|
||||
}
|
||||
}
|
|
@ -888,3 +888,40 @@ void CClaimTrieCacheBase::getNamesInTrie(std::function<void(const std::string&)>
|
|||
callback(name);
|
||||
};
|
||||
}
|
||||
|
||||
std::vector<CUint160> CClaimTrieCacheBase::getActivatedClaims(int height) {
|
||||
std::vector<CUint160> ret;
|
||||
auto query = db << "SELECT DISTINCT claimID FROM claim WHERE activationHeight = ?1 AND blockHeight < ?1" << height;
|
||||
for (auto&& row: query) {
|
||||
ret.emplace_back();
|
||||
row >> ret.back();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
std::vector<CUint160> CClaimTrieCacheBase::getClaimsWithActivatedSupports(int height) {
|
||||
std::vector<CUint160> ret;
|
||||
auto query = db << "SELECT DISTINCT supportedClaimID FROM support WHERE activationHeight = ?1 AND blockHeight < ?1" << height;
|
||||
for (auto&& row: query) {
|
||||
ret.emplace_back();
|
||||
row >> ret.back();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
std::vector<CUint160> CClaimTrieCacheBase::getExpiredClaims(int height) {
|
||||
std::vector<CUint160> ret;
|
||||
auto query = db << "SELECT DISTINCT claimID FROM claim WHERE expirationHeight = ?1 AND blockHeight < ?1" << height;
|
||||
for (auto&& row: query) {
|
||||
ret.emplace_back();
|
||||
row >> ret.back();
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
std::vector<CUint160> CClaimTrieCacheBase::getClaimsWithExpiredSupports(int height) {
|
||||
std::vector<CUint160> ret;
|
||||
auto query = db << "SELECT DISTINCT supportedClaimID FROM support WHERE expirationHeight = ?1 AND blockHeight < ?1" << height;
|
||||
for (auto&& row: query) {
|
||||
ret.emplace_back();
|
||||
row >> ret.back();
|
||||
}
|
||||
return ret;
|
||||
}
|
|
@ -102,6 +102,11 @@ public:
|
|||
bool getLastTakeoverForName(const std::string& name, CUint160& claimId, int& takeoverHeight) const;
|
||||
bool findNameForClaim(std::vector<unsigned char> claim, CClaimValue& value, std::string& name) const;
|
||||
|
||||
std::vector<CUint160> getActivatedClaims(int height);
|
||||
std::vector<CUint160> getClaimsWithActivatedSupports(int height);
|
||||
std::vector<CUint160> getExpiredClaims(int height);
|
||||
std::vector<CUint160> getClaimsWithExpiredSupports(int height);
|
||||
|
||||
protected:
|
||||
int nNextHeight; // Height of the block that is being worked on, which is
|
||||
CClaimTrie* base;
|
||||
|
|
|
@ -751,22 +751,34 @@ UniValue getchangesinblock(const JSONRPCRequest& request)
|
|||
LOCK(cs_main);
|
||||
bool allowSupportMetadata;
|
||||
CCoinsViewCache coinsCache(pcoinsTip.get());
|
||||
|
||||
UniValue claimsAddUp(UniValue::VARR),
|
||||
claimsRm(UniValue::VARR),
|
||||
supportsAddUp(UniValue::VARR),
|
||||
supportsRm(UniValue::VARR);
|
||||
|
||||
{
|
||||
auto index = chainActive.Tip();
|
||||
if (request.params.size() > 0)
|
||||
index = BlockHashIndex(ParseHashV(request.params[0], T_BLOCKHASH " (optional parameter)"));
|
||||
|
||||
CClaimTrieCache trieCache(pclaimTrie);
|
||||
RollBackTo(index, coinsCache, trieCache);
|
||||
if (!ReadBlockFromDisk(block, index, Params().GetConsensus()))
|
||||
throw JSONRPCError(RPC_INTERNAL_ERROR,
|
||||
"Unable to read the undo block for height " + std::to_string(index->nHeight));
|
||||
|
||||
allowSupportMetadata = index->nHeight >= Params().GetConsensus().nAllClaimsInMerkleForkHeight;
|
||||
}
|
||||
|
||||
UniValue claimsAddUp(UniValue::VARR),
|
||||
claimsRm(UniValue::VARR),
|
||||
supportsAddUp(UniValue::VARR),
|
||||
supportsRm(UniValue::VARR);
|
||||
for (auto& claim: trieCache.getActivatedClaims(index->nHeight))
|
||||
claimsAddUp.push_back(claim.ToString());
|
||||
for (auto& claim: trieCache.getClaimsWithActivatedSupports(index->nHeight))
|
||||
supportsAddUp.push_back(claim.ToString());
|
||||
for (auto& claim: trieCache.getExpiredClaims(index->nHeight))
|
||||
claimsRm.push_back(claim.ToString());
|
||||
for (auto& claim: trieCache.getClaimsWithExpiredSupports(index->nHeight))
|
||||
supportsRm.push_back(claim.ToString());
|
||||
}
|
||||
|
||||
int op;
|
||||
std::vector<std::vector<unsigned char> > vvchParams;
|
||||
|
@ -802,6 +814,7 @@ UniValue getchangesinblock(const JSONRPCRequest& request)
|
|||
break;
|
||||
case OP_SUPPORT_CLAIM:
|
||||
supportsRm.push_back(uint160(vvchParams[1]).ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -815,11 +828,14 @@ UniValue getchangesinblock(const JSONRPCRequest& request)
|
|||
|
||||
switch (op) {
|
||||
case OP_CLAIM_NAME:
|
||||
case OP_UPDATE_CLAIM:
|
||||
claimsAddUp.push_back(ClaimIdHash(tx->GetHash(), i).ToString());
|
||||
break;
|
||||
case OP_UPDATE_CLAIM:
|
||||
claimsAddUp.push_back(uint160(vvchParams[1]).ToString());
|
||||
break;
|
||||
case OP_SUPPORT_CLAIM:
|
||||
supportsAddUp.push_back(ClaimIdHash(tx->GetHash(), i).ToString());
|
||||
supportsAddUp.push_back(uint160(vvchParams[1]).ToString());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -360,8 +360,10 @@ BOOST_AUTO_TEST_CASE(hash_bid_seq_claim_changes_test)
|
|||
req.params.push_back(UniValue(blockhash.GetHex()));
|
||||
|
||||
result = getchangesinblock(req);
|
||||
BOOST_CHECK_EQUAL(result[T_CLAIMSADDEDORUPDATED].size(), 1);
|
||||
BOOST_CHECK_EQUAL(result[T_CLAIMSADDEDORUPDATED][0].get_str(), claimId4.GetHex());
|
||||
BOOST_CHECK_EQUAL(result[T_CLAIMSADDEDORUPDATED].size(), 3);
|
||||
BOOST_CHECK_EQUAL(result[T_CLAIMSADDEDORUPDATED][0].get_str(), claimId2.GetHex());
|
||||
BOOST_CHECK_EQUAL(result[T_CLAIMSADDEDORUPDATED][1].get_str(), claimId3.GetHex());
|
||||
BOOST_CHECK_EQUAL(result[T_CLAIMSADDEDORUPDATED][2].get_str(), claimId4.GetHex());
|
||||
BOOST_CHECK_EQUAL(result[T_CLAIMSREMOVED].size(), 0);
|
||||
BOOST_CHECK_EQUAL(result[T_SUPPORTSADDEDORUPDATED].size(), 0);
|
||||
BOOST_CHECK_EQUAL(result[T_SUPPORTSREMOVED].size(), 0);
|
||||
|
|
Loading…
Reference in a new issue