Remove broken logic from previous commit. I'll find a better way.

This commit is contained in:
JoelKatz
2013-04-21 14:26:04 -07:00
parent d17afbf9da
commit a9cab289dd
3 changed files with 1 additions and 137 deletions

View File

@@ -329,27 +329,6 @@ public:
static SMAddNode invalid() { return SMAddNode(true, false); }
};
class SHAMapIterator
{
friend class SHAMap;
typedef std::pair<SHAMapTreeNode*, int> stack_t;
SHAMap& mMap;
std::stack<stack_t> mStack;
bool mInner, mLeaf, mLock;
public:
SHAMapIterator(SHAMap& map, bool returnInner, bool returnLeaf);
~SHAMapIterator();
bool lock();
bool unlock();
void reset();
SHAMapTreeNode* getNext();
};
extern bool SMANCombine(SMAddNode& existing, const SMAddNode& additional);
class SHAMap : public IS_INSTANCE(SHAMap)

View File

@@ -571,95 +571,4 @@ std::ostream& operator<<(std::ostream& out, const SHAMapMissingNode& mn)
return out;
}
SHAMapIterator::SHAMapIterator(SHAMap& map, bool returnInner, bool returnLeaf) :
mMap(map), mInner(returnInner), mLeaf(returnLeaf), mLock(false)
{
mStack.push(stack_t(mMap.root.get(), 0));
}
SHAMapIterator::~SHAMapIterator()
{
if (mLock)
{
while (!mStack.empty())
mStack.pop();
mMap.mLock.unlock();
}
}
bool SHAMapIterator::lock()
{
if (mLock)
return false;
mMap.mLock.lock();
mLock = true;
return true;
}
bool SHAMapIterator::unlock()
{
if (!mLock)
return false;
mMap.mLock.unlock();
mLock = false;
return true;
}
void SHAMapIterator::reset()
{
while (!mStack.empty())
mStack.pop();
mStack.push(stack_t(mMap.root.get(), 0));
}
SHAMapTreeNode* SHAMapIterator::getNext()
{
if (mStack.empty())
return NULL;
stack_t& top = mStack.top();
if (top.first->isLeaf())
{ // special case, map has only one leaf
SHAMapTreeNode* ret = mLeaf ? top.first : NULL;
mStack.pop();
return ret;
}
while (1)
{
while (top.second < 16)
{ // continue where we left off
if (top.first->isEmptyBranch(top.second))
++top.second;
else
{
SHAMapTreeNode* next = mMap.getNodePointer(
top.first->getChildNodeID(top.second), top.first->getChildHash(top.second));
++top.second;
if (next->isLeaf())
{
if (mLeaf)
return next;
}
else
{
mStack.push(stack_t(next, 0));
top = mStack.top();
}
}
}
if (top.second == 16)
{ // we ran off the end of an inner node
SHAMapTreeNode* ret = top.first;
mStack.pop();
if (mInner)
return ret;
if (mStack.empty()) // ran off the end of the root
return NULL;
top = mStack.top();
}
}
}
// vim:ts=4

View File

@@ -176,31 +176,7 @@ std::list< std::pair<uint256, std::vector<unsigned char> > >
getSyncInfo(SHAMap::pointer have, SHAMap::pointer want, int max)
{
std::list< std::pair< uint256, std::vector<unsigned char> > > ret;
SHAMapIterator haveI(*have, true, false);
SHAMapIterator wantI(*want, true, false);
SHAMapTreeNode *haveN = haveI.getNext();
SHAMapTreeNode *wantN = wantI.getNext();
while (wantN != NULL)
{
if (haveN && (haveN->getNodeHash() == wantN->getNodeHash()))
{ // they match, advance both
haveN = haveI.getNext();
wantN = wantI.getNext();
}
else if (haveN && (haveN->getNodeHash() < wantN->getNodeHash()))
{ // need to advance have pointer
haveN = haveI.getNext();
}
else
{ // unmatched inner node
Serializer s;
wantN->addRaw(s, snfPREFIX);
ret.push_back(std::make_pair(wantN->getNodeHash(), s.peekData()));
if (--max <= 0)
break;
wantN = wantI.getNext();
}
}
// WRITEME
return ret;
}