mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-29 07:25:51 +00:00
vs 2012
This commit is contained in:
@@ -181,9 +181,9 @@ bool TransactionAcquire::takeNodes(const std::list<SHAMapNode>& nodeIDs,
|
||||
}
|
||||
|
||||
void LCTransaction::setVote(const uint160& peer, bool votesYes)
|
||||
{ // Tracke a peer's yes/no vote on a particular disputed transaction
|
||||
std::pair<boost::unordered_map<uint160, bool>::iterator, bool> res =
|
||||
mVotes.insert(std::make_pair<uint160, bool>(peer, votesYes));
|
||||
{ // Track a peer's yes/no vote on a particular disputed transaction
|
||||
std::pair<boost::unordered_map<const uint160, bool>::iterator, bool> res =
|
||||
mVotes.insert(std::pair<const uint160, bool>(peer, votesYes));
|
||||
|
||||
if (res.second)
|
||||
{ // new vote
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
#ifndef __RPC_h__
|
||||
#define __RPC_h__
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
@@ -37,3 +40,5 @@ extern std::string HTTPReply(int nStatus, const std::string& strMsg);
|
||||
extern std::string JSONRPCReply(const Json::Value& result, const Json::Value& error, const Json::Value& id);
|
||||
|
||||
extern Json::Value JSONRPCError(int code, const std::string& message);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -29,9 +29,10 @@ public:
|
||||
typedef c_Key key_type;
|
||||
typedef c_Data data_type;
|
||||
|
||||
typedef boost::weak_ptr<data_type> weak_data_ptr;
|
||||
typedef boost::shared_ptr<data_type> data_ptr;
|
||||
typedef std::pair<time_t, data_ptr> cache_entry;
|
||||
typedef boost::weak_ptr<data_type> weak_data_ptr;
|
||||
typedef boost::shared_ptr<data_type> data_ptr;
|
||||
typedef std::pair<time_t, weak_data_ptr> cache_entry;
|
||||
typedef std::pair<key_type, cache_entry> cache_pair;
|
||||
|
||||
protected:
|
||||
mutable boost::recursive_mutex mLock;
|
||||
@@ -130,7 +131,7 @@ template<typename c_Key, typename c_Data> void TaggedCache<c_Key, c_Data>::sweep
|
||||
|
||||
if (TaggedCachePartition.doLog(lsTRACE) && (mapRemovals || cacheRemovals))
|
||||
Log(lsTRACE, TaggedCachePartition) << mName << ": cache = " << mCache.size() << "-" << cacheRemovals <<
|
||||
", map = " << mMap.size() << "-" << mapRemovals;
|
||||
", map = " << mMap.size() << "-" << mapRemovals;
|
||||
}
|
||||
|
||||
template<typename c_Key, typename c_Data> bool TaggedCache<c_Key, c_Data>::touch(const key_type& key)
|
||||
@@ -156,7 +157,7 @@ template<typename c_Key, typename c_Data> bool TaggedCache<c_Key, c_Data>::touch
|
||||
}
|
||||
|
||||
// In map but not cache, put in cache
|
||||
mCache.insert(std::make_pair(key, std::make_pair(time(NULL), weak_data_ptr(cit->second.second))));
|
||||
mCache.insert(cache_pair(key, cache_entry(time(NULL), weak_data_ptr(cit->second.second))));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -180,7 +181,7 @@ bool TaggedCache<c_Key, c_Data>::canonicalize(const key_type& key, boost::shared
|
||||
typename boost::unordered_map<key_type, weak_data_ptr>::iterator mit = mMap.find(key);
|
||||
if (mit == mMap.end())
|
||||
{ // not in map
|
||||
mCache.insert(std::make_pair(key, std::make_pair(time(NULL), data)));
|
||||
mCache.insert(cache_pair(key, cache_entry(time(NULL), data)));
|
||||
mMap.insert(std::make_pair(key, data));
|
||||
return false;
|
||||
}
|
||||
@@ -189,7 +190,7 @@ bool TaggedCache<c_Key, c_Data>::canonicalize(const key_type& key, boost::shared
|
||||
if (!cachedData)
|
||||
{ // in map, but expired. Update in map, insert in cache
|
||||
mit->second = data;
|
||||
mCache.insert(std::make_pair(key, std::make_pair(time(NULL), data)));
|
||||
mCache.insert(cache_pair(key, cache_entry(time(NULL), data)));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -208,7 +209,7 @@ bool TaggedCache<c_Key, c_Data>::canonicalize(const key_type& key, boost::shared
|
||||
cit->second.second = data;
|
||||
}
|
||||
else // no, add to cache
|
||||
mCache.insert(std::make_pair(key, std::make_pair(time(NULL), data)));
|
||||
mCache.insert(cache_pair(key, cache_entry(time(NULL), data)));
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -229,13 +230,13 @@ boost::shared_ptr<c_Data> TaggedCache<c_Key, c_Data>::fetch(const key_type& key)
|
||||
mMap.erase(mit);
|
||||
return cachedData;
|
||||
}
|
||||
|
||||
|
||||
// Valid in map, is it in the cache?
|
||||
typename boost::unordered_map<key_type, cache_entry>::iterator cit = mCache.find(key);
|
||||
if (cit != mCache.end())
|
||||
cit->second.first = time(NULL); // Yes, refresh
|
||||
else // No, add to cache
|
||||
mCache.insert(std::make_pair(key, std::make_pair(time(NULL), cachedData)));
|
||||
mCache.insert(cache_pair(key, cache_entry(time(NULL), cachedData)));
|
||||
|
||||
return cachedData;
|
||||
}
|
||||
@@ -257,4 +258,4 @@ bool TaggedCache<c_Key, c_Data>::retrieve(const key_type& key, c_Data& data)
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user