Tidy up LedgerConsensus

This commit is contained in:
Vinnie Falco
2013-06-12 14:05:44 -07:00
parent c31e2396f2
commit 0787a74c87
5 changed files with 38 additions and 44 deletions

View File

@@ -24,21 +24,6 @@
//------------------------------------------------------------------------------
#if 0
#include <boost/foreach.hpp>
#include <boost/bind.hpp>
#include <boost/thread.hpp>
#include <string>
#include <boost/test/unit_test.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/format.hpp>
#include <openssl/rand.h>
#include <string>
#include <boost/test/unit_test.hpp>
#endif
//------------------------------------------------------------------------------
#include <algorithm>
@@ -237,7 +222,7 @@
#include "src/cpp/ripple/HttpsClient.h"
#include "src/cpp/ripple/ripple_TransactionAcquire.h"
#include "src/cpp/ripple/ripple_DisputedTx.h"
#include "src/cpp/ripple/LedgerConsensus.h"
#include "src/cpp/ripple/ripple_LedgerConsensus.h"
#include "src/cpp/ripple/LedgerTiming.h"
#include "src/cpp/ripple/Offer.h"
#include "src/cpp/ripple/OfferCancelTransactor.h"
@@ -301,7 +286,6 @@ static const uint64 tenTo17m1 = tenTo17 - 1;
#include "src/cpp/ripple/HttpsClient.cpp"
#include "src/cpp/ripple/Interpreter.cpp" // no log
#include "src/cpp/ripple/Ledger.cpp"
#include "src/cpp/ripple/LedgerConsensus.cpp"
#include "src/cpp/ripple/LedgerEntrySet.cpp"
#include "src/cpp/ripple/LedgerMaster.cpp"
#include "src/cpp/ripple/LedgerProposal.cpp" // no log
@@ -400,6 +384,7 @@ static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength)
#include "src/cpp/ripple/ripple_JobQueue.cpp"
#include "src/cpp/ripple/ripple_LedgerAcquire.cpp"
#include "src/cpp/ripple/ripple_LedgerAcquireMaster.cpp"
#include "src/cpp/ripple/ripple_LedgerConsensus.cpp"
#include "src/cpp/ripple/ripple_LedgerHistory.cpp"
#include "src/cpp/ripple/ripple_LoadEvent.cpp"
#include "src/cpp/ripple/ripple_LoadMonitor.cpp"

View File

@@ -873,7 +873,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\cpp\ripple\LedgerConsensus.cpp">
<ClCompile Include="src\cpp\ripple\ripple_LedgerConsensus.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -1763,7 +1763,7 @@
<ClInclude Include="src\cpp\ripple\Interpreter.h" />
<ClInclude Include="src\cpp\ripple\Ledger.h" />
<ClInclude Include="src\cpp\ripple\ripple_LedgerAcquire.h" />
<ClInclude Include="src\cpp\ripple\LedgerConsensus.h" />
<ClInclude Include="src\cpp\ripple\ripple_LedgerConsensus.h" />
<ClInclude Include="src\cpp\ripple\LedgerEntrySet.h" />
<ClInclude Include="src\cpp\ripple\LedgerFormats.h" />
<ClInclude Include="src\cpp\ripple\ripple_LedgerHistory.h" />

View File

@@ -639,9 +639,6 @@
<ClCompile Include="src\cpp\ripple\Ledger.cpp">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\LedgerConsensus.cpp">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\LedgerEntrySet.cpp">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClCompile>
@@ -879,6 +876,9 @@
<ClCompile Include="src\cpp\ripple\ripple_DisputedTx.cpp">
<Filter>1. Modules\ripple_main\refactored\consensus</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\ripple_LedgerConsensus.cpp">
<Filter>1. Modules\ripple_main\refactored\consensus</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="database\sqlite3ext.h">
@@ -1406,9 +1406,6 @@
<ClInclude Include="src\cpp\ripple\Ledger.h">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\LedgerConsensus.h">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\LedgerEntrySet.h">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClInclude>
@@ -1637,6 +1634,9 @@
<ClInclude Include="src\cpp\ripple\ripple_DisputedTx.h">
<Filter>1. Modules\ripple_main\refactored\consensus</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\ripple_LedgerConsensus.h">
<Filter>1. Modules\ripple_main\refactored\consensus</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="SConstruct" />

View File

@@ -1,36 +1,36 @@
#ifndef RIPPLE_LEDGERCONSENSUS_H
#define RIPPLE_LEDGERCONSENSUS_H
#include "Transaction.h"
#include "LedgerProposal.h"
#include "TransactionEngine.h"
DEFINE_INSTANCE(LedgerConsensus);
enum LCState
{
lcsPRE_CLOSE, // We haven't closed our ledger yet, but others might have
lcsESTABLISH, // Establishing consensus
lcsFINISHED, // We have closed on a transaction set
lcsACCEPTED, // We have accepted/validated a new last closed ledger
};
/** Manager for achieving consensus on the next ledger.
This object is created when the consensus process starts, and
is destroyed when the process is complete.
*/
class LedgerConsensus : public boost::enable_shared_from_this<LedgerConsensus>, IS_INSTANCE(LedgerConsensus)
{
public:
LedgerConsensus(uint256 const& prevLCLHash, Ledger::ref previousLedger, uint32 closeTime);
LedgerConsensus (LedgerHash const& prevLCLHash, Ledger::ref previousLedger, uint32 closeTime);
int startup();
Json::Value getJson(bool full);
Ledger::ref peekPreviousLedger() { return mPreviousLedger; }
uint256 getLCL() { return mPrevLedgerHash; }
SHAMap::pointer getTransactionTree(uint256 const& hash, bool doAcquire);
TransactionAcquire::pointer getAcquiring(uint256 const& hash);
void mapComplete(uint256 const& hash, SHAMap::ref map, bool acquired);
bool stillNeedTXSet(uint256 const& hash);
void checkLCL();
void handleLCL(uint256 const& lclHash);
void timerEntry();
@@ -92,6 +92,15 @@ private:
void endConsensus();
private:
// VFALCO TODO Rename these to look pretty
enum LCState
{
lcsPRE_CLOSE, // We haven't closed our ledger yet, but others might have
lcsESTABLISH, // Establishing consensus
lcsFINISHED, // We have closed on a transaction set
lcsACCEPTED, // We have accepted/validated a new last closed ledger
};
LCState mState;
uint32 mCloseTime; // The wall time this ledger closed
uint256 mPrevLedgerHash, mNewLedgerHash;