diff --git a/TransactionBundle.cpp b/TransactionBundle.cpp deleted file mode 100644 index 3097bef16d..0000000000 --- a/TransactionBundle.cpp +++ /dev/null @@ -1,133 +0,0 @@ -#include "TransactionBundle.h" -#include - -using namespace std; - -/* -// do we need to make sure this preserves the order you received the transactions? Otherwise when we run through it we can see invalid transactions that get funded later. -// No we can just allow this. We just check when a transaction comes in and at ledger close. -// There needs to be a predictable order or the hashes will all be different. -// -bool gTransactionSorter(const newcoin::Transaction& lhs, const newcoin::Transaction& rhs) -{ - if(lhs.from() == rhs.from()) - { - return(lhs.seqnum() < rhs.seqnum() ); - }else return lhs.from() < rhs.from(); -} - - -TransactionBundle::TransactionBundle() -{ - -} - - -bool TransactionBundle::hasTransaction(TransactionPtr needle) -{ - BOOST_FOREACH(TransactionPtr trans,mTransactions) - { - if( Transaction::isEqual(needle,trans) ) return(true); - } - - BOOST_FOREACH(TransactionPtr trans,mDisacrdedTransactions) - { - if( Transaction::isEqual(needle,trans) ) return(true); - } - - return(false); -} - -void TransactionBundle::addTransactionsToPB(newcoin::FullLedger* ledger) -{ - BOOST_FOREACH(TransactionPtr trans,mTransactions) - { - TransactionPtr newTrans=ledger->add_transactions(); - newTrans->operator=(trans); - } -} - -void TransactionBundle::addDiscardedTransaction(TransactionPtr trans) -{ - mDisacrdedTransactions.push_back(trans); - //mDisacrdedTransactions.sort(gTransactionSorter); -} - -void TransactionBundle::addTransaction(const TransactionPtr trans) -{ - mTransactions.push_back(trans); - //mTransactions.sort(gTransactionSorter); -} - - -// determine if all the transactions until end time from this address are valid -// return the amount left in this account -uint64 TransactionBundle::checkValid(std::string address, - uint64 startAmount,int startTime,int endTime) -{ - // TODO: check that 2 transactions from the same address on the same second - // that cause the amount to be < 0 both should be discarded. - // TODO: do we need to do this: - // it will also check if we can bring back discarded transactions - // we can probably wait and do this at finalize - bool sortDiscard=false; - - for(list::iterator iter=mTransactions.begin(); iter != mTransactions.end(); ) - { - newcoin::Transaction& trans=(*iter); - if(trans.seconds()>endTime) break; - if(trans.seconds()>=startTime) - { - if(trans.dest()==address) - { - startAmount += getTotalTransAmount(trans); - }else - { // check all the inputs to see if they are from this address - int numInputs=trans.inputs_size(); - for(int n=0; n& moneyMap) -{ - BOOST_FOREACH(newcoin::Transaction& trans, mTransactions) - { - uint64 total=0; - int numInputs=trans.inputs_size(); - for(int n=0; n -#include "newcoin.pb.h" -#include "types.h" -#include "Transaction.h" - - -class TransactionBundle -{ - // we have to order this before we hash so the hash will be consistent - std::list mTransactions; - std::list mDisacrdedTransactions; - //std::list mAllTransactions; -public: - TransactionBundle(); - - void clear(){ mTransactions.clear(); } - - unsigned int size(){ return(mTransactions.size()); } - - void addTransactionsToPB(newcoin::FullLedger* ledger); - - bool hasTransaction(TransactionPtr trans); - - // returns the amount of money this address holds at the end time - // it will discard any transactions till endTime that bring amount held under 0 - uint64 checkValid(std::string address, uint64 startAmount, - int startTime,int endTime); - - void updateMap(std::map& moneyMap); - - // will check if all transactions after this are valid - //void checkTransactions(); - void addTransaction(TransactionPtr trans); - - // transaction is valid and signed except the guy didn't have the money - void addDiscardedTransaction(TransactionPtr trans); - - - //static uint64 getTotalTransAmount(TransactionPtr trans); -}; - -#endif \ No newline at end of file