mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Rename SHAMap states.
This commit is contained in:
@@ -39,14 +39,14 @@ std::size_t hash_value(const uint160& u)
|
||||
}
|
||||
|
||||
|
||||
SHAMap::SHAMap(uint32 seq) : mSeq(seq), mState(Modifying)
|
||||
SHAMap::SHAMap(uint32 seq) : mSeq(seq), mState(smsModifying)
|
||||
{
|
||||
root = boost::make_shared<SHAMapTreeNode>(mSeq, SHAMapNode(0, uint256()));
|
||||
root->makeInner();
|
||||
mTNByID[*root] = root;
|
||||
}
|
||||
|
||||
SHAMap::SHAMap(const uint256& hash) : mSeq(0), mState(Synching)
|
||||
SHAMap::SHAMap(const uint256& hash) : mSeq(0), mState(smsSynching)
|
||||
{ // FIXME: Need to acquire root node
|
||||
root = boost::make_shared<SHAMapTreeNode>(mSeq, SHAMapNode(0, uint256()));
|
||||
root->makeInner();
|
||||
@@ -62,7 +62,7 @@ SHAMap::pointer SHAMap::snapShot(bool isMutable)
|
||||
newMap.mTNByID = mTNByID;
|
||||
newMap.root = root;
|
||||
if (!isMutable)
|
||||
newMap.mState = Immutable;
|
||||
newMap.mState = smsImmutable;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -105,7 +105,7 @@ void SHAMap::dirtyUp(std::stack<SHAMapTreeNode::pointer>& stack, const uint256&
|
||||
{ // walk the tree up from through the inner nodes to the root
|
||||
// update linking hashes and add nodes to dirty list
|
||||
|
||||
assert((mState != Synching) && (mState != Immutable));
|
||||
assert((mState != smsSynching) && (mState != smsImmutable));
|
||||
|
||||
while (!stack.empty())
|
||||
{
|
||||
@@ -475,7 +475,7 @@ bool SHAMap::hasItem(const uint256& id)
|
||||
bool SHAMap::delItem(const uint256& id)
|
||||
{ // delete the item with this ID
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
assert(mState != Immutable);
|
||||
assert(mState != smsImmutable);
|
||||
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack(id, true, false);
|
||||
if (stack.empty())
|
||||
@@ -552,7 +552,7 @@ bool SHAMap::addGiveItem(const SHAMapItem::pointer& item, bool isTransaction, bo
|
||||
(hasMeta ? SHAMapTreeNode::tnTRANSACTION_MD : SHAMapTreeNode::tnTRANSACTION_NM);
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
assert(mState != Immutable);
|
||||
assert(mState != smsImmutable);
|
||||
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack(tag, true, false);
|
||||
if (stack.empty())
|
||||
@@ -644,7 +644,7 @@ bool SHAMap::updateGiveItem(const SHAMapItem::pointer& item, bool isTransaction,
|
||||
uint256 tag = item->getTag();
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
assert(mState != Immutable);
|
||||
assert(mState != smsImmutable);
|
||||
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack(tag, true, false);
|
||||
if (stack.empty()) throw std::runtime_error("missing node");
|
||||
|
||||
30
src/SHAMap.h
30
src/SHAMap.h
@@ -217,11 +217,11 @@ public:
|
||||
|
||||
enum SHAMapState
|
||||
{
|
||||
Modifying = 0, // Objects can be added and removed (like an open 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)
|
||||
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)
|
||||
smsModifying = 0, // Objects can be added and removed (like an open ledger)
|
||||
smsImmutable = 1, // Map cannot be changed (like a closed ledger)
|
||||
smsSynching = 2, // Map's hash is locked in, valid nodes can be added (like a peer's closing ledger)
|
||||
smsFloating = 3, // Map is free to change hash (like a synching open ledger)
|
||||
smsInvalid = 4, // Map is known not to be valid (usually synching a corrupt ledger)
|
||||
};
|
||||
|
||||
class SHAMapSyncFilter
|
||||
@@ -229,9 +229,11 @@ class SHAMapSyncFilter
|
||||
public:
|
||||
SHAMapSyncFilter() { ; }
|
||||
virtual ~SHAMapSyncFilter() { ; }
|
||||
|
||||
virtual void gotNode(const SHAMapNode& id, const uint256& nodeHash,
|
||||
const std::vector<unsigned char>& nodeData, bool isLeaf)
|
||||
{ ; }
|
||||
|
||||
virtual bool haveNode(const SHAMapNode& id, const uint256& nodeHash, std::vector<unsigned char>& nodeData)
|
||||
{ return false; }
|
||||
};
|
||||
@@ -248,6 +250,7 @@ public:
|
||||
{ ; }
|
||||
virtual ~SHAMapMissingNode() throw()
|
||||
{ ; }
|
||||
|
||||
const SHAMapNode& getNodeID() const { return mNodeID; }
|
||||
const uint256& getNodeHash() const { return mNodeHash; }
|
||||
};
|
||||
@@ -257,6 +260,7 @@ class SHAMap
|
||||
public:
|
||||
typedef boost::shared_ptr<SHAMap> pointer;
|
||||
typedef const boost::shared_ptr<SHAMap>& ref;
|
||||
|
||||
typedef std::map<uint256, std::pair<SHAMapItem::pointer, SHAMapItem::pointer> > SHAMapDiff;
|
||||
|
||||
private:
|
||||
@@ -297,6 +301,8 @@ public:
|
||||
SHAMap(uint32 seq = 0);
|
||||
SHAMap(const uint256& hash);
|
||||
|
||||
~SHAMap() { mState = smsInvalid; }
|
||||
|
||||
// Returns a new map that's a snapshot of this one. Force CoW
|
||||
SHAMap::pointer snapShot(bool isMutable);
|
||||
|
||||
@@ -342,13 +348,13 @@ public:
|
||||
SHAMapSyncFilter* filter);
|
||||
|
||||
// status functions
|
||||
void setImmutable(void) { assert(mState != Invalid); mState = Immutable; }
|
||||
void clearImmutable(void) { mState = Modifying; }
|
||||
bool isSynching(void) const { return (mState == Floating) || (mState == Synching); }
|
||||
void setSynching(void) { mState = Synching; }
|
||||
void setFloating(void) { mState = Floating; }
|
||||
void clearSynching(void) { mState = Modifying; }
|
||||
bool isValid(void) { return mState != Invalid; }
|
||||
void setImmutable(void) { assert(mState != smsInvalid); mState = smsImmutable; }
|
||||
void clearImmutable(void) { mState = smsModifying; }
|
||||
bool isSynching(void) const { return (mState == smsFloating) || (mState == smsSynching); }
|
||||
void setSynching(void) { mState = smsSynching; }
|
||||
void setFloating(void) { mState = smsFloating; }
|
||||
void clearSynching(void) { mState = smsModifying; }
|
||||
bool isValid(void) { return mState != smsInvalid; }
|
||||
|
||||
// caution: otherMap must be accessed only by this function
|
||||
// return value: true=successfully completed, false=too different
|
||||
|
||||
Reference in New Issue
Block a user