std::string RippleAddress::humanAccountID () const { switch (nVersion) { case VER_NONE: throw std::runtime_error ("unset source - humanAccountID"); case VER_ACCOUNT_ID: { boost::mutex::scoped_lock sl (rncLock); boost::unordered_map< Blob , std::string >::iterator it = rncMap.find (vchData); if (it != rncMap.end ()) return it->second; if (rncMap.size () > 10000) rncMap.clear (); return rncMap[vchData] = ToString (); } case VER_ACCOUNT_PUBLIC: { RippleAddress accountID; (void) accountID.setAccountID (getAccountID ()); return accountID.ToString (); } default: throw std::runtime_error (str (boost::format ("bad source: %d") % int (nVersion))); } }
std::string RippleAddress::humanAccountID() const { switch (nVersion) { case VER_NONE: throw std::runtime_error("unset source - humanAccountID"); case VER_ACCOUNT_ID: return ToString(); case VER_ACCOUNT_PUBLIC: { RippleAddress accountID; (void) accountID.setAccountID(getAccountID()); return accountID.ToString(); } default: throw std::runtime_error(str(boost::format("bad source: %d") % int(nVersion))); } }
std::string RippleAddress::humanAccountID () const { switch (nVersion) { case VER_NONE: throw std::runtime_error ("unset source - humanAccountID"); case VER_ACCOUNT_ID: { StaticScopedLockType sl (s_lock); auto it = rncMap.find (vchData); if (it != rncMap.end ()) return it->second; // VFALCO NOTE Why do we throw everything out? We could keep two maps // here, switch back and forth keep one of them full and clear the // other on a swap - but always check both maps for cache hits. // if (rncMap.size () > 250000) rncMap.clear (); return rncMap[vchData] = ToString (); } case VER_ACCOUNT_PUBLIC: { RippleAddress accountID; (void) accountID.setAccountID (getAccountID ()); return accountID.ToString (); } default: throw std::runtime_error (str (boost::format ("bad source: %d") % int (nVersion))); } }