Skip to content

Commit

Permalink
Allow ledgers to be loaded from the command line.
Browse files Browse the repository at this point in the history
Conflicts:

	src/ripple_data/protocol/BuildInfo.cpp
  • Loading branch information
pull-robot authored and vinniefalco committed May 19, 2014
1 parent 568fae9 commit 4b3e629
Show file tree
Hide file tree
Showing 11 changed files with 236 additions and 72 deletions.
12 changes: 8 additions & 4 deletions src/ripple_app/data/DatabaseCon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ DatabaseCon::DatabaseCon (const std::string& strName, const char* initStrings[],
// responsibility to pass in the path. Add a member function to Application
// or Config to compute this path.
//
boost::filesystem::path pPath = (getConfig ().RUN_STANDALONE &&
((getConfig ().START_UP != Config::LOAD) && (getConfig ().START_UP != Config::REPLAY)))
? "" // Use temporary files.
: (getConfig ().DATA_DIR / strName); // Use regular db files.
auto const startUp = getConfig ().START_UP;
auto const useTempFiles // Use temporary files or regular DB files?
= getConfig ().RUN_STANDALONE &&
startUp != Config::LOAD &&
startUp != Config::LOAD_FILE &&
startUp != Config::REPLAY;
boost::filesystem::path pPath = useTempFiles
? "" : (getConfig ().DATA_DIR / strName);

mDatabase = new SqliteDatabase (pPath.string ().c_str ());
mDatabase->connect ();
Expand Down
28 changes: 28 additions & 0 deletions src/ripple_app/ledger/Ledger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,28 @@ Ledger::Ledger (const std::string& rawLedger, bool hasPrefix)
initializeFees ();
}

/** Used for ledgers loaded from JSON files */
Ledger::Ledger (std::uint32_t ledgerSeq, std::uint32_t closeTime)
: mTotCoins (0),
mLedgerSeq (ledgerSeq),
mCloseTime (closeTime),
mParentCloseTime (0),
mCloseResolution (LEDGER_TIME_ACCURACY),
mCloseFlags (0),
mClosed (false),
mValidated (false),
mValidHash (false),
mAccepted (false),
mImmutable (false),
mTransactionMap (boost::make_shared <SHAMap> (
smtTRANSACTION, std::ref (getApp().getFullBelowCache()))),
mAccountStateMap (boost::make_shared <SHAMap> (
smtSTATE, std::ref (getApp().getFullBelowCache())))
{
initializeFees ();
}


Ledger::~Ledger ()
{
if (mTransactionMap)
Expand Down Expand Up @@ -326,6 +348,12 @@ bool Ledger::hasAccount (const RippleAddress& accountID)
return mAccountStateMap->hasItem (Ledger::getAccountRootIndex (accountID));
}

bool Ledger::addSLE (SLE const& sle)
{
SHAMapItem item (sle.getIndex(), sle.getSerializer());
return mAccountStateMap->addItem(item, false, false);
}

AccountState::pointer Ledger::getAccountState (const RippleAddress& accountID)
{
#ifdef BEAST_DEBUG
Expand Down
9 changes: 9 additions & 0 deletions src/ripple_app/ledger/Ledger.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ class Ledger
int closeFlags, int closeResolution,
std::uint32_t ledgerSeq, bool & loaded); // used for database ledgers

Ledger (std::uint32_t ledgerSeq, std::uint32_t closeTime);

Ledger (Blob const & rawLedger, bool hasPrefix);

Ledger (const std::string & rawLedger, bool hasPrefix);
Expand Down Expand Up @@ -188,6 +190,10 @@ class Ledger
{
mTotCoins -= fee;
}
void setTotalCoins (std::uint64_t totCoins)
{
mTotCoins = totCoins;
}
std::uint32_t getCloseTimeNC () const
{
return mCloseTime;
Expand Down Expand Up @@ -238,6 +244,9 @@ class Ledger
mAccountStateMap->dropCache ();
}

// returns false on error
bool addSLE (SLE const& sle);

// ledger sync functions
void setAcquiring (void);
bool isAcquiring (void);
Expand Down
47 changes: 27 additions & 20 deletions src/ripple_app/ledger/LedgerTiming.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,58 +23,65 @@
namespace ripple {

// The number of seconds a ledger may remain idle before closing
# define LEDGER_IDLE_INTERVAL 15
const int LEDGER_IDLE_INTERVAL = 15;

// The number of seconds a validation remains current after its ledger's close time
// This is a safety to protect against very old validations and the time it takes to adjust
// the close time accuracy window
# define LEDGER_VAL_INTERVAL 300
const int LEDGER_VAL_INTERVAL = 300;

// The number of seconds before a close time that we consider a validation acceptable
// This protects against extreme clock errors
# define LEDGER_EARLY_INTERVAL 180
const int LEDGER_EARLY_INTERVAL = 180;

// The number of milliseconds we wait minimum to ensure participation
# define LEDGER_MIN_CONSENSUS 2000
const int LEDGER_MIN_CONSENSUS = 2000;

// The number of milliseconds we wait minimum to ensure others have computed the LCL
# define LEDGER_MIN_CLOSE 2000
const int LEDGER_MIN_CLOSE = 2000;

// Initial resolution of ledger close time
# define LEDGER_TIME_ACCURACY 30
const int LEDGER_TIME_ACCURACY = 30;

// How often to increase resolution
# define LEDGER_RES_INCREASE 8
const int LEDGER_RES_INCREASE = 8;

// How often to decrease resolution
# define LEDGER_RES_DECREASE 1
const int LEDGER_RES_DECREASE = 1;

// How often we check state or change positions (in milliseconds)
# define LEDGER_GRANULARITY 1000
const int LEDGER_GRANULARITY = 1000;

// The percentage of active trusted validators that must be able to
// keep up with the network or we consider the network overloaded
# define LEDGER_NET_RATIO 70
const int LEDGER_NET_RATIO = 70;

// How long we consider a proposal fresh
# define PROPOSE_FRESHNESS 20
const int PROPOSE_FRESHNESS = 20;

// How often we force generating a new proposal to keep ours fresh
# define PROPOSE_INTERVAL 12
const int PROPOSE_INTERVAL = 12;

// Avalanche tuning
# define AV_INIT_CONSENSUS_PCT 50 // percentage of nodes on our UNL that must vote yes
// percentage of nodes on our UNL that must vote yes
const int AV_INIT_CONSENSUS_PCT = 50;

# define AV_MID_CONSENSUS_TIME 50 // percentage of previous close time before we advance
# define AV_MID_CONSENSUS_PCT 65 // percentage of nodes that most vote yes after advancing
// percentage of previous close time before we advance
const int AV_MID_CONSENSUS_TIME = 50;

# define AV_LATE_CONSENSUS_TIME 85 // percentage of previous close time before we advance
# define AV_LATE_CONSENSUS_PCT 70 // percentage of nodes that most vote yes after advancing
// percentage of nodes that most vote yes after advancing
const int AV_MID_CONSENSUS_PCT = 65;

# define AV_STUCK_CONSENSUS_TIME 200
# define AV_STUCK_CONSENSUS_PCT 95
// percentage of previous close time before we advance
const int AV_LATE_CONSENSUS_TIME = 85;

# define AV_CT_CONSENSUS_PCT 75
// percentage of nodes that most vote yes after advancing
const int AV_LATE_CONSENSUS_PCT = 70;

const int AV_STUCK_CONSENSUS_TIME = 200;
const int AV_STUCK_CONSENSUS_PCT = 95;

const int AV_CT_CONSENSUS_PCT = 75;

class ContinuousLedgerTiming
{
Expand Down
Loading

0 comments on commit 4b3e629

Please sign in to comment.