I apologize for this moderate buchery, but we need to save the calls to base58::ToString

This commit is contained in:
JoelKatz
2013-02-20 11:58:57 -08:00
parent 3191bd4922
commit 24355e17fb

View File

@@ -7,6 +7,8 @@
#include <boost/format.hpp>
#include <boost/functional/hash.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/unordered_map.hpp>
#include <openssl/rand.h>
@@ -293,6 +295,9 @@ uint160 RippleAddress::getAccountID() const
}
}
static boost::mutex rncLock;
static boost::unordered_map< std::vector<unsigned char>, std::string > rncMap;
std::string RippleAddress::humanAccountID() const
{
switch (nVersion) {
@@ -300,7 +305,13 @@ std::string RippleAddress::humanAccountID() const
throw std::runtime_error("unset source - humanAccountID");
case VER_ACCOUNT_ID:
return ToString();
{
boost::mutex::scoped_lock sl(rncLock);
boost::unordered_map< std::vector<unsigned char>, std::string >::iterator it = rncMap.find(vchData);
if (it != rncMap.end())
return it->second;
return rncMap[vchData] = ToString();
}
case VER_ACCOUNT_PUBLIC:
{