mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
14
src/Ledger.h
14
src/Ledger.h
@@ -18,17 +18,17 @@
|
||||
|
||||
enum LedgerStateParms
|
||||
{
|
||||
lepNONE = 0, // no special flags
|
||||
lepNONE = 0, // no special flags
|
||||
|
||||
// input flags
|
||||
lepCREATE, // Create if not present
|
||||
lepCREATE = 1, // Create if not present
|
||||
|
||||
// output flags
|
||||
lepOKAY, // success
|
||||
lepMISSING, // No node in that slot
|
||||
lepWRONGTYPE, // Node of different type there
|
||||
lepCREATED, // Node was created
|
||||
lepERROR, // error
|
||||
lepOKAY = 2, // success
|
||||
lepMISSING = 4, // No node in that slot
|
||||
lepWRONGTYPE = 8, // Node of different type there
|
||||
lepCREATED = 16, // Node was created
|
||||
lepERROR = 32, // error
|
||||
};
|
||||
|
||||
class Ledger : public boost::enable_shared_from_this<Ledger>
|
||||
|
||||
@@ -111,7 +111,7 @@ SHAMapTreeNode::pointer SHAMap::getNode(const SHAMapNode& id, const uint256& has
|
||||
SHAMapTreeNode::pointer node = checkCacheNode(id);
|
||||
if (node)
|
||||
{
|
||||
if (node->getNodeHash()!=hash)
|
||||
if (node->getNodeHash() != hash)
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cerr << "Attempt to get node, hash not in tree" << std::endl;
|
||||
@@ -127,7 +127,7 @@ SHAMapTreeNode::pointer SHAMap::getNode(const SHAMapNode& id, const uint256& has
|
||||
}
|
||||
|
||||
std::vector<unsigned char> nodeData;
|
||||
if(!fetchNode(hash, nodeData)) return SHAMapTreeNode::pointer();
|
||||
if (!fetchNode(hash, nodeData)) return SHAMapTreeNode::pointer();
|
||||
|
||||
node = boost::make_shared<SHAMapTreeNode>(id, nodeData, mSeq);
|
||||
if (node->getNodeHash() != hash) throw SHAMapException(InvalidNode);
|
||||
@@ -140,7 +140,7 @@ SHAMapTreeNode::pointer SHAMap::getNode(const SHAMapNode& id, const uint256& has
|
||||
void SHAMap::returnNode(SHAMapTreeNode::pointer& node, bool modify)
|
||||
{ // make sure the node is suitable for the intended operation (copy on write)
|
||||
assert(node->isValid());
|
||||
if (node && modify && (node->getSeq()!=mSeq))
|
||||
if (node && modify && (node->getSeq() != mSeq))
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cerr << "returnNode COW" << std::endl;
|
||||
@@ -344,10 +344,10 @@ SHAMapItem::pointer SHAMap::peekItem(const uint256& id)
|
||||
bool SHAMap::hasItem(const uint256& id)
|
||||
{ // does the tree have an item with this ID
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
SHAMapTreeNode::pointer leaf=walkTo(id, false);
|
||||
if(!leaf) return false;
|
||||
SHAMapItem::pointer item=leaf->peekItem();
|
||||
if(!item || item->getTag()!=id) return false;
|
||||
SHAMapTreeNode::pointer leaf = walkTo(id, false);
|
||||
if (!leaf) return false;
|
||||
SHAMapItem::pointer item = leaf->peekItem();
|
||||
if (!item || item->getTag() != id) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -516,17 +516,17 @@ bool SHAMap::addItem(const SHAMapItem& i, bool isTransaction)
|
||||
|
||||
bool SHAMap::updateGiveItem(SHAMapItem::pointer item, bool isTransaction)
|
||||
{ // can't change the tag but can change the hash
|
||||
uint256 tag=item->getTag();
|
||||
uint256 tag = item->getTag();
|
||||
|
||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||
|
||||
std::stack<SHAMapTreeNode::pointer> stack = getStack(tag, true);
|
||||
if (stack.empty()) throw SHAMapException(MissingNode);
|
||||
|
||||
SHAMapTreeNode::pointer node=stack.top();
|
||||
SHAMapTreeNode::pointer node = stack.top();
|
||||
stack.pop();
|
||||
|
||||
if (!node->isLeaf() || (node->peekItem()->getTag() != tag) )
|
||||
if (!node->isLeaf() || (node->peekItem()->getTag() != tag))
|
||||
{
|
||||
assert(false);
|
||||
return false;
|
||||
|
||||
@@ -278,7 +278,7 @@ bool SHAMapTreeNode::updateHash()
|
||||
{
|
||||
Serializer s;
|
||||
mItem->addRaw(s);
|
||||
s.add160(mItem->getTag().to160());
|
||||
s.add256(mItem->getTag());
|
||||
nh = s.getSHA512Half();
|
||||
}
|
||||
else if (mType == tnTRANSACTION)
|
||||
@@ -299,7 +299,7 @@ bool SHAMapTreeNode::setItem(SHAMapItem::pointer& i, TNType type)
|
||||
mItem = i;
|
||||
assert(isLeaf());
|
||||
updateHash();
|
||||
return getNodeHash() == hash;
|
||||
return getNodeHash() != hash;
|
||||
}
|
||||
|
||||
SHAMapItem::pointer SHAMapTreeNode::getItem() const
|
||||
|
||||
@@ -117,7 +117,7 @@ STObject::STObject(SOElement* elem, SerializerIterator& sit, const char *name) :
|
||||
if ((flags&elem->e_flags) == 0)
|
||||
{
|
||||
done = true;
|
||||
giveObject(makeDefaultObject(elem->e_id, elem->e_name));
|
||||
giveObject(makeDefaultObject(STI_NOTPRESENT, elem->e_name));
|
||||
}
|
||||
}
|
||||
else if (elem->e_type == SOE_IFNFLAG)
|
||||
@@ -126,7 +126,7 @@ STObject::STObject(SOElement* elem, SerializerIterator& sit, const char *name) :
|
||||
if ((flags&elem->e_flags) != 0)
|
||||
{
|
||||
done = true;
|
||||
giveObject(makeDefaultObject(STI_NOTPRESENT, elem->e_name));
|
||||
giveObject(makeDefaultObject(elem->e_id, elem->e_name));
|
||||
}
|
||||
}
|
||||
else if (elem->e_type == SOE_FLAGS)
|
||||
|
||||
@@ -189,14 +189,15 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran
|
||||
if (result == terSUCCESS)
|
||||
{ // Write back the account states and add the transaction to the ledger
|
||||
// WRITEME: Special case code for changing transaction key
|
||||
for (std::vector<AffectedAccount>::iterator it=accounts.begin(), end=accounts.end();
|
||||
for (std::vector<AffectedAccount>::iterator it = accounts.begin(), end = accounts.end();
|
||||
it != end; ++it)
|
||||
{ if (it->first == taaCREATE)
|
||||
{
|
||||
if (it->first == taaCREATE)
|
||||
{
|
||||
if (mLedger->writeBack(lepCREATE, it->second) & lepERROR)
|
||||
assert(false);
|
||||
}
|
||||
else if (it->first==taaMODIFY)
|
||||
else if (it->first == taaMODIFY)
|
||||
{
|
||||
if (mLedger->writeBack(lepNONE, it->second) & lepERROR)
|
||||
assert(false);
|
||||
@@ -235,7 +236,7 @@ TransactionEngineResult TransactionEngine::doClaim(const SerializedTransaction&
|
||||
}
|
||||
|
||||
LedgerStateParms qry = lepNONE;
|
||||
SerializedLedgerEntry::pointer dest = mLedger->getAccountRoot(qry, sourceAccountID);
|
||||
SerializedLedgerEntry::pointer dest = accounts[0].second;
|
||||
|
||||
if (!dest)
|
||||
{
|
||||
@@ -265,8 +266,6 @@ TransactionEngineResult TransactionEngine::doClaim(const SerializedTransaction&
|
||||
// Set the public key needed to use the account.
|
||||
dest->setIFieldH160(sfAuthorizedKey, hGeneratorID);
|
||||
|
||||
accounts.push_back(std::make_pair(taaMODIFY, dest));
|
||||
|
||||
// Construct a generator map entry.
|
||||
gen = boost::make_shared<SerializedLedgerEntry>(ltGENERATOR_MAP);
|
||||
|
||||
@@ -289,6 +288,8 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
|
||||
// Does the destination account exist?
|
||||
if (!destAccount) return tenINVALID;
|
||||
LedgerStateParms qry = lepNONE;
|
||||
|
||||
// FIXME: If this transfer is to the same account, bad things will happen
|
||||
SerializedLedgerEntry::pointer dest = mLedger->getAccountRoot(qry, destAccount);
|
||||
if (!dest)
|
||||
{ // can this transaction create an account
|
||||
|
||||
Reference in New Issue
Block a user