Bugfixes.

This commit is contained in:
JoelKatz
2012-05-15 17:32:18 -07:00
parent 00b68c6bfa
commit 64616ec945
2 changed files with 13 additions and 12 deletions

View File

@@ -21,14 +21,14 @@ enum LedgerStateParms
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>

View File

@@ -191,12 +191,13 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran
// WRITEME: Special case code for changing transaction key
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