Track when a node was last accessed.

This commit is contained in:
JoelKatz
2012-12-14 09:56:28 -08:00
parent f5e70fdcf3
commit bc3f641373
3 changed files with 6 additions and 4 deletions

View File

@@ -144,6 +144,7 @@ SHAMapTreeNode::pointer SHAMap::checkCacheNode(const SHAMapNode& iNode)
boost::unordered_map<SHAMapNode, SHAMapTreeNode::pointer>::iterator it = mTNByID.find(iNode);
if (it == mTNByID.end())
return SHAMapTreeNode::pointer();
it->second->touch(mSeq);
return it->second;
}

View File

@@ -161,7 +161,7 @@ private:
uint256 mHash;
uint256 mHashes[16];
SHAMapItem::pointer mItem;
uint32 mSeq;
uint32 mSeq, mAccessSeq;
TNType mType;
bool mFullBelow;
@@ -183,7 +183,8 @@ public:
// node functions
uint32 getSeq() const { return mSeq; }
void setSeq(uint32 s) { mSeq = s; }
void setSeq(uint32 s) { mAccessSeq = mSeq = s; }
void touch(uint32 s) { mAccessSeq = s; }
const uint256& getNodeHash() const { return mHash; }
TNType getType() const { return mType; }

View File

@@ -173,8 +173,8 @@ void SHAMapNode::dump() const
Log(lsDEBUG) << getString();
}
SHAMapTreeNode::SHAMapTreeNode(uint32 seq, const SHAMapNode& nodeID) : SHAMapNode(nodeID), mHash(0), mSeq(seq),
mType(tnERROR), mFullBelow(false)
SHAMapTreeNode::SHAMapTreeNode(uint32 seq, const SHAMapNode& nodeID) : SHAMapNode(nodeID), mHash(0),
mSeq(seq), mAccessSeq(seq), mType(tnERROR), mFullBelow(false)
{
}