mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Cosmetic changes.
This commit is contained in:
@@ -430,16 +430,13 @@ bool SHAMap::addGiveItem(SHAMapItem::pointer item, bool isTransaction)
|
|||||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||||
|
|
||||||
std::stack<SHAMapTreeNode::pointer> stack=getStack(tag, true);
|
std::stack<SHAMapTreeNode::pointer> stack=getStack(tag, true);
|
||||||
if(stack.empty()) throw SHAMapException(MissingNode);
|
if (stack.empty()) throw SHAMapException(MissingNode);
|
||||||
|
|
||||||
SHAMapTreeNode::pointer node=stack.top();
|
SHAMapTreeNode::pointer node=stack.top();
|
||||||
stack.pop();
|
stack.pop();
|
||||||
|
|
||||||
if( node->isLeaf() && (node->peekItem()->getTag()==tag) )
|
if (node->isLeaf() && (node->peekItem()->getTag() == tag))
|
||||||
{
|
throw std::runtime_error("addGiveItem ends on leaf with same tag");
|
||||||
std::cerr << "addGiveItem ends on leaf with same tag" << std::endl;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint256 prevHash;
|
uint256 prevHash;
|
||||||
returnNode(node, true);
|
returnNode(node, true);
|
||||||
@@ -449,9 +446,9 @@ bool SHAMap::addGiveItem(SHAMapItem::pointer item, bool isTransaction)
|
|||||||
#ifdef ST_DEBUG
|
#ifdef ST_DEBUG
|
||||||
std::cerr << "aGI inner " << node->getString() << std::endl;
|
std::cerr << "aGI inner " << node->getString() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
int branch=node->selectBranch(tag);
|
int branch = node->selectBranch(tag);
|
||||||
assert(node->isEmptyBranch(branch));
|
assert(node->isEmptyBranch(branch));
|
||||||
SHAMapTreeNode::pointer newNode=
|
SHAMapTreeNode::pointer newNode =
|
||||||
boost::make_shared<SHAMapTreeNode>(node->getChildNodeID(branch), item, type, mSeq);
|
boost::make_shared<SHAMapTreeNode>(node->getChildNodeID(branch), item, type, mSeq);
|
||||||
if(!mTNByID.insert(std::make_pair(SHAMapNode(*newNode), newNode)).second)
|
if(!mTNByID.insert(std::make_pair(SHAMapNode(*newNode), newNode)).second)
|
||||||
{
|
{
|
||||||
@@ -467,14 +464,14 @@ bool SHAMap::addGiveItem(SHAMapItem::pointer item, bool isTransaction)
|
|||||||
#ifdef ST_DEBUG
|
#ifdef ST_DEBUG
|
||||||
std::cerr << "aGI leaf " << node->getString() << std::endl;
|
std::cerr << "aGI leaf " << node->getString() << std::endl;
|
||||||
#endif
|
#endif
|
||||||
SHAMapItem::pointer otherItem=node->peekItem();
|
SHAMapItem::pointer otherItem = node->peekItem();
|
||||||
assert(otherItem && (tag!=otherItem->getTag()) );
|
assert(otherItem && (tag != otherItem->getTag()) );
|
||||||
|
|
||||||
node->makeInner();
|
node->makeInner();
|
||||||
|
|
||||||
int b1, b2;
|
int b1, b2;
|
||||||
|
|
||||||
while( (b1=node->selectBranch(tag)) == (b2=node->selectBranch(otherItem->getTag())) )
|
while ((b1 = node->selectBranch(tag)) == (b2 = node->selectBranch(otherItem->getTag())))
|
||||||
{ // we need a new inner node, since both go on same branch at this level
|
{ // we need a new inner node, since both go on same branch at this level
|
||||||
#ifdef ST_DEBUG
|
#ifdef ST_DEBUG
|
||||||
std::cerr << "need new inner node at " << node->getDepth() << std::endl;
|
std::cerr << "need new inner node at " << node->getDepth() << std::endl;
|
||||||
@@ -484,26 +481,26 @@ bool SHAMap::addGiveItem(SHAMapItem::pointer item, bool isTransaction)
|
|||||||
if(!mTNByID.insert(std::make_pair(SHAMapNode(*newNode), newNode)).second)
|
if(!mTNByID.insert(std::make_pair(SHAMapNode(*newNode), newNode)).second)
|
||||||
assert(false);
|
assert(false);
|
||||||
stack.push(node);
|
stack.push(node);
|
||||||
node=newNode;
|
node = newNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we can add the two leaf nodes here
|
// we can add the two leaf nodes here
|
||||||
assert(node->isInner());
|
assert(node->isInner());
|
||||||
SHAMapTreeNode::pointer newNode=
|
SHAMapTreeNode::pointer newNode =
|
||||||
boost::make_shared<SHAMapTreeNode>(node->getChildNodeID(b1), item, type, mSeq);
|
boost::make_shared<SHAMapTreeNode>(node->getChildNodeID(b1), item, type, mSeq);
|
||||||
assert(newNode->isValid() && newNode->isLeaf());
|
assert(newNode->isValid() && newNode->isLeaf());
|
||||||
if(!mTNByID.insert(std::make_pair(SHAMapNode(*newNode), newNode)).second)
|
if (!mTNByID.insert(std::make_pair(SHAMapNode(*newNode), newNode)).second)
|
||||||
assert(false);
|
assert(false);
|
||||||
node->setChildHash(b1, newNode->getNodeHash()); // OPTIMIZEME hash op not needed
|
node->setChildHash(b1, newNode->getNodeHash()); // OPTIMIZEME hash op not needed
|
||||||
|
|
||||||
newNode=boost::make_shared<SHAMapTreeNode>(node->getChildNodeID(b2), otherItem, type, mSeq);
|
newNode = boost::make_shared<SHAMapTreeNode>(node->getChildNodeID(b2), otherItem, type, mSeq);
|
||||||
assert(newNode->isValid() && newNode->isLeaf());
|
assert(newNode->isValid() && newNode->isLeaf());
|
||||||
if(!mTNByID.insert(std::make_pair(SHAMapNode(*newNode), newNode)).second)
|
if(!mTNByID.insert(std::make_pair(SHAMapNode(*newNode), newNode)).second)
|
||||||
assert(false);
|
assert(false);
|
||||||
node->setChildHash(b2, newNode->getNodeHash());
|
node->setChildHash(b2, newNode->getNodeHash());
|
||||||
}
|
}
|
||||||
|
|
||||||
prevHash=node->getNodeHash();
|
prevHash = node->getNodeHash();
|
||||||
assert(prevHash.isNonZero());
|
assert(prevHash.isNonZero());
|
||||||
dirtyUp(stack, tag, prevHash);
|
dirtyUp(stack, tag, prevHash);
|
||||||
return true;
|
return true;
|
||||||
@@ -534,7 +531,7 @@ bool SHAMap::updateGiveItem(SHAMapItem::pointer item, bool isTransaction)
|
|||||||
|
|
||||||
returnNode(node, true);
|
returnNode(node, true);
|
||||||
if (!node->setItem(item, isTransaction ? SHAMapTreeNode::tnTRANSACTION : SHAMapTreeNode::tnACCOUNT_STATE))
|
if (!node->setItem(item, isTransaction ? SHAMapTreeNode::tnTRANSACTION : SHAMapTreeNode::tnACCOUNT_STATE))
|
||||||
return true;
|
return false;
|
||||||
|
|
||||||
dirtyUp(stack, tag, node->getNodeHash());
|
dirtyUp(stack, tag, node->getNodeHash());
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user