mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-30 16:05:51 +00:00
.
This commit is contained in:
51
Ledger.h
51
Ledger.h
@@ -1,53 +1,80 @@
|
||||
#ifndef __LEDGER__
|
||||
#define __LEDGER__
|
||||
|
||||
#include "TransactionBundle.h"
|
||||
#include "Transaction.h"
|
||||
#include "types.h"
|
||||
#include "BitcoinUtil.h"
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <boost/enable_shared_from_this.hpp>
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
|
||||
|
||||
class Ledger : public boost::enable_shared_from_this<Ledger>
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<Ledger> pointer;
|
||||
typedef std::pair<int64,uint32> Account;
|
||||
private:
|
||||
bool mValidSig;
|
||||
bool mValidHash;
|
||||
bool mFaith; //TODO: if you will bother to validate this ledger or not. You have to accept the first ledger on Faith
|
||||
|
||||
uint64 mIndex;
|
||||
uint32 mIndex;
|
||||
std::string mHash;
|
||||
std::string mSignature;
|
||||
std::map<std::string,uint64> mMoneyMap;
|
||||
TransactionBundle mBundle;
|
||||
|
||||
|
||||
|
||||
|
||||
std::map<uint160, Account > mAccounts;
|
||||
std::list<TransactionPtr> mTransactions;
|
||||
std::list<TransactionPtr> mDiscardedTransactions;
|
||||
|
||||
//TransactionBundle mBundle;
|
||||
|
||||
// these can be NULL
|
||||
// we need to keep track in case there are changes in this ledger that effect either the parent or child.
|
||||
Ledger::pointer mParent;
|
||||
Ledger::pointer mChild;
|
||||
|
||||
|
||||
void calcMoneyMap();
|
||||
void sign();
|
||||
void hash();
|
||||
void addTransactionRecalculate(TransactionPtr trans);
|
||||
void correctAccount(uint160& address);
|
||||
public:
|
||||
typedef boost::shared_ptr<Ledger> pointer;
|
||||
Ledger(uint64 index);
|
||||
Ledger(uint32 index);
|
||||
void setTo(newcoin::FullLedger& ledger);
|
||||
|
||||
void save(std::string dir);
|
||||
bool load(std::string dir);
|
||||
|
||||
void recalculate(bool recursive=true);
|
||||
|
||||
void publish();
|
||||
void finalize();
|
||||
|
||||
|
||||
uint64 getAmount(std::string address);
|
||||
void recheck(Ledger::pointer parent,newcoin::Transaction& cause);
|
||||
bool addTransaction(newcoin::Transaction& trans);
|
||||
bool hasTransaction(TransactionPtr trans);
|
||||
int64 getAmountHeld(uint160& address);
|
||||
void parentAddedTransaction(TransactionPtr cause);
|
||||
bool addTransaction(TransactionPtr trans,bool checkDuplicate=true);
|
||||
void addValidation(newcoin::Validation& valid);
|
||||
void addIgnoredValidation(newcoin::Validation& valid);
|
||||
|
||||
uint64 getIndex(){ return(mIndex); }
|
||||
uint32 getIndex(){ return(mIndex); }
|
||||
std::string& getHash();
|
||||
std::string& getSignature();
|
||||
unsigned int getNumTransactions(){ return(mBundle.size()); }
|
||||
std::map<std::string,uint64>& getMoneyMap(){ return(mMoneyMap); }
|
||||
unsigned int getNumTransactions(){ return(mTransactions.size()); }
|
||||
std::map<uint160, std::pair<int64,uint32> >& getAccounts(){ return(mAccounts); }
|
||||
Account* getAccount(uint160& address);
|
||||
newcoin::FullLedger* createFullLedger();
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user