This commit is contained in:
Vinnie Falco
2013-06-12 15:29:34 -07:00
parent 0787a74c87
commit b664f906c0
7 changed files with 72 additions and 26 deletions

View File

@@ -1103,6 +1103,49 @@ void Ledger::visitAccountItems(const uint160& accountID, FUNCTION_TYPE<void(SLE:
}
/*
// VFALCO: A proof of concept for making an iterator instead of a visitor
class AccountItemIterator
{
public:
explicit AccountItemIterator (uint160 const& accountID)
{
// Convert the account ID to the root hash
//
m_rootKey = Ledger::getOwnerDirIndex (accountID);
// Start iterating from the root
//
m_currentKey = rootKey;
}
SerializedLedgerEntry::ref operator* () const
{
return m_currentEntry;
}
SerializedLedgerEntry::ref end () const
{
return s_end;
}
AccountItemIterator& operator++ (int)
{
}
private:
static SerializedLedgerEntry s_end;
uint256 m_rootKey;
uint256 m_currentKey;
SerializedLedgerEntry::pointer m_currentEntry;
}
// typedef const boost::shared_ptr<SerializedLedgerEntry>& ref;
*/
uint256 Ledger::getFirstLedgerIndex()
{
SHAMapItem::pointer node = mAccountStateMap->peekFirstItem();

View File

@@ -241,6 +241,9 @@ public:
// Owner functions
//
// VFALCO NOTE This is a simple math operation that converts the account ID
// into a 256 bit object (I think....need to research this)
//
// All items controlled by an account are here: offers
static uint256 getOwnerDirIndex(const uint160& uAccountID);

View File

@@ -9,10 +9,10 @@
class NicknameState
{
public:
typedef boost::shared_ptr<NicknameState> pointer;
typedef boost::shared_ptr <NicknameState> pointer;
public:
NicknameState(SerializedLedgerEntry::pointer ledgerEntry); // For accounts in a ledger
explicit NicknameState (SerializedLedgerEntry::pointer ledgerEntry); // For accounts in a ledger
bool haveMinimumOffer() const;
STAmount getMinimumOffer() const;

View File

@@ -3,18 +3,14 @@
class Offer : public AccountItem
{
RippleAddress mAccount;
STAmount mTakerGets;
STAmount mTakerPays;
int mSeq;
Offer(SerializedLedgerEntry::pointer ledgerEntry); // For accounts in a ledger
public:
Offer(){}
virtual ~Offer(){}
AccountItem::pointer makeItem(const uint160&, SerializedLedgerEntry::ref ledgerEntry);
LedgerEntryType getType(){ return(ltOFFER); }
Offer () {}
virtual ~Offer(){}
AccountItem::pointer makeItem (const uint160&, SerializedLedgerEntry::ref ledgerEntry);
LedgerEntryType getType(){ return(ltOFFER); }
const STAmount& getTakerPays(){ return(mTakerPays); }
const STAmount& getTakerGets(){ return(mTakerGets); }
@@ -22,6 +18,15 @@ public:
int getSeq(){ return(mSeq); }
Json::Value getJson(int);
private:
// For accounts in a ledger
explicit Offer (SerializedLedgerEntry::pointer ledgerEntry);
private:
RippleAddress mAccount;
STAmount mTakerGets;
STAmount mTakerPays;
int mSeq;
};
#endif

View File

@@ -5,6 +5,14 @@
// Fetch ledger entries from an account's owner dir.
//
/** Base class representing account items.
Account items include:
- Offers
- Trust Lines
NOTE these are deprecated and will go away, to be replaced with
simple visitor patterns.
*/
class AccountItem
{