Rename SerializedLedger to SerializedLedgerEntry. It's not a whole ledger.

This commit is contained in:
JoelKatz
2012-04-13 20:07:57 -07:00
parent a4ae83c6fe
commit f05d6e0642
3 changed files with 19 additions and 18 deletions

View File

@@ -1,7 +1,7 @@
#include "SerializedLedger.h" #include "SerializedLedger.h"
SerializedLedger::SerializedLedger(SerializerIterator& sit, const uint256& index) SerializedLedgerEntry::SerializedLedgerEntry(SerializerIterator& sit, const uint256& index)
: STObject("LedgerEntry"), mIndex(index) : STObject("LedgerEntry"), mIndex(index)
{ {
uint16 type=sit.get16(); uint16 type=sit.get16();
@@ -12,7 +12,7 @@ SerializedLedger::SerializedLedger(SerializerIterator& sit, const uint256& index
mObject=STObject(mFormat->elements, sit, "Entry"); mObject=STObject(mFormat->elements, sit, "Entry");
} }
SerializedLedger::SerializedLedger(LedgerEntryType type) : STObject("LedgerEntry"), mType(type) SerializedLedgerEntry::SerializedLedgerEntry(LedgerEntryType type) : STObject("LedgerEntry"), mType(type)
{ {
mFormat=getLgrFormat(type); mFormat=getLgrFormat(type);
if(mFormat==NULL) throw std::runtime_error("invalid ledger entry type"); if(mFormat==NULL) throw std::runtime_error("invalid ledger entry type");
@@ -20,7 +20,7 @@ SerializedLedger::SerializedLedger(LedgerEntryType type) : STObject("LedgerEntry
mObject=STObject(mFormat->elements, "Entry"); mObject=STObject(mFormat->elements, "Entry");
} }
std::string SerializedLedger::getFullText() const std::string SerializedLedgerEntry::getFullText() const
{ {
std::string ret="\""; std::string ret="\"";
ret+=mIndex.GetHex(); ret+=mIndex.GetHex();
@@ -32,7 +32,7 @@ std::string SerializedLedger::getFullText() const
return ret; return ret;
} }
std::string SerializedLedger::getText() const std::string SerializedLedgerEntry::getText() const
{ {
std::string ret="{"; std::string ret="{";
ret+=mIndex.GetHex(); ret+=mIndex.GetHex();
@@ -42,9 +42,9 @@ std::string SerializedLedger::getText() const
return ret; return ret;
} }
bool SerializedLedger::isEquivalent(const SerializedType& t) const bool SerializedLedgerEntry::isEquivalent(const SerializedType& t) const
{ // locators are not compared { // locators are not compared
const SerializedLedger* v=dynamic_cast<const SerializedLedger*>(&t); const SerializedLedgerEntry* v=dynamic_cast<const SerializedLedgerEntry*>(&t);
if(!v) return false; if(!v) return false;
if(mType != v->mType) return false; if(mType != v->mType) return false;
if(mObject != v->mObject) return false; if(mObject != v->mObject) return false;

View File

@@ -4,10 +4,10 @@
#include "SerializedObject.h" #include "SerializedObject.h"
#include "LedgerFormats.h" #include "LedgerFormats.h"
class SerializedLedger : public STObject class SerializedLedgerEntry : public STObject
{ {
public: public:
typedef boost::shared_ptr<SerializedLedger> pointer; typedef boost::shared_ptr<SerializedLedgerEntry> pointer;
protected: protected:
uint256 mIndex; uint256 mIndex;
@@ -17,12 +17,12 @@ protected:
LedgerEntryFormat* mFormat; LedgerEntryFormat* mFormat;
public: public:
SerializedLedger(SerializerIterator& sit, const uint256& index); SerializedLedgerEntry(SerializerIterator& sit, const uint256& index);
SerializedLedger(LedgerEntryType type); SerializedLedgerEntry(LedgerEntryType type);
int getLength() const { return mVersion.getLength() + mObject.getLength(); } int getLength() const { return mVersion.getLength() + mObject.getLength(); }
SerializedTypeID getSType() const { return STI_LEDGERENTRY; } SerializedTypeID getSType() const { return STI_LEDGERENTRY; }
SerializedLedger* duplicate() const { return new SerializedLedger(*this); } SerializedLedgerEntry* duplicate() const { return new SerializedLedgerEntry(*this); }
std::string getFullText() const; std::string getFullText() const;
std::string getText() const; std::string getText() const;
void add(Serializer& s) const { mVersion.add(s); mObject.add(s); } void add(Serializer& s) const { mVersion.add(s); mObject.add(s); }

View File

@@ -3,6 +3,7 @@
#include "Ledger.h" #include "Ledger.h"
#include "SerializedTransaction.h" #include "SerializedTransaction.h"
#include "SerializedLedger.h"
// A TransactionEngine applies serialized transactions to a ledger // A TransactionEngine applies serialized transactions to a ledger
// It can also, verify signatures, verify fees, and give rejection reasons // It can also, verify signatures, verify fees, and give rejection reasons
@@ -33,13 +34,13 @@ class TransactionEngine
protected: protected:
Ledger::pointer mTargetLedger; Ledger::pointer mTargetLedger;
TransactionEngineResult doPayment(const SerializedTransaction&); TransactionEngineResult doPayment(const SerializedTransaction&, SerializedLedgerEntry& source);
TransactionEngineResult doInvoice(const SerializedTransaction&); TransactionEngineResult doInvoice(const SerializedTransaction&, SerializedLedgerEntry& source);
TransactionEngineResult doOffer(const SerializedTransaction&); TransactionEngineResult doOffer(const SerializedTransaction&, SerializedLedgerEntry& source);
TransactionEngineResult doTake(const SerializedTransaction&); TransactionEngineResult doTake(const SerializedTransaction&, SerializedLedgerEntry& source);
TransactionEngineResult doCancel(const SerializedTransaction&); TransactionEngineResult doCancel(const SerializedTransaction&, SerializedLedgerEntry& source);
TransactionEngineResult doStore(const SerializedTransaction&); TransactionEngineResult doStore(const SerializedTransaction&, SerializedLedgerEntry& source);
TransactionEngineResult doDelete(const SerializedTransaction&); TransactionEngineResult doDelete(const SerializedTransaction&, SerializedLedgerEntry& source);
public: public:
TransactionEngine(Ledger::pointer targetLedger) : mTargetLedger(targetLedger) { ; } TransactionEngine(Ledger::pointer targetLedger) : mTargetLedger(targetLedger) { ; }