Cleanups and fixes.

This commit is contained in:
JoelKatz
2012-09-26 20:40:23 -07:00
parent 3f469c914d
commit c9b8408d08
3 changed files with 26 additions and 37 deletions

View File

@@ -56,11 +56,12 @@
FIELD(OfferSequence, UINT32, 25)
// 64-bit integers
FIELD(IndexNext, UINT64, 1)
FIELD(IndexPrevious, UINT64, 2)
FIELD(BookNode, UINT64, 3)
FIELD(OwnerNode, UINT64, 4)
FIELD(BaseFee, UINT64, 5)
FIELD(Fee, UINT64, 1)
FIELD(IndexNext, UINT64, 2)
FIELD(IndexPrevious, UINT64, 3)
FIELD(BookNode, UINT64, 4)
FIELD(OwnerNode, UINT64, 5)
FIELD(BaseFee, UINT64, 6)
// 128-bit
FIELD(EmailHash, HASH128, 2)

View File

@@ -14,7 +14,7 @@ SerializedLedgerEntry::SerializedLedgerEntry(SerializerIterator& sit, const uint
if (mFormat == NULL)
throw std::runtime_error("invalid ledger entry type");
mType = mFormat->t_type;
setType(mType);
setType(mFormat->elements);
}
SerializedLedgerEntry::SerializedLedgerEntry(const Serializer& s, const uint256& index)
@@ -28,15 +28,15 @@ SerializedLedgerEntry::SerializedLedgerEntry(const Serializer& s, const uint256&
if (mFormat == NULL)
throw std::runtime_error("invalid ledger entry type");
mType = mFormat->t_type;
setType(mTyhpe);
setType(mFormat->elements);
}
SerializedLedgerEntry::SerializedLedgerEntry(LedgerEntryType type) : SerializedType("LedgerEntry"), mType(type)
SerializedLedgerEntry::SerializedLedgerEntry(LedgerEntryType type) : STObject(sfLedgerEntry), mType(type)
{
mFormat = getLgrFormat(type);
if (mFormat == NULL) throw std::runtime_error("invalid ledger entry type");
mVersion.setValue(static_cast<uint16>(mFormat->t_type));
set(mFormat->elements);
setValueFieldU16(sfLedgerEntryType, static_cast<uint16>(mFormat->t_type));
}
std::string SerializedLedgerEntry::getFullText() const
@@ -60,7 +60,7 @@ std::string SerializedLedgerEntry::getText() const
Json::Value SerializedLedgerEntry::getJson(int options) const
{
Json::Value ret(SerializedObject::getJson(options));
Json::Value ret(STObject::getJson(options));
ret["index"] = mIndex.GetHex();
@@ -96,8 +96,8 @@ bool SerializedLedgerEntry::thread(const uint256& txID, uint32 ledgerSeq, uint25
prevTxID = oldPrevTxID;
prevLedgerID = getValueFieldU32(sfLastTxnSeq);
assert(prevTxID != txID);
setFieldH256(sfLastTxnID, txID);
setFieldU32(sfLastTxnSeq, ledgerSeq);
setValueFieldH256(sfLastTxnID, txID);
setValueFieldU32(sfLastTxnSeq, ledgerSeq);
return true;
}
@@ -133,20 +133,13 @@ std::vector<uint256> SerializedLedgerEntry::getOwners()
for (int i = 0, fields = getCount(); i < fields; ++i)
{
switch (getFieldSType(i))
int fc = getFieldSType(i).fieldCode;
if ((fc == sfAccount.fieldCode) || (fc == sfLowID.fieldCode) || (fc == sfHighID.fieldCode))
{
case sfAccount:
case sfLowID:
case sfHighID:
{
const STAccount* entry = dynamic_cast<const STAccount *>(mObject.peekAtPIndex(i));
const STAccount* entry = dynamic_cast<const STAccount *>(peekAtPIndex(i));
if ((entry != NULL) && entry->getValueH160(account))
owners.push_back(Ledger::getAccountRootIndex(account));
}
default:
nothing();
}
}
return owners;

View File

@@ -12,13 +12,13 @@ SerializedTransaction::SerializedTransaction(TransactionType type) : mType(type)
mFormat = getTxnFormat(type);
if (mFormat == NULL) throw std::runtime_error("invalid transaction type");
mMiddleTxn.giveObject(new STVariableLength(sfSigningPubKey));
mMiddleTxn.giveObject(new STAccount(sfSourceAccount));
mMiddleTxn.giveObject(new STVariableLength(sfSigningKey));
mMiddleTxn.giveObject(new STAccount(sfAccount));
mMiddleTxn.giveObject(new STUInt32(sfSequence));
mMiddleTxn.giveObject(new STUInt16(sfTransactionType, static_cast<uint16>(type)));
mMiddleTxn.giveObject(new STAmount(sfFee));
mInnerTxn = STObject(mFormat->elements, "InnerTransaction");
mInnerTxn = STObject(mFormat->elements, sfInnerTransaction);
}
SerializedTransaction::SerializedTransaction(SerializerIterator& sit)
@@ -53,11 +53,6 @@ SerializedTransaction::SerializedTransaction(SerializerIterator& sit)
mInnerTxn = STObject(mFormat->elements, sit, "InnerTransaction");
}
int SerializedTransaction::getLength() const
{
return mSignature.getLength() + mMiddleTxn.getLength() + mInnerTxn.getLength();
}
std::string SerializedTransaction::getFullText() const
{
std::string ret = "\"";
@@ -241,7 +236,7 @@ const NewcoinAddress& SerializedTransaction::setSourceAccount(const NewcoinAddre
return mSourceAccount;
}
uint160 SerializedTransaction::getITFieldAccount(SOE_Field field) const
uint160 SerializedTransaction::getITFieldAccount(SField::ref field) const
{
uint160 r;
const SerializedType* st = mInnerTxn.peekAtPField(field);
@@ -253,7 +248,7 @@ uint160 SerializedTransaction::getITFieldAccount(SOE_Field field) const
return r;
}
int SerializedTransaction::getITFieldIndex(SOE_Field field) const
int SerializedTransaction::getITFieldIndex(SField::ref field) const
{
return mInnerTxn.getFieldIndex(field);
}
@@ -263,27 +258,27 @@ int SerializedTransaction::getITFieldCount() const
return mInnerTxn.getCount();
}
bool SerializedTransaction::getITFieldPresent(SOE_Field field) const
bool SerializedTransaction::getITFieldPresent(SField::ref field) const
{
return mInnerTxn.isFieldPresent(field);
}
const SerializedType& SerializedTransaction::peekITField(SOE_Field field) const
const SerializedType& SerializedTransaction::peekITField(SField::ref field) const
{
return mInnerTxn.peekAtField(field);
}
SerializedType& SerializedTransaction::getITField(SOE_Field field)
SerializedType& SerializedTransaction::getITField(SField::ref field)
{
return mInnerTxn.getField(field);
}
void SerializedTransaction::makeITFieldPresent(SOE_Field field)
void SerializedTransaction::makeITFieldPresent(SField::ref field)
{
mInnerTxn.makeFieldPresent(field);
}
void SerializedTransaction::makeITFieldAbsent(SOE_Field field)
void SerializedTransaction::makeITFieldAbsent(SField::ref field)
{
return mInnerTxn.makeFieldAbsent(field);
}