Cleanups and fixes.

This commit is contained in:
JoelKatz
2012-09-27 14:11:10 -07:00
parent c9b8408d08
commit a40120b6c9
9 changed files with 35 additions and 35 deletions

View File

@@ -274,7 +274,7 @@ void STAmount::canonicalize()
assert((mValue != 0) || (mOffset != -100) );
}
void STAmount::add(Serializer& s) const
void STAmount::addData(Serializer& s) const
{
if (mIsNative)
{

View File

@@ -64,7 +64,7 @@
FIELD(BaseFee, UINT64, 6)
// 128-bit
FIELD(EmailHash, HASH128, 2)
FIELD(EmailHash, HASH128, 1)
// 256-bit (common)
FIELD(LedgerHash, HASH256, 1)
@@ -98,7 +98,7 @@
// variable length
FIELD(PublicKey, VL, 1)
FIELD(MessageKey, VL, 2)
FIELD(SigningKey, VL, 3)
FIELD(SigningPubKey, VL, 3)
FIELD(Signature, VL, 4)
FIELD(Generator, VL, 5)
FIELD(Domain, VL, 6)
@@ -125,8 +125,7 @@
// inner object
// OBJECT/1 is reserved for end of object
FIELD(MiddleTransaction, OBJECT, 2)
FIELD(InnerTransaction, OBJECT, 3)
FIELD(InnerTransaction, OBJECT, 1)
// array of objects
// ARRAY/1 is reserved for end of array

View File

@@ -28,8 +28,8 @@ public:
std::string getText() const;
Json::Value getJson(int options) const;
const uint256& getIndex() const;
void setIndex(const uint256& i);
const uint256& getIndex() const { return mIndex; }
void setIndex(const uint256& i) { mIndex = i; }
LedgerEntryType getType() const { return mType; }
uint16 getVersion() const { return getValueFieldU16(sfLedgerEntryType); }

View File

@@ -212,11 +212,11 @@ std::string STObject::getFullText() const
void STObject::add(Serializer& s) const
{
addFieldID(s);
addRaw(s);
addData(s);
s.addFieldID(STI_OBJECT, 1);
}
void STObject::addRaw(Serializer& s) const
void STObject::addData(Serializer& s) const
{ // FIXME: need to add in sorted order
BOOST_FOREACH(const SerializedType& it, mData)
it.add(s);

View File

@@ -57,7 +57,7 @@ public:
virtual bool isEquivalent(const SerializedType& t) const;
void add(Serializer& s) const; // with start/end of object
virtual void addRaw(Serializer& s) const; // just inner elements
virtual void addData(Serializer& s) const; // just inner elements
Serializer getSerializer() const { Serializer s; add(s); return s; }
std::string getFullText() const;
std::string getText() const;

View File

@@ -12,7 +12,7 @@ SerializedTransaction::SerializedTransaction(TransactionType type) : mType(type)
mFormat = getTxnFormat(type);
if (mFormat == NULL) throw std::runtime_error("invalid transaction type");
mMiddleTxn.giveObject(new STVariableLength(sfSigningKey));
mMiddleTxn.giveObject(new STVariableLength(sfSigningPubKey));
mMiddleTxn.giveObject(new STAccount(sfAccount));
mMiddleTxn.giveObject(new STUInt32(sfSequence));
mMiddleTxn.giveObject(new STUInt16(sfTransactionType, static_cast<uint16>(type)));
@@ -32,25 +32,25 @@ SerializedTransaction::SerializedTransaction(SerializerIterator& sit)
mSignature.setValue(sit.getVL());
mMiddleTxn.giveObject(new STVariableLength("SigningPubKey", sit.getVL()));
mMiddleTxn.giveObject(new STVariableLength(sfSigningPubKey, sit.getVL()));
STAccount sa("SourceAccount", sit.getVL());
STAccount sa(sfAccount, sit.getVL());
mSourceAccount = sa.getValueNCA();
mMiddleTxn.giveObject(new STAccount(sa));
mMiddleTxn.giveObject(new STUInt32("Sequence", sit.get32()));
mMiddleTxn.giveObject(new STUInt32(sfSequence, sit.get32()));
mType = static_cast<TransactionType>(sit.get16());
mMiddleTxn.giveObject(new STUInt16("Type", static_cast<uint16>(mType)));
mMiddleTxn.giveObject(new STUInt16(sfTransactionType, static_cast<uint16>(mType)));
mFormat = getTxnFormat(mType);
if (!mFormat)
{
Log(lsERROR) << "Transaction has invalid type";
throw std::runtime_error("Transaction has invalid type");
}
mMiddleTxn.giveObject(STAmount::deserialize(sit, "Fee"));
mMiddleTxn.giveObject(STAmount::deserialize(sit, sfFee));
mInnerTxn = STObject(mFormat->elements, sit, "InnerTransaction");
mInnerTxn = STObject(mFormat->elements, sit, sfInnerTransaction);
}
std::string SerializedTransaction::getFullText() const

View File

@@ -202,7 +202,7 @@ STVector256* STVector256::construct(SerializerIterator& u, SField::ref name)
return new STVector256(name, value);
}
void STVector256::add(Serializer& s) const
void STVector256::addData(Serializer& s) const
{
s.addVL(mValue.empty() ? NULL : mValue[0].begin(), mValue.size() * (256 / 8));
}
@@ -427,7 +427,7 @@ std::string STPathSet::getText() const
}
#endif
void STPathSet::add(Serializer& s) const
void STPathSet::addData(Serializer& s) const
{
bool bFirst = true;

View File

@@ -61,7 +61,8 @@ public:
virtual Json::Value getJson(int) const
{ return getText(); }
virtual void add(Serializer& s) const { return; }
virtual void add(Serializer& s) const { addFieldID(s); addData(s); }
virtual void addData(Serializer& s) const { ; }
virtual bool isEquivalent(const SerializedType& t) const
{ assert(getSType() == STI_NOTPRESENT); return t.getSType() == STI_NOTPRESENT; }
@@ -97,7 +98,7 @@ public:
SerializedTypeID getSType() const { return STI_UINT8; }
std::string getText() const;
void add(Serializer& s) const { s.add8(value); }
void addData(Serializer& s) const { s.add8(value); }
unsigned char getValue() const { return value; }
void setValue(unsigned char v) { value = v; }
@@ -123,7 +124,7 @@ public:
SerializedTypeID getSType() const { return STI_UINT16; }
std::string getText() const;
void add(Serializer& s) const { s.add16(value); }
void addData(Serializer& s) const { s.add16(value); }
uint16 getValue() const { return value; }
void setValue(uint16 v) { value=v; }
@@ -149,7 +150,7 @@ public:
SerializedTypeID getSType() const { return STI_UINT32; }
std::string getText() const;
void add(Serializer& s) const { s.add32(value); }
void addData(Serializer& s) const { s.add32(value); }
uint32 getValue() const { return value; }
void setValue(uint32 v) { value=v; }
@@ -175,7 +176,7 @@ public:
SerializedTypeID getSType() const { return STI_UINT64; }
std::string getText() const;
void add(Serializer& s) const { s.add64(value); }
void addData(Serializer& s) const { s.add64(value); }
uint64 getValue() const { return value; }
void setValue(uint64 v) { value=v; }
@@ -267,7 +268,7 @@ public:
std::string getText() const;
std::string getRaw() const;
std::string getFullText() const;
void add(Serializer& s) const;
void addData(Serializer& s) const;
int getExponent() const { return mOffset; }
uint64 getMantissa() const { return mValue; }
@@ -391,7 +392,7 @@ public:
SerializedTypeID getSType() const { return STI_HASH128; }
virtual std::string getText() const;
void add(Serializer& s) const { s.add128(value); }
void addData(Serializer& s) const { s.add128(value); }
const uint128& getValue() const { return value; }
void setValue(const uint128& v) { value=v; }
@@ -419,7 +420,7 @@ public:
SerializedTypeID getSType() const { return STI_HASH160; }
virtual std::string getText() const;
void add(Serializer& s) const { s.add160(value); }
void addData(Serializer& s) const { s.add160(value); }
const uint160& getValue() const { return value; }
void setValue(const uint160& v) { value=v; }
@@ -447,7 +448,7 @@ public:
SerializedTypeID getSType() const { return STI_HASH256; }
std::string getText() const;
void add(Serializer& s) const { s.add256(value); }
void addData(Serializer& s) const { s.add256(value); }
const uint256& getValue() const { return value; }
void setValue(const uint256& v) { value=v; }
@@ -476,7 +477,7 @@ public:
virtual SerializedTypeID getSType() const { return STI_VL; }
virtual std::string getText() const;
void add(Serializer& s) const { s.addVL(value); }
void addData(Serializer& s) const { s.addVL(value); }
const std::vector<unsigned char>& peekValue() const { return value; }
std::vector<unsigned char>& peekValue() { return value; }
@@ -641,7 +642,7 @@ public:
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }
// std::string getText() const;
void add(Serializer& s) const;
void addData(Serializer& s) const;
virtual Json::Value getJson(int) const;
SerializedTypeID getSType() const { return STI_PATHSET; }
@@ -710,7 +711,7 @@ public:
STVector256(const std::vector<uint256>& vector) : mValue(vector) { ; }
SerializedTypeID getSType() const { return STI_VECTOR256; }
void add(Serializer& s) const;
void addData(Serializer& s) const;
static std::auto_ptr<SerializedType> deserialize(SerializerIterator& sit, SField::ref name)
{ return std::auto_ptr<SerializedType>(construct(sit, name)); }

View File

@@ -11,7 +11,7 @@ SOElement SerializedValidation::sValidationFormat[] = {
{ sfLoadFee, SOE_OPTIONAL },
{ sfBaseFee, SOE_OPTIONAL },
{ sfSigningTime, SOE_REQUIRED },
{ sfSigningKey, SOE_REQUIRED },
{ sfSigningPubKey, SOE_REQUIRED },
{ sfInvalid, SOE_END }
};
@@ -30,7 +30,7 @@ SerializedValidation::SerializedValidation(const uint256& ledgerHash, uint32 sig
setValueFieldH256(sfLedgerHash, ledgerHash);
setValueFieldU32(sfSigningTime, signTime);
if (naSeed.isValid())
setValueFieldVL(sfSigningKey, NewcoinAddress::createNodePublic(naSeed).getNodePublic());
setValueFieldVL(sfSigningPubKey, NewcoinAddress::createNodePublic(naSeed).getNodePublic());
if (!isFull) setFlag(sFullFlag);
NewcoinAddress::createNodePrivate(naSeed).signNodePrivate(getSigningHash(), mSignature.peekValue());
@@ -73,7 +73,7 @@ bool SerializedValidation::isValid(const uint256& signingHash) const
{
try
{
NewcoinAddress naPublicKey = NewcoinAddress::createNodePublic(getValueFieldVL(sfSigningKey));
NewcoinAddress naPublicKey = NewcoinAddress::createNodePublic(getValueFieldVL(sfSigningPubKey));
return naPublicKey.isValid() && naPublicKey.verifyNodePublic(signingHash, mSignature.peekValue());
}
catch (...)
@@ -85,7 +85,7 @@ bool SerializedValidation::isValid(const uint256& signingHash) const
NewcoinAddress SerializedValidation::getSignerPublic() const
{
NewcoinAddress a;
a.setNodePublic(getValueFieldVL(sfSigningKey));
a.setNodePublic(getValueFieldVL(sfSigningPubKey));
return a;
}