mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Parts of the new serialization code. Does not compile yet.
This commit is contained in:
@@ -298,7 +298,7 @@ void STAmount::add(Serializer& s) const
|
||||
}
|
||||
}
|
||||
|
||||
STAmount::STAmount(const char* name, int64 value) : SerializedType(name), mOffset(0), mIsNative(true)
|
||||
STAmount::STAmount(FieldName* name, int64 value) : SerializedType(name), mOffset(0), mIsNative(true)
|
||||
{
|
||||
if (value >= 0)
|
||||
{
|
||||
@@ -330,7 +330,7 @@ uint64 STAmount::toUInt64() const
|
||||
return mValue | (static_cast<uint64>(mOffset + 256 + 97) << (64 - 10));
|
||||
}
|
||||
|
||||
STAmount* STAmount::construct(SerializerIterator& sit, const char *name)
|
||||
STAmount* STAmount::construct(SerializerIterator& sit, FieldName* name)
|
||||
{
|
||||
uint64 value = sit.get64();
|
||||
|
||||
@@ -883,7 +883,7 @@ uint64 STAmount::convertToDisplayAmount(const STAmount& internalAmount, uint64 t
|
||||
}
|
||||
|
||||
STAmount STAmount::convertToInternalAmount(uint64 displayAmount, uint64 totalNow, uint64 totalInit,
|
||||
const char *name)
|
||||
FieldName* name)
|
||||
{ // Convert a display/request currency amount to an internal amount
|
||||
return STAmount(name, muldiv(displayAmount, totalNow, totalInit));
|
||||
}
|
||||
|
||||
@@ -1,13 +1,53 @@
|
||||
|
||||
#include "FieldNames.h"
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
#define FIELD(name, type, index) { sf##name, #name, STI_##type, index },
|
||||
#define TYPE(name, type, index)
|
||||
|
||||
FieldName FieldNames[]=
|
||||
{
|
||||
#include "SerializeProto.h"
|
||||
|
||||
{ sfInvalid, 0, STI_DONE, 0 }
|
||||
};
|
||||
|
||||
#undef FIELD
|
||||
#undef TYPE
|
||||
|
||||
static std::map<int, FieldName*> unknownFieldMap;
|
||||
static boost::mutex unknownFieldMutex;
|
||||
|
||||
FieldName* getFieldName(SOE_Field f)
|
||||
{ // OPTIMIZEME
|
||||
for (FieldName* n = FieldNames; n->fieldName != 0; ++n)
|
||||
if (n->field == f)
|
||||
return n;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
FieldName* getFieldName(int type, int field)
|
||||
{ // OPTIMIZEME
|
||||
int f = (type << 16) | field;
|
||||
for (FieldName* n = FieldNames; n->fieldName != 0; ++n)
|
||||
if (n->field == f)
|
||||
return n;
|
||||
if ((type <= 0) || (type >= 256) || (field <= 0) || (field >= 256
|
||||
return NULL;
|
||||
|
||||
boost::mutex::scoped_lock sl(unknownFieldMutex);
|
||||
std::map<int, FieldName*> it = unknownFieldMap.Find(f);
|
||||
if (it != unknownFieldMap.end())
|
||||
return it->second;
|
||||
|
||||
FieldName* n = new FieldName();
|
||||
n->field = f;
|
||||
n->fieldName = "unknown";
|
||||
n->fieldType = static_cast<SerializedTypeID>(type);
|
||||
n->fieldNum = field;
|
||||
unknownFieldMap[f] = n;
|
||||
return n;
|
||||
}
|
||||
|
||||
@@ -1,16 +1,56 @@
|
||||
#ifndef __FIELDNAMES__
|
||||
#define __FIELDNAMES__
|
||||
|
||||
#include "SerializedTypes.h"
|
||||
#include "SerializedObject.h"
|
||||
enum SerializedTypeID
|
||||
{
|
||||
// special types
|
||||
STI_DONE = -1,
|
||||
STI_NOTPRESENT = 0,
|
||||
|
||||
#define TYPE(name, field, value) STI_##field = value,
|
||||
#define FIELD(name, field, value)
|
||||
#include "SerializeProto.h"
|
||||
#undef TYPE
|
||||
#undef FIELD
|
||||
|
||||
// high level types
|
||||
STI_TRANSACTION = 100001,
|
||||
STI_LEDGERENTRY = 100002,
|
||||
STI_VALIDATION = 100003,
|
||||
};
|
||||
|
||||
enum SOE_Flags
|
||||
{
|
||||
SOE_END = -1, // marks end of object
|
||||
SOE_REQUIRED = 0, // required
|
||||
SOE_OPTIONAL = 1, // optional
|
||||
};
|
||||
|
||||
enum SOE_Field
|
||||
{
|
||||
sfInvalid = -1,
|
||||
sfGeneric = 0,
|
||||
|
||||
#define FIELD(name, type, index) sf##name = (STI_##type << 16) | index,
|
||||
#define TYPE(name, type, index)
|
||||
#include "SerializeProto.h"
|
||||
#undef FIELD
|
||||
#undef TYPE
|
||||
|
||||
// test fields
|
||||
sfTest1=100000, sfTest2, sfTest3, sfTest4
|
||||
};
|
||||
|
||||
struct FieldName
|
||||
{
|
||||
SOE_Field field;
|
||||
const char *fieldName;
|
||||
SerializedTypeID fieldType;
|
||||
int fieldValue;
|
||||
int fieldID;
|
||||
int fieldNum;
|
||||
};
|
||||
|
||||
extern FieldName FieldNames[];
|
||||
extern FieldName* getFieldName(SOE_Field);
|
||||
extern FieldName* getFieldName(int type, int field);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,89 +1,87 @@
|
||||
|
||||
#include "LedgerFormats.h"
|
||||
|
||||
#define S_FIELD(x) sf##x, #x
|
||||
|
||||
LedgerEntryFormat LedgerFormats[]=
|
||||
{
|
||||
{ "AccountRoot", ltACCOUNT_ROOT, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Account), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Sequence), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Balance), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnID), STI_HASH256, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnSeq), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(AuthorizedKey), STI_ACCOUNT, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(EmailHash), STI_HASH128, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(WalletLocator), STI_HASH256, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(MessageKey), STI_VL, SOE_IFFLAG, 8 },
|
||||
{ S_FIELD(TransferRate), STI_UINT32, SOE_IFFLAG, 16 },
|
||||
{ S_FIELD(Domain), STI_VL, SOE_IFFLAG, 32 },
|
||||
{ S_FIELD(PublishHash), STI_HASH256, SOE_IFFLAG, 64 },
|
||||
{ S_FIELD(PublishSize), STI_UINT32, SOE_IFFLAG, 128 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfAccount, SOE_REQUIRED },
|
||||
{ sfSequence, SOE_REQUIRED },
|
||||
{ sfBalance, SOE_REQUIRED },
|
||||
{ sfLastTxnID, SOE_REQUIRED },
|
||||
{ sfLastTxnSeq, SOE_REQUIRED },
|
||||
{ sfAuthorizedKey, SOE_OPTIONAL },
|
||||
{ sfEmailHash, SOE_OPTIONAL },
|
||||
{ sfWalletLocator, SOE_OPTIONAL },
|
||||
{ sfMessageKey, SOE_OPTIONAL },
|
||||
{ sfTransferRate, SOE_OPTIONAL },
|
||||
{ sfDomain, SOE_OPTIONAL },
|
||||
{ sfPublishHash, SOE_OPTIONAL },
|
||||
{ sfPublishSize, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "Contract", ltCONTRACT, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Account), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Balance), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnID), STI_HASH256, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnSeq), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Issuer), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Owner), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Expiration), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(BondAmount), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(CreateCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(FundCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(RemoveCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(ExpireCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfAccount, SOE_REQUIRED },
|
||||
{ sfBalance, SOE_REQUIRED },
|
||||
{ sfLastTxnID, SOE_REQUIRED },
|
||||
{ sfLastTxnSeq, SOE_REQUIRED },
|
||||
{ sfIssuer, SOE_REQUIRED },
|
||||
{ sfOwner, SOE_REQUIRED },
|
||||
{ sfExpiration, SOE_REQUIRED },
|
||||
{ sfBondAmount, SOE_REQUIRED },
|
||||
{ sfCreateCode, SOE_REQUIRED },
|
||||
{ sfFundCode, SOE_REQUIRED },
|
||||
{ sfRemoveCode, SOE_REQUIRED },
|
||||
{ sfExpireCode, SOE_REQUIRED },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "DirectoryNode", ltDIR_NODE, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Indexes), STI_VECTOR256, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(IndexNext), STI_UINT64, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(IndexPrevious), STI_UINT64, SOE_IFFLAG, 2 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfIndexes, SOE_REQUIRED },
|
||||
{ sfIndexNext, SOE_OPTIONAL },
|
||||
{ sfIndexPrevious, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "GeneratorMap", ltGENERATOR_MAP, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Generator), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfGenerator, SOE_REQUIRED },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "Nickname", ltNICKNAME, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Account), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(MinimumOffer), STI_AMOUNT, SOE_IFFLAG, 1 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfAccount, SOE_REQUIRED },
|
||||
{ sfMinimumOffer, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "Offer", ltOFFER, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Account), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Sequence), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(TakerPays), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(TakerGets), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(BookDirectory), STI_HASH256, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(BookNode), STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(OwnerNode), STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnID), STI_HASH256, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnSeq), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Expiration), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfAccount, SOE_REQUIRED },
|
||||
{ sfSequence, SOE_REQUIRED },
|
||||
{ sfTakerPays, SOE_REQUIRED },
|
||||
{ sfTakerGets, SOE_REQUIRED },
|
||||
{ sfBookDirectory, SOE_REQUIRED },
|
||||
{ sfBookNode, SOE_REQUIRED },
|
||||
{ sfOwnerNode, SOE_REQUIRED },
|
||||
{ sfLastTxnID, SOE_REQUIRED },
|
||||
{ sfLastTxnSeq, SOE_REQUIRED },
|
||||
{ sfExpiration, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "RippleState", ltRIPPLE_STATE, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Balance), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LowID), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LowLimit), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(HighID), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(HighLimit), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnID), STI_HASH256, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LastTxnSeq), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(LowQualityIn), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(LowQualityOut), STI_UINT32, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(HighQualityIn), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(HighQualityOut), STI_UINT32, SOE_IFFLAG, 8 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfBalance, SOE_REQUIRED },
|
||||
{ sfLowID, SOE_REQUIRED },
|
||||
{ sfLowLimit, SOE_REQUIRED },
|
||||
{ sfHighID, SOE_REQUIRED },
|
||||
{ sfHighLimit, SOE_REQUIRED },
|
||||
{ sfLastTxnID, SOE_REQUIRED },
|
||||
{ sfLastTxnSeq, SOE_REQUIRED },
|
||||
{ sfLowQualityIn, SOE_OPTIONAL },
|
||||
{ sfLowQualityOut, SOE_OPTIONAL },
|
||||
{ sfHighQualityIn, SOE_OPTIONAL },
|
||||
{ sfHighQualityOut, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ NULL, ltINVALID }
|
||||
};
|
||||
|
||||
@@ -41,9 +41,9 @@ enum LedgerSpecificFlags
|
||||
|
||||
struct LedgerEntryFormat
|
||||
{
|
||||
const char *t_name;
|
||||
const char * t_name;
|
||||
LedgerEntryType t_type;
|
||||
SOElement elements[20];
|
||||
SOElement elements[24];
|
||||
};
|
||||
|
||||
extern LedgerEntryFormat LedgerFormats[];
|
||||
|
||||
@@ -27,17 +27,18 @@
|
||||
FIELD(CloseResolution, UINT8, 1)
|
||||
|
||||
// 32-bit integers (common)
|
||||
FIELD(Flags, UINT32, 1)
|
||||
FIELD(SourceTag, UINT32, 2)
|
||||
FIELD(Sequence, UINT32, 3)
|
||||
FIELD(LastTxnSeq, UINT32, 4)
|
||||
FIELD(LedgerSequence, UINT32, 5)
|
||||
FIELD(CloseTime, UINT32, 6)
|
||||
FIELD(ParentCloseTime, UINT32, 7)
|
||||
FIELD(SigningTime, UINT32, 8)
|
||||
FIELD(Expiration, UINT32, 9)
|
||||
FIELD(TransferRate, UINT32, 10)
|
||||
FIELD(PublishSize, UINT32, 11)
|
||||
FIELD(ObjectType, UINT32, 1)
|
||||
FIELD(Flags, UINT32, 2)
|
||||
FIELD(SourceTag, UINT32, 3)
|
||||
FIELD(Sequence, UINT32, 4)
|
||||
FIELD(LastTxnSeq, UINT32, 5)
|
||||
FIELD(LedgerSequence, UINT32, 6)
|
||||
FIELD(CloseTime, UINT32, 7)
|
||||
FIELD(ParentCloseTime, UINT32, 8)
|
||||
FIELD(SigningTime, UINT32, 9)
|
||||
FIELD(Expiration, UINT32, 10)
|
||||
FIELD(TransferRate, UINT32, 11)
|
||||
FIELD(PublishSize, UINT32, 12)
|
||||
|
||||
// 32-bit integers (uncommon)
|
||||
FIELD(HighQualityIn, UINT32, 16)
|
||||
|
||||
@@ -25,7 +25,6 @@ public:
|
||||
SerializedLedgerEntry(SerializerIterator& sit, const uint256& index);
|
||||
SerializedLedgerEntry(LedgerEntryType type);
|
||||
|
||||
int getLength() const { return mVersion.getLength() + mObject.getLength(); }
|
||||
SerializedTypeID getSType() const { return STI_LEDGERENTRY; }
|
||||
std::string getFullText() const;
|
||||
std::string getText() const;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
|
||||
#include "Log.h"
|
||||
|
||||
std::auto_ptr<SerializedType> STObject::makeDefaultObject(SerializedTypeID id, const char *name)
|
||||
std::auto_ptr<SerializedType> STObject::makeDefaultObject(SerializedTypeID id, FieldName* name)
|
||||
{
|
||||
switch(id)
|
||||
{
|
||||
@@ -53,8 +53,8 @@ std::auto_ptr<SerializedType> STObject::makeDefaultObject(SerializedTypeID id, c
|
||||
}
|
||||
}
|
||||
|
||||
std::auto_ptr<SerializedType> STObject::makeDeserializedObject(SerializedTypeID id, const char *name,
|
||||
SerializerIterator& sit)
|
||||
std::auto_ptr<SerializedType> STObject::makeDeserializedObject(SerializedTypeID id, FieldName* name,
|
||||
SerializerIterator& sit, int depth)
|
||||
{
|
||||
switch(id)
|
||||
{
|
||||
@@ -94,6 +94,12 @@ std::auto_ptr<SerializedType> STObject::makeDeserializedObject(SerializedTypeID
|
||||
case STI_PATHSET:
|
||||
return STPathSet::deserialize(sit, name);
|
||||
|
||||
case STI_ARRAY:
|
||||
return STArray::deserialize(sit, name);
|
||||
|
||||
case STI_OBJECT:
|
||||
return STObject::deserialize(sit, name);
|
||||
|
||||
default:
|
||||
throw std::runtime_error("Unknown object type");
|
||||
}
|
||||
@@ -103,13 +109,11 @@ void STObject::set(const SOElement* elem)
|
||||
{
|
||||
mData.empty();
|
||||
mType.empty();
|
||||
mFlagIdx = -1;
|
||||
|
||||
while (elem->e_id != STI_DONE)
|
||||
while (elem->flags != SOE_END)
|
||||
{
|
||||
if (elem->e_type == SOE_FLAGS) mFlagIdx = mType.size();
|
||||
mType.push_back(elem);
|
||||
if (elem->e_type == SOE_IFFLAG)
|
||||
if (elem->flags == SOE_OPTIONAL)
|
||||
giveObject(makeDefaultObject(STI_NOTPRESENT, elem->e_name));
|
||||
else
|
||||
giveObject(makeDefaultObject(elem->e_id, elem->e_name));
|
||||
@@ -117,55 +121,30 @@ void STObject::set(const SOElement* elem)
|
||||
}
|
||||
}
|
||||
|
||||
STObject::STObject(const SOElement* elem, const char *name) : SerializedType(name)
|
||||
STObject::STObject(const SOElement* elem, FieldName* name) : SerializedType(name)
|
||||
{
|
||||
set(elem);
|
||||
}
|
||||
|
||||
void STObject::set(const SOElement* elem, SerializerIterator& sit)
|
||||
void STObject::set(FieldName* name, SerializerIterator& sit, int depth = 0)
|
||||
{
|
||||
mData.empty();
|
||||
mType.empty();
|
||||
mFlagIdx = -1;
|
||||
|
||||
int flags = -1;
|
||||
while (elem->e_id != STI_DONE)
|
||||
fName = name;
|
||||
|
||||
while(1)
|
||||
{
|
||||
mType.push_back(elem);
|
||||
bool done = false;
|
||||
if (elem->e_type == SOE_IFFLAG)
|
||||
{
|
||||
assert(flags >= 0);
|
||||
if ((flags&elem->e_flags) == 0)
|
||||
{
|
||||
done = true;
|
||||
giveObject(makeDefaultObject(STI_NOTPRESENT, elem->e_name));
|
||||
}
|
||||
}
|
||||
else if (elem->e_type == SOE_IFNFLAG)
|
||||
{
|
||||
assert(flags >= 0);
|
||||
if ((flags&elem->e_flags) != 0)
|
||||
{
|
||||
done = true;
|
||||
giveObject(makeDefaultObject(elem->e_id, elem->e_name));
|
||||
}
|
||||
}
|
||||
else if (elem->e_type == SOE_FLAGS)
|
||||
{
|
||||
assert(elem->e_id == STI_UINT32);
|
||||
flags = sit.get32();
|
||||
mFlagIdx = giveObject(new STUInt32(elem->e_name, flags));
|
||||
done = true;
|
||||
}
|
||||
if (!done)
|
||||
giveObject(makeDeserializedObject(elem->e_id, elem->e_name, sit));
|
||||
elem++;
|
||||
int type, field.
|
||||
sit.getFieldID(type, field);
|
||||
if ((type == STI_ARRAY) && (field == 1))
|
||||
return;
|
||||
FieldName* fn = getFieldName(type, field);
|
||||
giveObject(makeDeserializedObject(static_cast<SerializedTypeID> type, fn, sit, depth + 1);
|
||||
}
|
||||
}
|
||||
|
||||
STObject::STObject(const SOElement* elem, SerializerIterator& sit, const char *name)
|
||||
: SerializedType(name), mFlagIdx(-1)
|
||||
STObject::STObject(const SOElement* elem, SerializerIterator& sit, FieldName*name) : SerializedType(name)
|
||||
{
|
||||
set(elem, sit);
|
||||
}
|
||||
@@ -193,14 +172,6 @@ std::string STObject::getFullText() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
int STObject::getLength() const
|
||||
{
|
||||
int ret = 0;
|
||||
BOOST_FOREACH(const SerializedType& it, mData)
|
||||
ret += it.getLength();
|
||||
return ret;
|
||||
}
|
||||
|
||||
void STObject::add(Serializer& s) const
|
||||
{
|
||||
BOOST_FOREACH(const SerializedType& it, mData)
|
||||
@@ -295,9 +266,9 @@ bool STObject::isFieldPresent(SOE_Field field) const
|
||||
|
||||
bool STObject::setFlag(uint32 f)
|
||||
{
|
||||
if (mFlagIdx < 0) return false;
|
||||
STUInt32* t = dynamic_cast<STUInt32*>(getPIndex(mFlagIdx));
|
||||
assert(t);
|
||||
STUInt32* t = dynamic_cast<STUInt32*>(getPField(sfFlags));
|
||||
if (!t)
|
||||
return false;
|
||||
t->setValue(t->getValue() | f);
|
||||
return true;
|
||||
}
|
||||
@@ -305,17 +276,18 @@ bool STObject::setFlag(uint32 f)
|
||||
bool STObject::clearFlag(uint32 f)
|
||||
{
|
||||
if (mFlagIdx < 0) return false;
|
||||
STUInt32* t = dynamic_cast<STUInt32*>(getPIndex(mFlagIdx));
|
||||
assert(t);
|
||||
STUInt32* t = dynamic_cast<STUInt32*>(getPField(sfFlags));
|
||||
if (!t)
|
||||
return false;
|
||||
t->setValue(t->getValue() & ~f);
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 STObject::getFlags(void) const
|
||||
{
|
||||
if (mFlagIdx < 0) return 0;
|
||||
const STUInt32* t = dynamic_cast<const STUInt32*>(peekAtPIndex(mFlagIdx));
|
||||
assert(t);
|
||||
const STUInt32* t = dynamic_cast<const STUInt32*>(peekAtPField(mFlagIdx));
|
||||
if (!t)
|
||||
return 0;
|
||||
return t->getValue();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,56 +9,30 @@
|
||||
|
||||
#include "SerializedTypes.h"
|
||||
|
||||
enum SOE_Type
|
||||
{
|
||||
SOE_NEVER = -1, // never occurs (marks end of object)
|
||||
SOE_REQUIRED = 0, // required
|
||||
SOE_FLAGS = 1, // flags field
|
||||
SOE_IFFLAG = 2, // present if flag set
|
||||
SOE_IFNFLAG = 3 // present if flag not set
|
||||
};
|
||||
|
||||
enum SOE_Field
|
||||
{
|
||||
sfInvalid = -1,
|
||||
sfGeneric = 0,
|
||||
|
||||
#define FIELD(name, type, index) sf##name,
|
||||
#define TYPE(name, type, index)
|
||||
#include "SerializeProto.h"
|
||||
#undef FIELD
|
||||
#undef TYPE
|
||||
|
||||
// test fields
|
||||
sfTest1, sfTest2, sfTest3, sfTest4
|
||||
};
|
||||
// Serializable object/array types
|
||||
|
||||
struct SOElement
|
||||
{ // An element in the description of a serialized object
|
||||
SOE_Field e_field;
|
||||
const char *e_name;
|
||||
SerializedTypeID e_id;
|
||||
SOE_Type e_type;
|
||||
int e_flags;
|
||||
SOE_Flags flags;
|
||||
};
|
||||
|
||||
class STObject : public SerializedType
|
||||
{
|
||||
protected:
|
||||
int mFlagIdx; // the offset to the flags object, -1 if none
|
||||
boost::ptr_vector<SerializedType> mData;
|
||||
std::vector<const SOElement*> mType;
|
||||
|
||||
STObject* duplicate() const { return new STObject(*this); }
|
||||
|
||||
public:
|
||||
STObject(const char *n = NULL) : SerializedType(n), mFlagIdx(-1) { ; }
|
||||
STObject(const SOElement *t, const char *n = NULL);
|
||||
STObject(const SOElement *t, SerializerIterator& u, const char *n = NULL);
|
||||
STObject(FieldName *n = NULL) : SerializedType(n) { ; }
|
||||
STObject(const SOElement *t, FieldName *n = NULL);
|
||||
STObject(const SOElement *t, SerializerIterator& u, FieldName *n = NULL);
|
||||
virtual ~STObject() { ; }
|
||||
|
||||
void set(const SOElement* t);
|
||||
void set(const SOElement* t, SerializerIterator& u);
|
||||
void set(const SOElement* t, SerializerIterator& u, int depth = 0);
|
||||
|
||||
int getLength() const;
|
||||
virtual SerializedTypeID getSType() const { return STI_OBJECT; }
|
||||
@@ -133,13 +107,71 @@ public:
|
||||
SerializedType* makeFieldPresent(SOE_Field field);
|
||||
void makeFieldAbsent(SOE_Field field);
|
||||
|
||||
static std::auto_ptr<SerializedType> makeDefaultObject(SerializedTypeID id, const char *name);
|
||||
static std::auto_ptr<SerializedType> makeDeserializedObject(SerializedTypeID id, const char *name,
|
||||
SerializerIterator&);
|
||||
static std::auto_ptr<SerializedType> makeDefaultObject(SerializedTypeID id, FieldName *name);
|
||||
static std::auto_ptr<SerializedType> makeDeserializedObject(SerializedTypeID id, FieldName *name,
|
||||
SerializerIterator&, int depth);
|
||||
|
||||
static void unitTest();
|
||||
};
|
||||
|
||||
class STArray : public SerializedType
|
||||
{
|
||||
public:
|
||||
typedef std::vector<STObject> vector;
|
||||
typedef std::vector<STObject>::iterator iterator;
|
||||
typedef std::vector<STObject>::const_iterator const_iterator;
|
||||
typedef std::vector<STObject>::reverse_iterator reverse_iterator;
|
||||
typedef std::vector<STObject>::const_reverse_iterator const_reverse_iterator;
|
||||
typedef std::vector<STObject>::size_type size_type;
|
||||
|
||||
protected:
|
||||
|
||||
vector value;
|
||||
|
||||
STArray* duplicate() const { return new STArray(fName, value); }
|
||||
static STArray* construct(SerializerIterator&, FieldName* name = NULL);
|
||||
|
||||
public:
|
||||
|
||||
STArray() { ; }
|
||||
STArray(FieldName* f, const vector& v) : SerializedType(f), value(v) { ; }
|
||||
STArray(vector& v) : value(v) { ; }
|
||||
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, FieldName* name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
const vector& getValue() const { return value; }
|
||||
vector& getValue() { return value; }
|
||||
|
||||
// vector-like functions
|
||||
void push_back(const STObject& object) { value.push_back(object); }
|
||||
STObject& operator[](int j) { return value[j]; }
|
||||
const STObject& operator[](int j) const { return value[j]; }
|
||||
iterator begin() { return value.begin(); }
|
||||
const_iterator begin() const { return value.begin(); }
|
||||
iterator end() { return value.end(); }
|
||||
const_iterator end() const { return value.end(); }
|
||||
size_type size() const { return value.size(); }
|
||||
reverse_iterator rbegin() { return value.rbegin(); }
|
||||
const_reverse_iterator rbegin() const { return value.rbegin(); }
|
||||
reverse_iterator rend() { return value.rend(); }
|
||||
const_reverse_iterator rend() const { return value.rend(); }
|
||||
iterator erase(iterator pos) { return value.erase(pos); }
|
||||
void pop_back() { value.pop_back(); }
|
||||
bool empty() const { return value.empty(); }
|
||||
void clear() { value.clear(); }
|
||||
|
||||
virtual std::string getFullText() const;
|
||||
virtual std::string getText() const;
|
||||
virtual Json::Value getJson(int) const;
|
||||
virtual void add(Serializer& s) const;
|
||||
|
||||
bool operator==(const STArray &s) { return value == s.value; }
|
||||
bool operator!=(const STArray &s) { return value != s.value; }
|
||||
|
||||
virtual SerializedTypeID getSType() const { return STI_ARRAY; }
|
||||
virtual bool isEquivalent(const SerializedType& t) const;
|
||||
};
|
||||
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
@@ -17,9 +17,9 @@ std::string SerializedType::getFullText() const
|
||||
std::string ret;
|
||||
if (getSType() != STI_NOTPRESENT)
|
||||
{
|
||||
if(name != NULL)
|
||||
if(fName != NULL)
|
||||
{
|
||||
ret = name;
|
||||
ret = fName->fieldName;
|
||||
ret += " = ";
|
||||
}
|
||||
ret += getText();
|
||||
@@ -27,7 +27,7 @@ std::string SerializedType::getFullText() const
|
||||
return ret;
|
||||
}
|
||||
|
||||
STUInt8* STUInt8::construct(SerializerIterator& u, const char *name)
|
||||
STUInt8* STUInt8::construct(SerializerIterator& u, FieldName* name)
|
||||
{
|
||||
return new STUInt8(name, u.get8());
|
||||
}
|
||||
@@ -43,7 +43,7 @@ bool STUInt8::isEquivalent(const SerializedType& t) const
|
||||
return v && (value == v->value);
|
||||
}
|
||||
|
||||
STUInt16* STUInt16::construct(SerializerIterator& u, const char *name)
|
||||
STUInt16* STUInt16::construct(SerializerIterator& u, FieldName* name)
|
||||
{
|
||||
return new STUInt16(name, u.get16());
|
||||
}
|
||||
@@ -59,7 +59,7 @@ bool STUInt16::isEquivalent(const SerializedType& t) const
|
||||
return v && (value == v->value);
|
||||
}
|
||||
|
||||
STUInt32* STUInt32::construct(SerializerIterator& u, const char *name)
|
||||
STUInt32* STUInt32::construct(SerializerIterator& u, FieldName* name)
|
||||
{
|
||||
return new STUInt32(name, u.get32());
|
||||
}
|
||||
@@ -75,7 +75,7 @@ bool STUInt32::isEquivalent(const SerializedType& t) const
|
||||
return v && (value == v->value);
|
||||
}
|
||||
|
||||
STUInt64* STUInt64::construct(SerializerIterator& u, const char *name)
|
||||
STUInt64* STUInt64::construct(SerializerIterator& u, FieldName* name)
|
||||
{
|
||||
return new STUInt64(name, u.get64());
|
||||
}
|
||||
@@ -91,7 +91,7 @@ bool STUInt64::isEquivalent(const SerializedType& t) const
|
||||
return v && (value == v->value);
|
||||
}
|
||||
|
||||
STHash128* STHash128::construct(SerializerIterator& u, const char *name)
|
||||
STHash128* STHash128::construct(SerializerIterator& u, FieldName* name)
|
||||
{
|
||||
return new STHash128(name, u.get128());
|
||||
}
|
||||
@@ -107,7 +107,7 @@ bool STHash128::isEquivalent(const SerializedType& t) const
|
||||
return v && (value == v->value);
|
||||
}
|
||||
|
||||
STHash160* STHash160::construct(SerializerIterator& u, const char *name)
|
||||
STHash160* STHash160::construct(SerializerIterator& u, FieldName* name)
|
||||
{
|
||||
return new STHash160(name, u.get160());
|
||||
}
|
||||
@@ -123,7 +123,7 @@ bool STHash160::isEquivalent(const SerializedType& t) const
|
||||
return v && (value == v->value);
|
||||
}
|
||||
|
||||
STHash256* STHash256::construct(SerializerIterator& u, const char *name)
|
||||
STHash256* STHash256::construct(SerializerIterator& u, FieldName* name)
|
||||
{
|
||||
return new STHash256(name, u.get256());
|
||||
}
|
||||
@@ -139,7 +139,7 @@ bool STHash256::isEquivalent(const SerializedType& t) const
|
||||
return v && (value == v->value);
|
||||
}
|
||||
|
||||
STVariableLength::STVariableLength(SerializerIterator& st, const char *name) : SerializedType(name)
|
||||
STVariableLength::STVariableLength(SerializerIterator& st, FieldName* name) : SerializedType(name)
|
||||
{
|
||||
value = st.getVL();
|
||||
}
|
||||
@@ -149,16 +149,11 @@ std::string STVariableLength::getText() const
|
||||
return strHex(value);
|
||||
}
|
||||
|
||||
STVariableLength* STVariableLength::construct(SerializerIterator& u, const char *name)
|
||||
STVariableLength* STVariableLength::construct(SerializerIterator& u, FieldName* name)
|
||||
{
|
||||
return new STVariableLength(name, u.getVL());
|
||||
}
|
||||
|
||||
int STVariableLength::getLength() const
|
||||
{
|
||||
return Serializer::encodeLengthLength(value.size()) + value.size();
|
||||
}
|
||||
|
||||
bool STVariableLength::isEquivalent(const SerializedType& t) const
|
||||
{
|
||||
const STVariableLength* v = dynamic_cast<const STVariableLength*>(&t);
|
||||
@@ -176,7 +171,7 @@ std::string STAccount::getText() const
|
||||
return a.humanAccountID();
|
||||
}
|
||||
|
||||
STAccount* STAccount::construct(SerializerIterator& u, const char *name)
|
||||
STAccount* STAccount::construct(SerializerIterator& u, FieldName* name)
|
||||
{
|
||||
return new STAccount(name, u.getVL());
|
||||
}
|
||||
@@ -186,7 +181,7 @@ STAccount* STAccount::construct(SerializerIterator& u, const char *name)
|
||||
//
|
||||
|
||||
// Return a new object from a SerializerIterator.
|
||||
STVector256* STVector256::construct(SerializerIterator& u, const char *name)
|
||||
STVector256* STVector256::construct(SerializerIterator& u, FieldName* name)
|
||||
{
|
||||
std::vector<unsigned char> data = u.getVL();
|
||||
std::vector<uint256> value;
|
||||
@@ -255,7 +250,7 @@ void STAccount::setValueNCA(const NewcoinAddress& nca)
|
||||
setValueH160(nca.getAccountID());
|
||||
}
|
||||
|
||||
STPathSet* STPathSet::construct(SerializerIterator& s, const char *name)
|
||||
STPathSet* STPathSet::construct(SerializerIterator& s, FieldName* name)
|
||||
{
|
||||
std::vector<STPath> paths;
|
||||
std::vector<STPathElement> path;
|
||||
@@ -342,18 +337,6 @@ int STPath::getSerializeSize() const
|
||||
return iBytes;
|
||||
}
|
||||
|
||||
int STPathSet::getLength() const
|
||||
{
|
||||
int iBytes = 0;
|
||||
|
||||
BOOST_FOREACH(const STPath& spPath, value)
|
||||
{
|
||||
iBytes += spPath.getSerializeSize();
|
||||
}
|
||||
|
||||
return iBytes ? iBytes : 1;
|
||||
}
|
||||
|
||||
Json::Value STPath::getJson(int) const
|
||||
{
|
||||
Json::Value ret(Json::arrayValue);
|
||||
|
||||
@@ -8,28 +8,13 @@
|
||||
|
||||
#include "uint256.h"
|
||||
#include "Serializer.h"
|
||||
#include "FieldNames.h"
|
||||
|
||||
enum SerializedTypeID
|
||||
{
|
||||
// special types
|
||||
STI_DONE = -1,
|
||||
STI_NOTPRESENT = 0,
|
||||
|
||||
#define TYPE(name, field, value) STI_##field = value,
|
||||
#define FIELD(name, field, value)
|
||||
#include "SerializeProto.h"
|
||||
#undef TYPE
|
||||
#undef FIELD
|
||||
|
||||
// high level types
|
||||
STI_TRANSACTION = 100001,
|
||||
STI_LEDGERENTRY = 100002
|
||||
};
|
||||
|
||||
enum PathFlags
|
||||
{
|
||||
PF_END = 0x00, // End of current path & path list.
|
||||
PF_BOUNDRY = 0xFF, // End of current path & new path follows.
|
||||
PF_BOUNDARY = 0xFF, // End of current path & new path follows.
|
||||
|
||||
PF_ACCOUNT = 0x01,
|
||||
PF_OFFER = 0x02,
|
||||
@@ -48,24 +33,24 @@ enum PathFlags
|
||||
class SerializedType
|
||||
{
|
||||
protected:
|
||||
const char* name;
|
||||
FieldName* fName;
|
||||
|
||||
virtual SerializedType* duplicate() const { return new SerializedType(name); }
|
||||
virtual SerializedType* duplicate() const { return new SerializedType(fName); }
|
||||
|
||||
public:
|
||||
|
||||
SerializedType() : name(NULL) { ; }
|
||||
SerializedType(const char* n) : name(n) { ; }
|
||||
SerializedType(const SerializedType& n) : name(n.name) { ; }
|
||||
SerializedType() : fName(NULL) { ; }
|
||||
SerializedType(FieldName* n) : fName(n) { ; }
|
||||
SerializedType(const SerializedType& n) : fName(n.fName) { ; }
|
||||
virtual ~SerializedType() { ; }
|
||||
|
||||
static std::auto_ptr<SerializedType> deserialize(const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(FieldName* name)
|
||||
{ return std::auto_ptr<SerializedType>(new SerializedType(name)); }
|
||||
|
||||
void setName(const char* n) { name=n; }
|
||||
const char *getName() const { return name; }
|
||||
void setFName(FieldName* n) { fName=n; }
|
||||
FieldName* getFName() { return fName; }
|
||||
const char *getName() const { return (fName != NULL) ? fName->fieldName : NULL; }
|
||||
|
||||
virtual int getLength() const { return 0; }
|
||||
virtual SerializedTypeID getSType() const { return STI_NOTPRESENT; }
|
||||
std::auto_ptr<SerializedType> clone() const { return std::auto_ptr<SerializedType>(duplicate()); }
|
||||
|
||||
@@ -81,7 +66,7 @@ public:
|
||||
{ assert(getSType() == STI_NOTPRESENT); return t.getSType() == STI_NOTPRESENT; }
|
||||
|
||||
SerializedType& operator=(const SerializedType& t)
|
||||
{ name = (name == NULL) ? t.name : name; return *this; }
|
||||
{ if (fName == NULL) fName = t.fName; return *this; }
|
||||
bool operator==(const SerializedType& t) const
|
||||
{ return (getSType() == t.getSType()) && isEquivalent(t); }
|
||||
bool operator!=(const SerializedType& t) const
|
||||
@@ -97,23 +82,22 @@ class STUInt8 : public SerializedType
|
||||
protected:
|
||||
unsigned char value;
|
||||
|
||||
STUInt8* duplicate() const { return new STUInt8(name, value); }
|
||||
static STUInt8* construct(SerializerIterator&, const char* name = NULL);
|
||||
STUInt8* duplicate() const { return new STUInt8(fName, value); }
|
||||
static STUInt8* construct(SerializerIterator&, FieldName* name = NULL);
|
||||
|
||||
public:
|
||||
|
||||
STUInt8(unsigned char v=0) : value(v) { ; }
|
||||
STUInt8(const char* n, unsigned char v=0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
STUInt8(FieldName* n, unsigned char v=0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, FieldName* name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const { return 1; }
|
||||
SerializedTypeID getSType() const { return STI_UINT8; }
|
||||
std::string getText() const;
|
||||
void add(Serializer& s) const { s.add8(value); }
|
||||
|
||||
unsigned char getValue() const { return value; }
|
||||
void setValue(unsigned char v) { value=v; }
|
||||
void setValue(unsigned char v) { value = v; }
|
||||
|
||||
operator unsigned char() const { return value; }
|
||||
virtual bool isEquivalent(const SerializedType& t) const;
|
||||
@@ -124,17 +108,16 @@ class STUInt16 : public SerializedType
|
||||
protected:
|
||||
uint16 value;
|
||||
|
||||
STUInt16* duplicate() const { return new STUInt16(name, value); }
|
||||
static STUInt16* construct(SerializerIterator&, const char* name = NULL);
|
||||
STUInt16* duplicate() const { return new STUInt16(fName, value); }
|
||||
static STUInt16* construct(SerializerIterator&, FieldName* name = NULL);
|
||||
|
||||
public:
|
||||
|
||||
STUInt16(uint16 v=0) : value(v) { ; }
|
||||
STUInt16(const char* n, uint16 v=0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
STUInt16(FieldName* n, uint16 v=0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, FieldName* name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const { return 2; }
|
||||
SerializedTypeID getSType() const { return STI_UINT16; }
|
||||
std::string getText() const;
|
||||
void add(Serializer& s) const { s.add16(value); }
|
||||
@@ -151,17 +134,16 @@ class STUInt32 : public SerializedType
|
||||
protected:
|
||||
uint32 value;
|
||||
|
||||
STUInt32* duplicate() const { return new STUInt32(name, value); }
|
||||
static STUInt32* construct(SerializerIterator&, const char* name = NULL);
|
||||
STUInt32* duplicate() const { return new STUInt32(fName, value); }
|
||||
static STUInt32* construct(SerializerIterator&, FieldName* name = NULL);
|
||||
|
||||
public:
|
||||
|
||||
STUInt32(uint32 v=0) : value(v) { ; }
|
||||
STUInt32(const char* n, uint32 v=0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
STUInt32(FieldName* n, uint32 v=0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, FieldName* name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const { return 4; }
|
||||
SerializedTypeID getSType() const { return STI_UINT32; }
|
||||
std::string getText() const;
|
||||
void add(Serializer& s) const { s.add32(value); }
|
||||
@@ -178,17 +160,16 @@ class STUInt64 : public SerializedType
|
||||
protected:
|
||||
uint64 value;
|
||||
|
||||
STUInt64* duplicate() const { return new STUInt64(name, value); }
|
||||
static STUInt64* construct(SerializerIterator&, const char* name = NULL);
|
||||
STUInt64* duplicate() const { return new STUInt64(fName, value); }
|
||||
static STUInt64* construct(SerializerIterator&, FieldName* name = NULL);
|
||||
|
||||
public:
|
||||
|
||||
STUInt64(uint64 v=0) : value(v) { ; }
|
||||
STUInt64(const char* n, uint64 v=0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
STUInt64(FieldName* n, uint64 v=0) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, FieldName* name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const { return 8; }
|
||||
SerializedTypeID getSType() const { return STI_UINT64; }
|
||||
std::string getText() const;
|
||||
void add(Serializer& s) const { s.add64(value); }
|
||||
@@ -224,7 +205,7 @@ protected:
|
||||
|
||||
void canonicalize();
|
||||
STAmount* duplicate() const { return new STAmount(*this); }
|
||||
static STAmount* construct(SerializerIterator&, const char* name = NULL);
|
||||
static STAmount* construct(SerializerIterator&, FieldName* name = NULL);
|
||||
|
||||
static const int cMinOffset = -96, cMaxOffset = 80;
|
||||
static const uint64 cMinValue = 1000000000000000ull, cMaxValue = 9999999999999999ull;
|
||||
@@ -234,10 +215,10 @@ protected:
|
||||
|
||||
STAmount(bool isNeg, uint64 value) : mValue(value), mOffset(0), mIsNative(true), mIsNegative(isNeg) { ; }
|
||||
|
||||
STAmount(const char *name, uint64 value, bool isNegative)
|
||||
: SerializedType(name), mValue(value), mOffset(0), mIsNative(true), mIsNegative(isNegative)
|
||||
STAmount(FieldName *name, uint64 value, bool isNegative)
|
||||
: SerializedType(fName), mValue(value), mOffset(0), mIsNative(true), mIsNegative(isNegative)
|
||||
{ ; }
|
||||
STAmount(const char *n, const uint160& cur, const uint160& iss, uint64 val, int off, bool isNat, bool isNeg)
|
||||
STAmount(FieldName *n, const uint160& cur, const uint160& iss, uint64 val, int off, bool isNat, bool isNeg)
|
||||
: SerializedType(n), mCurrency(cur), mIssuer(iss), mValue(val), mOffset(off),
|
||||
mIsNative(isNat), mIsNegative(isNeg) { ; }
|
||||
|
||||
@@ -250,7 +231,7 @@ public:
|
||||
STAmount(uint64 v = 0, bool isNeg = false) : mValue(v), mOffset(0), mIsNative(true), mIsNegative(isNeg)
|
||||
{ if (v==0) mIsNegative = false; }
|
||||
|
||||
STAmount(const char* n, uint64 v = 0)
|
||||
STAmount(FieldName* n, uint64 v = 0)
|
||||
: SerializedType(n), mValue(v), mOffset(0), mIsNative(true), mIsNegative(false)
|
||||
{ ; }
|
||||
|
||||
@@ -259,14 +240,14 @@ public:
|
||||
{ canonicalize(); }
|
||||
|
||||
// YYY This should probably require issuer too.
|
||||
STAmount(const char* n, const uint160& currency, const uint160& issuer,
|
||||
STAmount(FieldName* n, const uint160& currency, const uint160& issuer,
|
||||
uint64 v = 0, int off = 0, bool isNeg = false) :
|
||||
SerializedType(n), mCurrency(currency), mIssuer(issuer), mValue(v), mOffset(off), mIsNegative(isNeg)
|
||||
{ canonicalize(); }
|
||||
|
||||
STAmount(const char* n, int64 v);
|
||||
STAmount(FieldName* n, int64 v);
|
||||
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, FieldName* name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
static STAmount saFromRate(uint64 uRate = 0)
|
||||
@@ -279,7 +260,6 @@ public:
|
||||
return STAmount(uCurrencyID, uIssuerID, iV < 0 ? -iV : iV, iOff, iV < 0);
|
||||
}
|
||||
|
||||
int getLength() const { return mIsNative ? 8 : 28; }
|
||||
SerializedTypeID getSType() const { return STI_AMOUNT; }
|
||||
std::string getText() const;
|
||||
std::string getRaw() const;
|
||||
@@ -377,7 +357,7 @@ public:
|
||||
// Native currency conversions, to/from display format
|
||||
static uint64 convertToDisplayAmount(const STAmount& internalAmount, uint64 totalNow, uint64 totalInit);
|
||||
static STAmount convertToInternalAmount(uint64 displayAmount, uint64 totalNow, uint64 totalInit,
|
||||
const char* name = NULL);
|
||||
FieldName* name = NULL);
|
||||
|
||||
static std::string createHumanCurrency(const uint160& uCurrency);
|
||||
static STAmount deserialize(SerializerIterator&);
|
||||
@@ -394,19 +374,18 @@ class STHash128 : public SerializedType
|
||||
protected:
|
||||
uint128 value;
|
||||
|
||||
STHash128* duplicate() const { return new STHash128(name, value); }
|
||||
static STHash128* construct(SerializerIterator&, const char* name = NULL);
|
||||
STHash128* duplicate() const { return new STHash128(fName, value); }
|
||||
static STHash128* construct(SerializerIterator&, FieldName* name = NULL);
|
||||
|
||||
public:
|
||||
|
||||
STHash128(const uint128& v) : value(v) { ; }
|
||||
STHash128(const char* n, const uint128& v) : SerializedType(n), value(v) { ; }
|
||||
STHash128(const char* n) : SerializedType(n) { ; }
|
||||
STHash128(FieldName* n, const uint128& v) : SerializedType(n), value(v) { ; }
|
||||
STHash128(FieldName* n) : SerializedType(n) { ; }
|
||||
STHash128() { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, FieldName* name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const { return 20; }
|
||||
SerializedTypeID getSType() const { return STI_HASH128; }
|
||||
virtual std::string getText() const;
|
||||
void add(Serializer& s) const { s.add128(value); }
|
||||
@@ -423,19 +402,18 @@ class STHash160 : public SerializedType
|
||||
protected:
|
||||
uint160 value;
|
||||
|
||||
STHash160* duplicate() const { return new STHash160(name, value); }
|
||||
static STHash160* construct(SerializerIterator&, const char* name = NULL);
|
||||
STHash160* duplicate() const { return new STHash160(fName, value); }
|
||||
static STHash160* construct(SerializerIterator&, FieldName* name = NULL);
|
||||
|
||||
public:
|
||||
|
||||
STHash160(const uint160& v) : value(v) { ; }
|
||||
STHash160(const char* n, const uint160& v) : SerializedType(n), value(v) { ; }
|
||||
STHash160(const char* n) : SerializedType(n) { ; }
|
||||
STHash160(FieldName* n, const uint160& v) : SerializedType(n), value(v) { ; }
|
||||
STHash160(FieldName* n) : SerializedType(n) { ; }
|
||||
STHash160() { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, FieldName* name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const { return 20; }
|
||||
SerializedTypeID getSType() const { return STI_HASH160; }
|
||||
virtual std::string getText() const;
|
||||
void add(Serializer& s) const { s.add160(value); }
|
||||
@@ -452,19 +430,18 @@ class STHash256 : public SerializedType
|
||||
protected:
|
||||
uint256 value;
|
||||
|
||||
STHash256* duplicate() const { return new STHash256(name, value); }
|
||||
static STHash256* construct(SerializerIterator&, const char* name = NULL);
|
||||
STHash256* duplicate() const { return new STHash256(fName, value); }
|
||||
static STHash256* construct(SerializerIterator&, FieldName* name = NULL);
|
||||
|
||||
public:
|
||||
|
||||
STHash256(const uint256& v) : value(v) { ; }
|
||||
STHash256(const char* n, const uint256& v) : SerializedType(n), value(v) { ; }
|
||||
STHash256(const char* n) : SerializedType(n) { ; }
|
||||
STHash256(FieldName* n, const uint256& v) : SerializedType(n), value(v) { ; }
|
||||
STHash256(FieldName* n) : SerializedType(n) { ; }
|
||||
STHash256() { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, FieldName* name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const { return 32; }
|
||||
SerializedTypeID getSType() const { return STI_HASH256; }
|
||||
std::string getText() const;
|
||||
void add(Serializer& s) const { s.add256(value); }
|
||||
@@ -481,20 +458,19 @@ class STVariableLength : public SerializedType
|
||||
protected:
|
||||
std::vector<unsigned char> value;
|
||||
|
||||
virtual STVariableLength* duplicate() const { return new STVariableLength(name, value); }
|
||||
static STVariableLength* construct(SerializerIterator&, const char* name = NULL);
|
||||
virtual STVariableLength* duplicate() const { return new STVariableLength(fName, value); }
|
||||
static STVariableLength* construct(SerializerIterator&, FieldName* name = NULL);
|
||||
|
||||
public:
|
||||
|
||||
STVariableLength(const std::vector<unsigned char>& v) : value(v) { ; }
|
||||
STVariableLength(const char* n, const std::vector<unsigned char>& v) : SerializedType(n), value(v) { ; }
|
||||
STVariableLength(const char* n) : SerializedType(n) { ; }
|
||||
STVariableLength(SerializerIterator&, const char* name = NULL);
|
||||
STVariableLength(FieldName* n, const std::vector<unsigned char>& v) : SerializedType(n), value(v) { ; }
|
||||
STVariableLength(FieldName* n) : SerializedType(n) { ; }
|
||||
STVariableLength(SerializerIterator&, FieldName* name = NULL);
|
||||
STVariableLength() { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, FieldName* name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const;
|
||||
virtual SerializedTypeID getSType() const { return STI_VL; }
|
||||
virtual std::string getText() const;
|
||||
void add(Serializer& s) const { s.addVL(value); }
|
||||
@@ -511,16 +487,16 @@ public:
|
||||
class STAccount : public STVariableLength
|
||||
{
|
||||
protected:
|
||||
virtual STAccount* duplicate() const { return new STAccount(name, value); }
|
||||
static STAccount* construct(SerializerIterator&, const char* name = NULL);
|
||||
virtual STAccount* duplicate() const { return new STAccount(fName, value); }
|
||||
static STAccount* construct(SerializerIterator&, FieldName* name = NULL);
|
||||
|
||||
public:
|
||||
|
||||
STAccount(const std::vector<unsigned char>& v) : STVariableLength(v) { ; }
|
||||
STAccount(const char* n, const std::vector<unsigned char>& v) : STVariableLength(n, v) { ; }
|
||||
STAccount(const char* n) : STVariableLength(n) { ; }
|
||||
STAccount(FieldName* n, const std::vector<unsigned char>& v) : STVariableLength(n, v) { ; }
|
||||
STAccount(FieldName* n) : STVariableLength(n) { ; }
|
||||
STAccount() { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, FieldName* name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
SerializedTypeID getSType() const { return STI_ACCOUNT; }
|
||||
@@ -649,19 +625,18 @@ class STPathSet : public SerializedType
|
||||
protected:
|
||||
std::vector<STPath> value;
|
||||
|
||||
STPathSet* duplicate() const { return new STPathSet(name, value); }
|
||||
static STPathSet* construct(SerializerIterator&, const char* name = NULL);
|
||||
STPathSet* duplicate() const { return new STPathSet(fName, value); }
|
||||
static STPathSet* construct(SerializerIterator&, FieldName* name = NULL);
|
||||
|
||||
public:
|
||||
|
||||
STPathSet() { ; }
|
||||
STPathSet(const char* n) : SerializedType(n) { ; }
|
||||
STPathSet(FieldName* n) : SerializedType(n) { ; }
|
||||
STPathSet(const std::vector<STPath>& v) : value(v) { ; }
|
||||
STPathSet(const char* n, const std::vector<STPath>& v) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
STPathSet(FieldName* n, const std::vector<STPath>& v) : SerializedType(n), value(v) { ; }
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, FieldName* name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
int getLength() const;
|
||||
// std::string getText() const;
|
||||
void add(Serializer& s) const;
|
||||
virtual Json::Value getJson(int) const;
|
||||
@@ -722,20 +697,19 @@ class STVector256 : public SerializedType
|
||||
protected:
|
||||
std::vector<uint256> mValue;
|
||||
|
||||
STVector256* duplicate() const { return new STVector256(name, mValue); }
|
||||
static STVector256* construct(SerializerIterator&, const char* name = NULL);
|
||||
STVector256* duplicate() const { return new STVector256(fName, mValue); }
|
||||
static STVector256* construct(SerializerIterator&, FieldName* name = NULL);
|
||||
|
||||
public:
|
||||
STVector256() { ; }
|
||||
STVector256(const char* n) : SerializedType(n) { ; }
|
||||
STVector256(const char* n, const std::vector<uint256>& v) : SerializedType(n), mValue(v) { ; }
|
||||
STVector256(FieldName* n) : SerializedType(n) { ; }
|
||||
STVector256(FieldName* n, const std::vector<uint256>& v) : SerializedType(n), mValue(v) { ; }
|
||||
STVector256(const std::vector<uint256>& vector) : mValue(vector) { ; }
|
||||
|
||||
SerializedTypeID getSType() const { return STI_VECTOR256; }
|
||||
int getLength() const { return Serializer::lengthVL(mValue.size() * (256 / 8)); }
|
||||
void add(Serializer& s) const;
|
||||
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, const char* name)
|
||||
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, FieldName* name)
|
||||
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
|
||||
|
||||
const std::vector<uint256>& peekValue() const { return mValue; }
|
||||
|
||||
@@ -1,122 +1,120 @@
|
||||
|
||||
#include "TransactionFormats.h"
|
||||
|
||||
#define S_FIELD(x) sf##x, #x
|
||||
|
||||
TransactionFormat InnerTxnFormats[]=
|
||||
{
|
||||
{ "AccountSet", ttACCOUNT_SET, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(EmailHash), STI_HASH128, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(WalletLocator), STI_HASH256, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(MessageKey), STI_VL, SOE_IFFLAG, 8 },
|
||||
{ S_FIELD(Domain), STI_VL, SOE_IFFLAG, 16 },
|
||||
{ S_FIELD(TransferRate), STI_UINT32, SOE_IFFLAG, 32 },
|
||||
{ S_FIELD(PublishHash), STI_HASH256, SOE_IFFLAG, 64 },
|
||||
{ S_FIELD(PublishSize), STI_UINT32, SOE_IFFLAG, 128 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfSourceTag, SOE_OPTIONAL },
|
||||
{ sfEmailHash, SOE_OPTIONAL },
|
||||
{ sfWalletLocator, SOE_OPTIONAL },
|
||||
{ sfMessageKey, SOE_OPTIONAL },
|
||||
{ sfDomain, SOE_OPTIONAL },
|
||||
{ sfTransferRate, SOE_OPTIONAL },
|
||||
{ sfPublishHash, SOE_OPTIONAL },
|
||||
{ sfPublishSize, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "Claim", ttCLAIM, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Generator), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(PublicKey), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Signature), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfGenerator, SOE_REQUIRED },
|
||||
{ sfPublicKey, SOE_REQUIRED },
|
||||
{ sfSignature, SOE_REQUIRED },
|
||||
{ sfSourceTag, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "CreditSet", ttCREDIT_SET, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Destination), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(LimitAmount), STI_AMOUNT, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(QualityIn), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(QualityOut), STI_UINT32, SOE_IFFLAG, 8 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfDestination, SOE_REQUIRED },
|
||||
{ sfSourceTag, SOE_OPTIONAL },
|
||||
{ sfLimitAmount, SOE_OPTIONAL },
|
||||
{ sfQualityIn, SOE_OPTIONAL },
|
||||
{ sfQualityOut, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
/*
|
||||
{ "Invoice", ttINVOICE, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Target), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Amount), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(Destination), STI_ACCOUNT, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(Identifier), STI_VL, SOE_IFFLAG, 4 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfTarget, SOE_REQUIRED },
|
||||
{ sfAmount, SOE_REQUIRED },
|
||||
{ sfSourceTag, SOE_OPTIONAL },
|
||||
{ sfDestination, SOE_OPTIONAL },
|
||||
{ sfIdentifier, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
*/
|
||||
{ "NicknameSet", ttNICKNAME_SET, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Nickname), STI_HASH256, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(MinimumOffer), STI_AMOUNT, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(Signature), STI_VL, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfNickname, SOE_REQUIRED },
|
||||
{ sfMinimumOffer, SOE_OPTIONAL },
|
||||
{ sfSignature, SOE_OPTIONAL },
|
||||
{ sfSourceTag, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "OfferCreate", ttOFFER_CREATE, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(TakerPays), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(TakerGets), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(Expiration), STI_UINT32, SOE_IFFLAG, 2 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED},
|
||||
{ sfTakerPays, SOE_REQUIRED },
|
||||
{ sfTakerGets, SOE_REQUIRED },
|
||||
{ sfSourceTag, SOE_OPTIONAL },
|
||||
{ sfExpiration, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "OfferCancel", ttOFFER_CANCEL, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(OfferSequence), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfOfferSequence, SOE_REQUIRED },
|
||||
{ sfSourceTag, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "PasswordFund", ttPASSWORD_FUND, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Destination), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfDestination, SOE_REQUIRED },
|
||||
{ sfSourceTag, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "PasswordSet", ttPASSWORD_SET, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(AuthorizedKey), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Generator), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(PublicKey), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Signature), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfAuthorizedKey, SOE_REQUIRED },
|
||||
{ sfGenerator, SOE_REQUIRED },
|
||||
{ sfPublicKey, SOE_REQUIRED },
|
||||
{ sfSignature, SOE_REQUIRED },
|
||||
{ sfSourceTag, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "Payment", ttPAYMENT, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Destination), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Amount), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SendMax), STI_AMOUNT, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(Paths), STI_PATHSET, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
{ S_FIELD(InvoiceID), STI_HASH256, SOE_IFFLAG, 8 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfDestination, SOE_REQUIRED },
|
||||
{ sfAmount, SOE_REQUIRED },
|
||||
{ sfSendMax, SOE_OPTIONAL },
|
||||
{ sfPaths, SOE_OPTIONAL },
|
||||
{ sfSourceTag, SOE_OPTIONAL },
|
||||
{ sfInvoiceID, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "WalletAdd", ttWALLET_ADD, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Amount), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(AuthorizedKey), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(PublicKey), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Signature), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfAmount, SOE_REQUIRED },
|
||||
{ sfAuthorizedKey, SOE_REQUIRED },
|
||||
{ sfPublicKey, SOE_REQUIRED },
|
||||
{ sfSignature, SOE_REQUIRED },
|
||||
{ sfSourceTag, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "Contract", ttCONTRACT, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Expiration), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(BondAmount), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(StampEscrow), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(RippleEscrow), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(CreateCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(FundCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(RemoveCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(ExpireCode), STI_VL, SOE_REQUIRED, 0 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfExpiration, SOE_REQUIRED },
|
||||
{ sfBondAmount, SOE_REQUIRED },
|
||||
{ sfStampEscrow, SOE_REQUIRED },
|
||||
{ sfRippleEscrow, SOE_REQUIRED },
|
||||
{ sfCreateCode, SOE_OPTIONAL },
|
||||
{ sfFundCode, SOE_OPTIONAL },
|
||||
{ sfRemoveCode, SOE_OPTIONAL },
|
||||
{ sfExpireCode, SOE_OPTIONAL },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ "Contract", ttCONTRACT_REMOVE, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Target), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ sfInvalid, NULL, STI_DONE, SOE_NEVER, -1 } }
|
||||
{ "RemoveContract", ttCONTRACT_REMOVE, {
|
||||
{ sfFlags, SOE_REQUIRED },
|
||||
{ sfTarget, SOE_REQUIRED },
|
||||
{ sfInvalid, SOE_END } }
|
||||
},
|
||||
{ NULL, ttINVALID }
|
||||
};
|
||||
|
||||
@@ -23,9 +23,9 @@ enum TransactionType
|
||||
|
||||
struct TransactionFormat
|
||||
{
|
||||
const char *t_name;
|
||||
const char * t_name;
|
||||
TransactionType t_type;
|
||||
SOElement elements[16];
|
||||
SOElement elements[24];
|
||||
};
|
||||
|
||||
const int TransactionISigningPubKey = 0;
|
||||
|
||||
Reference in New Issue
Block a user