mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Cleanups.
This commit is contained in:
50
src/SHAMap.h
50
src/SHAMap.h
@@ -166,16 +166,16 @@ public:
|
|||||||
|
|
||||||
// node functions
|
// node functions
|
||||||
uint32 getSeq() const { return mSeq; }
|
uint32 getSeq() const { return mSeq; }
|
||||||
void setSeq(uint32 s) { mSeq=s; }
|
void setSeq(uint32 s) { mSeq = s; }
|
||||||
const uint256& getNodeHash() const { return mHash; }
|
const uint256& getNodeHash() const { return mHash; }
|
||||||
TNType getType() const { return mType; }
|
TNType getType() const { return mType; }
|
||||||
|
|
||||||
// type functions
|
// type functions
|
||||||
bool isLeaf() const { return (mType==tnTRANSACTION) || (mType==tnACCOUNT_STATE); }
|
bool isLeaf() const { return (mType == tnTRANSACTION) || (mType == tnACCOUNT_STATE); }
|
||||||
bool isInner() const { return mType==tnINNER; }
|
bool isInner() const { return mType == tnINNER; }
|
||||||
bool isValid() const { return mType!=tnERROR; }
|
bool isValid() const { return mType != tnERROR; }
|
||||||
bool isTransaction() const { return mType!=tnTRANSACTION; }
|
bool isTransaction() const { return mType != tnTRANSACTION; }
|
||||||
bool isAccountState() const { return mType!=tnACCOUNT_STATE; }
|
bool isAccountState() const { return mType != tnACCOUNT_STATE; }
|
||||||
|
|
||||||
// inner node functions
|
// inner node functions
|
||||||
bool isInnerNode() const { return !mItem; }
|
bool isInnerNode() const { return !mItem; }
|
||||||
@@ -196,7 +196,7 @@ public:
|
|||||||
|
|
||||||
// sync functions
|
// sync functions
|
||||||
bool isFullBelow(void) const { return mFullBelow; }
|
bool isFullBelow(void) const { return mFullBelow; }
|
||||||
void setFullBelow(void) { mFullBelow=true; }
|
void setFullBelow(void) { mFullBelow = true; }
|
||||||
|
|
||||||
virtual void dump();
|
virtual void dump();
|
||||||
virtual std::string getString() const;
|
virtual std::string getString() const;
|
||||||
@@ -204,18 +204,18 @@ public:
|
|||||||
|
|
||||||
enum SHAMapException
|
enum SHAMapException
|
||||||
{
|
{
|
||||||
MissingNode=1,
|
MissingNode = 1,
|
||||||
InvalidNode=2,
|
InvalidNode = 2,
|
||||||
InvalidMap=3,
|
InvalidMap = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum SHAMapState
|
enum SHAMapState
|
||||||
{
|
{
|
||||||
Modifying=0, // Objects can be added and removed (like an open ledger)
|
Modifying = 0, // Objects can be added and removed (like an open ledger)
|
||||||
Immutable=1, // Map cannot be changed (like a closed ledger)
|
Immutable = 1, // Map cannot be changed (like a closed ledger)
|
||||||
Synching=2, // Map's hash is locked in, valid nodes can be added (like a peer's closing ledger)
|
Synching = 2, // Map's hash is locked in, valid nodes can be added (like a peer's closing ledger)
|
||||||
Floating=3, // Map is free to change hash (like a synching open ledger)
|
Floating = 3, // Map is free to change hash (like a synching open ledger)
|
||||||
Invalid=4, // Map is known not to be valid (usually synching a corrupt ledger)
|
Invalid = 4, // Map is known not to be valid (usually synching a corrupt ledger)
|
||||||
};
|
};
|
||||||
|
|
||||||
class SHAMap
|
class SHAMap
|
||||||
@@ -298,13 +298,13 @@ public:
|
|||||||
bool addKnownNode(const SHAMapNode& nodeID, const std::vector<unsigned char>& rawNode);
|
bool addKnownNode(const SHAMapNode& nodeID, const std::vector<unsigned char>& rawNode);
|
||||||
|
|
||||||
// status functions
|
// status functions
|
||||||
void setImmutable(void) { assert(mState!=Invalid); mState=Immutable; }
|
void setImmutable(void) { assert(mState != Invalid); mState = Immutable; }
|
||||||
void clearImmutable(void) { mState=Modifying; }
|
void clearImmutable(void) { mState = Modifying; }
|
||||||
bool isSynching(void) const { return mState==Floating || mState==Synching; }
|
bool isSynching(void) const { return mState == Floating || mState == Synching; }
|
||||||
void setSynching(void) { mState=Synching; }
|
void setSynching(void) { mState = Synching; }
|
||||||
void setFloating(void) { mState=Floating; }
|
void setFloating(void) { mState = Floating; }
|
||||||
void clearSynching(void) { mState=Modifying; }
|
void clearSynching(void) { mState = Modifying; }
|
||||||
bool isValid(void) { return mState!=Invalid; }
|
bool isValid(void) { return mState != Invalid; }
|
||||||
|
|
||||||
// caution: otherMap must be accessed only by this function
|
// caution: otherMap must be accessed only by this function
|
||||||
// return value: true=successfully completed, false=too different
|
// return value: true=successfully completed, false=too different
|
||||||
@@ -312,18 +312,18 @@ public:
|
|||||||
|
|
||||||
int flushDirty(int maxNodes, HashedObjectType t, uint32 seq);
|
int flushDirty(int maxNodes, HashedObjectType t, uint32 seq);
|
||||||
|
|
||||||
void setSeq(uint32 seq) { mSeq=seq; }
|
void setSeq(uint32 seq) { mSeq = seq; }
|
||||||
uint32 getSeq() { return mSeq; }
|
uint32 getSeq() { return mSeq; }
|
||||||
|
|
||||||
// overloads for backed maps
|
// overloads for backed maps
|
||||||
bool fetchNode(const uint256& hash, std::vector<unsigned char>& rawNode);
|
bool fetchNode(const uint256& hash, std::vector<unsigned char>& rawNode);
|
||||||
|
|
||||||
bool operator==(const SHAMap& s) { return getHash()==s.getHash(); }
|
bool operator==(const SHAMap& s) { return getHash() == s.getHash(); }
|
||||||
|
|
||||||
static bool TestSHAMap();
|
static bool TestSHAMap();
|
||||||
static bool syncTest();
|
static bool syncTest();
|
||||||
bool deepCompare(SHAMap& other);
|
bool deepCompare(SHAMap& other);
|
||||||
virtual void dump(bool withHashes=false);
|
virtual void dump(bool withHashes = false);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -9,14 +9,14 @@
|
|||||||
std::string SerializedType::getFullText() const
|
std::string SerializedType::getFullText() const
|
||||||
{
|
{
|
||||||
std::string ret;
|
std::string ret;
|
||||||
if(getSType()!=STI_NOTPRESENT)
|
if (getSType() != STI_NOTPRESENT)
|
||||||
{
|
{
|
||||||
if(name!=NULL)
|
if(name != NULL)
|
||||||
{
|
{
|
||||||
ret=name;
|
ret = name;
|
||||||
ret+=" = ";
|
ret += " = ";
|
||||||
}
|
}
|
||||||
ret+=getText();
|
ret += getText();
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -33,8 +33,8 @@ std::string STUInt8::getText() const
|
|||||||
|
|
||||||
bool STUInt8::isEquivalent(const SerializedType& t) const
|
bool STUInt8::isEquivalent(const SerializedType& t) const
|
||||||
{
|
{
|
||||||
const STUInt8* v=dynamic_cast<const STUInt8*>(&t);
|
const STUInt8* v = dynamic_cast<const STUInt8*>(&t);
|
||||||
return v && (value==v->value);
|
return v && (value == v->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
STUInt16* STUInt16::construct(SerializerIterator& u, const char *name)
|
STUInt16* STUInt16::construct(SerializerIterator& u, const char *name)
|
||||||
@@ -49,8 +49,8 @@ std::string STUInt16::getText() const
|
|||||||
|
|
||||||
bool STUInt16::isEquivalent(const SerializedType& t) const
|
bool STUInt16::isEquivalent(const SerializedType& t) const
|
||||||
{
|
{
|
||||||
const STUInt16* v=dynamic_cast<const STUInt16*>(&t);
|
const STUInt16* v = dynamic_cast<const STUInt16*>(&t);
|
||||||
return v && (value==v->value);
|
return v && (value == v->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
STUInt32* STUInt32::construct(SerializerIterator& u, const char *name)
|
STUInt32* STUInt32::construct(SerializerIterator& u, const char *name)
|
||||||
@@ -65,8 +65,8 @@ std::string STUInt32::getText() const
|
|||||||
|
|
||||||
bool STUInt32::isEquivalent(const SerializedType& t) const
|
bool STUInt32::isEquivalent(const SerializedType& t) const
|
||||||
{
|
{
|
||||||
const STUInt32* v=dynamic_cast<const STUInt32*>(&t);
|
const STUInt32* v = dynamic_cast<const STUInt32*>(&t);
|
||||||
return v && (value==v->value);
|
return v && (value == v->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
STUInt64* STUInt64::construct(SerializerIterator& u, const char *name)
|
STUInt64* STUInt64::construct(SerializerIterator& u, const char *name)
|
||||||
@@ -81,8 +81,8 @@ std::string STUInt64::getText() const
|
|||||||
|
|
||||||
bool STUInt64::isEquivalent(const SerializedType& t) const
|
bool STUInt64::isEquivalent(const SerializedType& t) const
|
||||||
{
|
{
|
||||||
const STUInt64* v=dynamic_cast<const STUInt64*>(&t);
|
const STUInt64* v = dynamic_cast<const STUInt64*>(&t);
|
||||||
return v && (value==v->value);
|
return v && (value == v->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
STHash128* STHash128::construct(SerializerIterator& u, const char *name)
|
STHash128* STHash128::construct(SerializerIterator& u, const char *name)
|
||||||
@@ -97,8 +97,8 @@ std::string STHash128::getText() const
|
|||||||
|
|
||||||
bool STHash128::isEquivalent(const SerializedType& t) const
|
bool STHash128::isEquivalent(const SerializedType& t) const
|
||||||
{
|
{
|
||||||
const STHash128* v=dynamic_cast<const STHash128*>(&t);
|
const STHash128* v = dynamic_cast<const STHash128*>(&t);
|
||||||
return v && (value==v->value);
|
return v && (value == v->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
STHash160* STHash160::construct(SerializerIterator& u, const char *name)
|
STHash160* STHash160::construct(SerializerIterator& u, const char *name)
|
||||||
@@ -113,8 +113,8 @@ std::string STHash160::getText() const
|
|||||||
|
|
||||||
bool STHash160::isEquivalent(const SerializedType& t) const
|
bool STHash160::isEquivalent(const SerializedType& t) const
|
||||||
{
|
{
|
||||||
const STHash160* v=dynamic_cast<const STHash160*>(&t);
|
const STHash160* v = dynamic_cast<const STHash160*>(&t);
|
||||||
return v && (value==v->value);
|
return v && (value == v->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
STHash256* STHash256::construct(SerializerIterator& u, const char *name)
|
STHash256* STHash256::construct(SerializerIterator& u, const char *name)
|
||||||
@@ -129,8 +129,8 @@ std::string STHash256::getText() const
|
|||||||
|
|
||||||
bool STHash256::isEquivalent(const SerializedType& t) const
|
bool STHash256::isEquivalent(const SerializedType& t) const
|
||||||
{
|
{
|
||||||
const STHash256* v=dynamic_cast<const STHash256*>(&t);
|
const STHash256* v = dynamic_cast<const STHash256*>(&t);
|
||||||
return v && (value==v->value);
|
return v && (value == v->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
static std::string hex(const std::vector<unsigned char>& value)
|
static std::string hex(const std::vector<unsigned char>& value)
|
||||||
@@ -159,26 +159,28 @@ int STVariableLength::getLength() const
|
|||||||
|
|
||||||
bool STVariableLength::isEquivalent(const SerializedType& t) const
|
bool STVariableLength::isEquivalent(const SerializedType& t) const
|
||||||
{
|
{
|
||||||
const STVariableLength* v=dynamic_cast<const STVariableLength*>(&t);
|
const STVariableLength* v = dynamic_cast<const STVariableLength*>(&t);
|
||||||
return v && (value==v->value);
|
return v && (value == v->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string STAccount::getText() const
|
std::string STAccount::getText() const
|
||||||
{
|
{
|
||||||
uint160 u;
|
uint160 u;
|
||||||
NewcoinAddress a;
|
NewcoinAddress a;
|
||||||
if(!getValueH160(u)) return STVariableLength::getText();
|
|
||||||
|
if (!getValueH160(u))
|
||||||
|
return STVariableLength::getText();
|
||||||
a.setAccountID(u);
|
a.setAccountID(u);
|
||||||
return a.humanAccountPublic();
|
return a.humanAccountPublic();
|
||||||
}
|
}
|
||||||
|
|
||||||
STAccount* STAccount::construct(SerializerIterator& u, const char *name)
|
STAccount* STAccount::construct(SerializerIterator& u, const char *name)
|
||||||
{
|
{
|
||||||
STAccount *ret=new STAccount(u.getVL());
|
STAccount *ret = new STAccount(u.getVL());
|
||||||
if(!ret->isValueH160())
|
if (!ret->isValueH160())
|
||||||
{
|
{
|
||||||
delete ret;
|
delete ret;
|
||||||
throw(std::runtime_error("invalid account in transaction"));
|
throw std::runtime_error("invalid account in transaction");
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -196,7 +198,7 @@ void STAccount::setValueH160(const uint160& v)
|
|||||||
|
|
||||||
bool STAccount::getValueH160(uint160& v) const
|
bool STAccount::getValueH160(uint160& v) const
|
||||||
{
|
{
|
||||||
if(!isValueH160()) return false;
|
if (!isValueH160()) return false;
|
||||||
memcpy(v.begin(), &(peekValue().front()), 32);
|
memcpy(v.begin(), &(peekValue().front()), 32);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -204,11 +206,11 @@ bool STAccount::getValueH160(uint160& v) const
|
|||||||
std::string STTaggedList::getText() const
|
std::string STTaggedList::getText() const
|
||||||
{
|
{
|
||||||
std::string ret;
|
std::string ret;
|
||||||
for(std::vector<TaggedListItem>::const_iterator it=value.begin(); it!=value.end(); ++it)
|
for (std::vector<TaggedListItem>::const_iterator it=value.begin(); it!=value.end(); ++it)
|
||||||
{
|
{
|
||||||
ret+=boost::lexical_cast<std::string>(it->first);
|
ret += boost::lexical_cast<std::string>(it->first);
|
||||||
ret+=",";
|
ret += ",";
|
||||||
ret+=hex(it->second);
|
ret += hex(it->second);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -220,13 +222,13 @@ STTaggedList* STTaggedList::construct(SerializerIterator& u, const char *name)
|
|||||||
|
|
||||||
int STTaggedList::getLength() const
|
int STTaggedList::getLength() const
|
||||||
{
|
{
|
||||||
int ret=Serializer::getTaggedListLength(value);
|
int ret = Serializer::getTaggedListLength(value);
|
||||||
if(ret<0) throw(std::overflow_error("bad TL length"));
|
if (ret<0) throw std::overflow_error("bad TL length");
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool STTaggedList::isEquivalent(const SerializedType& t) const
|
bool STTaggedList::isEquivalent(const SerializedType& t) const
|
||||||
{
|
{
|
||||||
const STTaggedList* v=dynamic_cast<const STTaggedList*>(&t);
|
const STTaggedList* v = dynamic_cast<const STTaggedList*>(&t);
|
||||||
return v && (value==v->value);
|
return v && (value == v->value);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user