From 64616ec94577d3e65d8b232729695bfbff09c96f Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Tue, 15 May 2012 17:32:18 -0700 Subject: [PATCH] Bugfixes. --- src/Ledger.h | 14 +++++++------- src/TransactionEngine.cpp | 11 ++++++----- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/Ledger.h b/src/Ledger.h index 4d9b5fb614..4d330c9648 100644 --- a/src/Ledger.h +++ b/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 diff --git a/src/TransactionEngine.cpp b/src/TransactionEngine.cpp index aba6aa276b..3f8490e4b0 100644 --- a/src/TransactionEngine.cpp +++ b/src/TransactionEngine.cpp @@ -191,12 +191,13 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran // WRITEME: Special case code for changing transaction key for (std::vector::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(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