From 766e03bc62c716cdd8a1d0d9c8b501278469e451 Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Fri, 1 Jun 2012 20:34:25 -0700 Subject: [PATCH] Fee charge fixes. --- src/Ledger.cpp | 13 ++++++------- src/Ledger.h | 3 ++- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Ledger.cpp b/src/Ledger.cpp index 495974f34f..c428482ed4 100644 --- a/src/Ledger.cpp +++ b/src/Ledger.cpp @@ -44,13 +44,13 @@ Ledger::Ledger(const uint256 &parentHash, const uint256 &transHash, const uint25 updateHash(); } -Ledger::Ledger(Ledger::pointer prevLedger) : mParentHash(prevLedger->getHash()), mTotCoins(prevLedger->mTotCoins), +Ledger::Ledger(Ledger::pointer prevLedger) : mTotCoins(prevLedger->mTotCoins), mLedgerSeq(prevLedger->mLedgerSeq + 1), mLedgerInterval(prevLedger->mLedgerInterval), mClosed(false), mValidHash(false), mAccepted(false), mImmutable(false), mTransactionMap(new SHAMap()), mAccountStateMap(prevLedger->mAccountStateMap) { - prevLedger->setClosed(); prevLedger->updateHash(); + mParentHash = prevLedger->getHash(); mAccountStateMap->setSeq(mLedgerSeq); mCloseTime = prevLedger->getNextLedgerClose(); } @@ -158,22 +158,20 @@ RippleState::pointer Ledger::getRippleState(const uint256& uNode) } bool Ledger::addTransaction(Transaction::pointer trans) -{ // low-level - just add to table, debit fee +{ // low-level - just add to table assert(!mAccepted); assert(!!trans->getID()); Serializer s; trans->getSTransaction()->add(s); SHAMapItem::pointer item = boost::make_shared(trans->getID(), s.peekData()); if (!mTransactionMap->addGiveItem(item, true)) return false; - mTotCoins -= trans->getFee(); return true; } -bool Ledger::addTransaction(const uint256& txID, const Serializer& txn, STAmount saPaid) +bool Ledger::addTransaction(const uint256& txID, const Serializer& txn) { // low-level - just add to table SHAMapItem::pointer item = boost::make_shared(txID, txn.peekData()); if (!mTransactionMap->addGiveItem(item, true)) return false; - mTotCoins -= saPaid; return true; } @@ -339,6 +337,7 @@ Ledger::pointer Ledger::switchPreviousLedger(Ledger::pointer oldPrevious, Ledger return Ledger::pointer(); // new previous ledger contains invalid transactions // 4) Try to add those transactions to the new ledger. +#if 0 do { count = 0; @@ -354,7 +353,7 @@ Ledger::pointer Ledger::switchPreviousLedger(Ledger::pointer oldPrevious, Ledger else ++it; } } while (count != 0); - +#endif // WRITEME: Handle rejected transactions left in TxnDiff // 5) Try to add transactions from this ledger to the new ledger. diff --git a/src/Ledger.h b/src/Ledger.h index 477f4fb34b..ea7b297fd6 100644 --- a/src/Ledger.h +++ b/src/Ledger.h @@ -72,7 +72,7 @@ private: protected: bool addTransaction(Transaction::pointer); - bool addTransaction(const uint256& id, const Serializer& txn, STAmount saPaid); + bool addTransaction(const uint256& id, const Serializer& txn); static Ledger::pointer getSQL(const std::string& sqlStatement); @@ -105,6 +105,7 @@ public: const uint256& getTransHash() const { return mTransHash; } const uint256& getAccountHash() const { return mAccountHash; } uint64 getTotalCoins() const { return mTotCoins; } + void destroyCoins(uint64 fee) { mTotCoins -= fee; } uint64 getCloseTimeNC() const { return mCloseTime; } uint32 getLedgerSeq() const { return mLedgerSeq; } uint16 getInterval() const { return mLedgerInterval; }