mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 06:25:51 +00:00
Tidy up AccountState
This commit is contained in:
@@ -22,8 +22,7 @@ protected:
|
||||
void simplify();
|
||||
|
||||
public:
|
||||
|
||||
RangeSet() { ; }
|
||||
RangeSet () { }
|
||||
|
||||
bool hasValue(uint32) const;
|
||||
uint32 getFirst() const;
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#include "src/cpp/ripple/ripple_SerializedLedger.h"
|
||||
#include "src/cpp/ripple/TransactionMeta.h"
|
||||
#include "src/cpp/ripple/Transaction.h"
|
||||
#include "src/cpp/ripple/AccountState.h"
|
||||
#include "src/cpp/ripple/ripple_AccountState.h"
|
||||
#include "src/cpp/ripple/NicknameState.h"
|
||||
#include "src/cpp/ripple/Ledger.h"
|
||||
#include "src/cpp/ripple/LedgerEntrySet.h"
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
// VFALCO NOTE Holy smokes...that's a lot of boost!!!
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/array.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <boost/asio/ssl.hpp>
|
||||
@@ -82,6 +83,7 @@
|
||||
#include <boost/test/unit_test.hpp>
|
||||
|
||||
#include <openssl/ec.h>
|
||||
#include <openssl/md5.h>
|
||||
#include <openssl/ripemd.h>
|
||||
#include <openssl/sha.h>
|
||||
|
||||
@@ -124,7 +126,7 @@
|
||||
#include "src/cpp/ripple/ripple_SerializedLedger.h"
|
||||
#include "src/cpp/ripple/TransactionMeta.h"
|
||||
#include "src/cpp/ripple/Transaction.h"
|
||||
#include "src/cpp/ripple/AccountState.h"
|
||||
#include "src/cpp/ripple/ripple_AccountState.h"
|
||||
#include "src/cpp/ripple/NicknameState.h"
|
||||
#include "src/cpp/ripple/Ledger.h"
|
||||
|
||||
@@ -271,7 +273,7 @@ static const uint64 tenTo17m1 = tenTo17 - 1;
|
||||
#include "src/cpp/ripple/ripple_AccountItem.cpp"
|
||||
#include "src/cpp/ripple/ripple_AccountItems.cpp"
|
||||
#include "src/cpp/ripple/AccountSetTransactor.cpp"
|
||||
#include "src/cpp/ripple/AccountState.cpp" // no log
|
||||
#include "src/cpp/ripple/ripple_AccountState.cpp"
|
||||
#include "src/cpp/ripple/CallRPC.cpp"
|
||||
#include "src/cpp/ripple/ripple_CanonicalTXSet.cpp"
|
||||
#include "src/cpp/ripple/ChangeTransactor.cpp" // no log
|
||||
|
||||
@@ -743,7 +743,7 @@
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\cpp\ripple\AccountState.cpp">
|
||||
<ClCompile Include="src\cpp\ripple\ripple_AccountState.cpp">
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||
@@ -1735,7 +1735,7 @@
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\cpp\ripple\ripple_AcceptedLedger.h" />
|
||||
<ClInclude Include="src\cpp\ripple\AccountSetTransactor.h" />
|
||||
<ClInclude Include="src\cpp\ripple\AccountState.h" />
|
||||
<ClInclude Include="src\cpp\ripple\ripple_AccountState.h" />
|
||||
<ClInclude Include="src\cpp\ripple\ripple_AccountItem.h" />
|
||||
<ClInclude Include="src\cpp\ripple\ripple_AccountItems.h" />
|
||||
<ClInclude Include="src\cpp\ripple\ripple_IApplication.h" />
|
||||
@@ -1802,7 +1802,6 @@
|
||||
<ClInclude Include="src\cpp\ripple\ripple_SHAMapNode.h" />
|
||||
<ClInclude Include="src\cpp\ripple\ripple_SHAMapSyncFilter.h" />
|
||||
<ClInclude Include="src\cpp\ripple\ripple_SHAMapTreeNode.h" />
|
||||
<ClInclude Include="src\cpp\ripple\ripple_UptimeTimerAdapter.h" />
|
||||
<ClInclude Include="src\cpp\ripple\RPC.h" />
|
||||
<ClInclude Include="src\cpp\ripple\RPCDoor.h" />
|
||||
<ClInclude Include="src\cpp\ripple\RPCErr.h" />
|
||||
|
||||
@@ -79,9 +79,6 @@
|
||||
<Filter Include="1. Modules\ripple_data\crypto">
|
||||
<UniqueIdentifier>{095d33d8-dbf7-44d0-a675-6722b02bb3be}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="1. Modules\ripple_data\protobuf">
|
||||
<UniqueIdentifier>{9f8ed40a-9f16-42fe-82fd-caf72d3d6a2b}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="2. Empty">
|
||||
<UniqueIdentifier>{786657f9-b1b3-483c-a8e6-863cc2e02eb8}</UniqueIdentifier>
|
||||
</Filter>
|
||||
@@ -139,6 +136,9 @@
|
||||
<Filter Include="1. Modules\ripple_main\refactored\shamap">
|
||||
<UniqueIdentifier>{5b22fcf9-c9f0-4260-9a17-7b448e30bb57}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="1. Modules\ripple_data\utility">
|
||||
<UniqueIdentifier>{82b7f371-8bc6-474b-b10c-18c004467b46}</UniqueIdentifier>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\cpp\database\sqlite3.c">
|
||||
@@ -582,9 +582,6 @@
|
||||
<ClCompile Include="modules\ripple_basics\utility\ripple_InstanceCounter.cpp">
|
||||
<Filter>1. Modules\ripple_basics\utility</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="build\proto\ripple.pb.cc">
|
||||
<Filter>1. Modules\ripple_data\protobuf</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\cpp\ripple\LoadManager.cpp">
|
||||
<Filter>1. Modules\ripple_main\_unfactored\main</Filter>
|
||||
</ClCompile>
|
||||
@@ -636,9 +633,6 @@
|
||||
<ClCompile Include="src\cpp\ripple\ripple_UniqueNodeList.cpp">
|
||||
<Filter>1. Modules\ripple_main\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\cpp\ripple\AccountState.cpp">
|
||||
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\cpp\ripple\Ledger.cpp">
|
||||
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
|
||||
</ClCompile>
|
||||
@@ -870,6 +864,12 @@
|
||||
<ClCompile Include="src\cpp\ripple\WSHandler.cpp">
|
||||
<Filter>1. Modules\ripple_main\_unfactored\network</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\cpp\ripple\ripple_AccountState.cpp">
|
||||
<Filter>1. Modules\ripple_main\refactored</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="build\proto\ripple.pb.cc">
|
||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="database\sqlite3ext.h">
|
||||
@@ -1343,9 +1343,6 @@
|
||||
<ClInclude Include="modules\ripple_basics\utility\ripple_InstanceCounter.h">
|
||||
<Filter>1. Modules\ripple_basics\utility</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="build\proto\ripple.pb.h">
|
||||
<Filter>1. Modules\ripple_data\protobuf</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\cpp\ripple\LoadManager.h">
|
||||
<Filter>1. Modules\ripple_main\_unfactored\main</Filter>
|
||||
</ClInclude>
|
||||
@@ -1397,9 +1394,6 @@
|
||||
<ClInclude Include="src\cpp\ripple\ripple_IUniqueNodeList.h">
|
||||
<Filter>1. Modules\ripple_main\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\cpp\ripple\AccountState.h">
|
||||
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\cpp\ripple\Ledger.h">
|
||||
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
|
||||
</ClInclude>
|
||||
@@ -1532,9 +1526,6 @@
|
||||
<ClInclude Include="src\cpp\ripple\ripple_HashedObjectStore.h">
|
||||
<Filter>1. Modules\ripple_main\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\cpp\ripple\ripple_UptimeTimerAdapter.h">
|
||||
<Filter>1. Modules\ripple_main\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\cpp\ripple\ripple_HashedObject.h">
|
||||
<Filter>1. Modules\ripple_main\refactored</Filter>
|
||||
</ClInclude>
|
||||
@@ -1622,6 +1613,15 @@
|
||||
<ClInclude Include="src\cpp\ripple\ripple_SHAMap.h">
|
||||
<Filter>1. Modules\ripple_main\refactored\shamap</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\cpp\ripple\ripple_AccountState.h">
|
||||
<Filter>1. Modules\ripple_main\refactored</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="modules\ripple_data\utility\ripple_UptimeTimerAdapter.h">
|
||||
<Filter>1. Modules\ripple_data\utility</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="build\proto\ripple.pb.h">
|
||||
<Filter>1. Modules\ripple_data\protocol</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="SConstruct" />
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
#ifndef RIPPLE_ACCOUNTSTATE_H
|
||||
#define RIPPLE_ACCOUNTSTATE_H
|
||||
|
||||
//
|
||||
// Provide abstract access to an account's state, such that access to the serialized format is hidden.
|
||||
//
|
||||
|
||||
class AccountState
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<AccountState> pointer;
|
||||
|
||||
public:
|
||||
// For new accounts
|
||||
explicit AccountState (const RippleAddress& naAccountID);
|
||||
|
||||
// For accounts in a ledger
|
||||
AccountState (SLE::ref ledgerEntry, const RippleAddress& naAccountI);
|
||||
|
||||
bool haveAuthorizedKey ()
|
||||
{
|
||||
return mLedgerEntry->isFieldPresent(sfRegularKey);
|
||||
}
|
||||
|
||||
RippleAddress getAuthorizedKey()
|
||||
{
|
||||
return mLedgerEntry->getFieldAccount(sfRegularKey);
|
||||
}
|
||||
|
||||
STAmount getBalance() const { return mLedgerEntry->getFieldAmount(sfBalance); }
|
||||
uint32 getSeq() const { return mLedgerEntry->getFieldU32(sfSequence); }
|
||||
|
||||
SerializedLedgerEntry::pointer getSLE() { return mLedgerEntry; }
|
||||
const SerializedLedgerEntry& peekSLE() const { return *mLedgerEntry; }
|
||||
SerializedLedgerEntry& peekSLE() { return *mLedgerEntry; }
|
||||
|
||||
Blob getRaw() const;
|
||||
void addJson(Json::Value& value);
|
||||
void dump();
|
||||
|
||||
static std::string createGravatarUrl(uint128 uEmailHash);
|
||||
|
||||
private:
|
||||
RippleAddress mAccountID;
|
||||
RippleAddress mAuthorizedKey;
|
||||
SerializedLedgerEntry::pointer mLedgerEntry;
|
||||
|
||||
bool mValid;
|
||||
};
|
||||
|
||||
#endif
|
||||
// vim:ts=4
|
||||
@@ -2,19 +2,12 @@
|
||||
// Carries out the RPC.
|
||||
//
|
||||
|
||||
#include <openssl/md5.h>
|
||||
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/pointer_cast.hpp>
|
||||
|
||||
#include "Pathfinder.h"
|
||||
#include "RPCHandler.h"
|
||||
#include "RPCSub.h"
|
||||
#include "Wallet.h"
|
||||
#include "RippleCalc.h"
|
||||
#include "RPCErr.h"
|
||||
#include "AccountState.h"
|
||||
#include "NicknameState.h"
|
||||
#include "Offer.h"
|
||||
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
|
||||
AccountState::AccountState(const RippleAddress& naAccountID) : mAccountID(naAccountID), mValid(false)
|
||||
AccountState::AccountState (RippleAddress const& naAccountID)
|
||||
: mAccountID (naAccountID)
|
||||
, mValid (false)
|
||||
{
|
||||
if (!naAccountID.isValid()) return;
|
||||
|
||||
mLedgerEntry = boost::make_shared<SerializedLedgerEntry>(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(naAccountID));
|
||||
mLedgerEntry->setFieldAccount(sfAccount, naAccountID.getAccountID());
|
||||
|
||||
if (naAccountID.isValid ())
|
||||
{
|
||||
mValid = true;
|
||||
|
||||
mLedgerEntry = boost::make_shared <SerializedLedgerEntry> (
|
||||
ltACCOUNT_ROOT, Ledger::getAccountRootIndex (naAccountID));
|
||||
|
||||
mLedgerEntry->setFieldAccount (sfAccount, naAccountID.getAccountID());
|
||||
}
|
||||
}
|
||||
|
||||
AccountState::AccountState(SLE::ref ledgerEntry, const RippleAddress& naAccountID) :
|
||||
@@ -20,13 +25,17 @@ AccountState::AccountState(SLE::ref ledgerEntry, const RippleAddress& naAccountI
|
||||
mValid = true;
|
||||
}
|
||||
|
||||
// VFALCO TODO Make this a generic utility function of some container class
|
||||
//
|
||||
std::string AccountState::createGravatarUrl(uint128 uEmailHash)
|
||||
{
|
||||
Blob vucMD5(uEmailHash.begin(), uEmailHash.end());
|
||||
std::string strMD5Lower = strHex(vucMD5);
|
||||
boost::to_lower(strMD5Lower);
|
||||
|
||||
return str(boost::format("https://www.gravatar.com/avatar/%s") % strMD5Lower);
|
||||
// VFALCO TODO Give a name and move this constant to a more visible location.
|
||||
// Also shouldn't this be https?
|
||||
return str(boost::format("http://www.gravatar.com/avatar/%s") % strMD5Lower);
|
||||
}
|
||||
|
||||
void AccountState::addJson(Json::Value& val)
|
||||
71
src/cpp/ripple/ripple_AccountState.h
Normal file
71
src/cpp/ripple/ripple_AccountState.h
Normal file
@@ -0,0 +1,71 @@
|
||||
#ifndef RIPPLE_ACCOUNTSTATE_H
|
||||
#define RIPPLE_ACCOUNTSTATE_H
|
||||
|
||||
//
|
||||
// Provide abstract access to an account's state, such that access to the serialized format is hidden.
|
||||
//
|
||||
|
||||
class AccountState
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<AccountState> pointer;
|
||||
|
||||
public:
|
||||
// For new accounts
|
||||
explicit AccountState (RippleAddress const& naAccountID);
|
||||
|
||||
// For accounts in a ledger
|
||||
AccountState (SLE::ref ledgerEntry, RippleAddress const& naAccountI);
|
||||
|
||||
bool haveAuthorizedKey ()
|
||||
{
|
||||
return mLedgerEntry->isFieldPresent (sfRegularKey);
|
||||
}
|
||||
|
||||
RippleAddress getAuthorizedKey ()
|
||||
{
|
||||
return mLedgerEntry->getFieldAccount (sfRegularKey);
|
||||
}
|
||||
|
||||
STAmount getBalance () const
|
||||
{
|
||||
return mLedgerEntry->getFieldAmount (sfBalance);
|
||||
}
|
||||
|
||||
uint32 getSeq () const
|
||||
{
|
||||
return mLedgerEntry->getFieldU32 (sfSequence);
|
||||
}
|
||||
|
||||
SerializedLedgerEntry::pointer getSLE ()
|
||||
{
|
||||
return mLedgerEntry;
|
||||
}
|
||||
|
||||
SerializedLedgerEntry const& peekSLE () const
|
||||
{
|
||||
return *mLedgerEntry;
|
||||
}
|
||||
|
||||
SerializedLedgerEntry& peekSLE()
|
||||
{
|
||||
return *mLedgerEntry;
|
||||
}
|
||||
|
||||
Blob getRaw () const;
|
||||
|
||||
void addJson (Json::Value& value);
|
||||
|
||||
void dump ();
|
||||
|
||||
static std::string createGravatarUrl (uint128 uEmailHash);
|
||||
|
||||
private:
|
||||
RippleAddress const mAccountID;
|
||||
RippleAddress mAuthorizedKey;
|
||||
SerializedLedgerEntry::pointer mLedgerEntry;
|
||||
|
||||
bool mValid;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user