Merge branch 'develop' of github.com:jedmccaleb/NewCoin into develop

This commit is contained in:
JoelKatz
2013-06-12 12:51:16 -07:00
49 changed files with 713 additions and 649 deletions

View File

@@ -17,6 +17,7 @@
<WarningLevel>Level3</WarningLevel>
<AdditionalIncludeDirectories>$(RepoDir);$(RepoDir)\src\cpp\leveldb;$(RepoDir)\src\cpp\leveldb\include;$(RepoDir)\src\cpp\protobuf\src;$(RepoDir)\src\cpp\protobuf\vsprojects;$(RepoDir)\build\proto;$(RepoDir)\Subtrees\beast;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalOptions>/bigobj %(AdditionalOptions)</AdditionalOptions>
<ExceptionHandling>Async</ExceptionHandling>
</ClCompile>
<Link>
<AdditionalDependencies>Shlwapi.lib;%(AdditionalDependencies)</AdditionalDependencies>

View File

@@ -6,100 +6,152 @@ inline uint32 max(uint32 x, uint32 y) { return (x > y) ? x : y; }
bool RangeSet::hasValue(uint32 v) const
{
return mRanges.find(v) != mRanges.end();
BOOST_FOREACH(const value_type& it, mRanges)
{
if (contains(it, v))
return true;
}
return false;
}
uint32 RangeSet::getFirst() const
{
const_iterator it = begin();
if (it == end())
const_iterator it = mRanges.begin();
if (it == mRanges.end())
return RangeSetAbsent;
return lower(it);
return it->first;
}
uint32 RangeSet::getNext(uint32 v) const
{
for (const_iterator it = begin(); it != end(); ++it)
BOOST_FOREACH(const value_type& it, mRanges)
{
if (upper(it) > v)
return max(v + 1, lower(it));
if (it.first > v)
return it.first;
if (contains(it, v + 1))
return v + 1;
}
return RangeSetAbsent;
}
uint32 RangeSet::getLast() const
{
const_reverse_iterator it = rbegin();
if (it == rend())
const_reverse_iterator it = mRanges.rbegin();
if (it == mRanges.rend())
return RangeSetAbsent;
return upper(it);
return it->second;
}
uint32 RangeSet::getPrev(uint32 v) const
{
for (const_reverse_iterator it = rbegin(); it != rend(); ++it)
BOOST_REVERSE_FOREACH(const value_type& it, mRanges)
{
if (lower(it) < v)
return min(v - 1, upper(it));
if (it.second < v)
return it.second;
if (contains(it, v + 1))
return v - 1;
}
return RangeSetAbsent;
}
uint32 RangeSet::prevMissing(uint32 v) const
{ // largest number not in the set that is less than the given number
WriteLog (lsTRACE, RangeSet) << "prevMissing(" << v << ") " << toString();
for (const_reverse_iterator it = rbegin(); it != rend(); ++it)
BOOST_FOREACH(const value_type& it, mRanges)
{
if ((upper(it) + 1) < v)
return upper(it) + 1;
if (lower(it) == 0)
return RangeSetAbsent;
if ((lower(it) - 1) < v)
return lower(it) - 1;
if (contains(it, v))
return it.first - 1;
if (it.first > v)
return v + 1;
}
if (v > 0)
return v - 1;
return RangeSetAbsent;
}
void RangeSet::setValue(uint32 v)
{
setRange(v, v);
if (!hasValue(v))
{
mRanges[v] = v;
simplify();
}
}
void RangeSet::setRange(uint32 minV, uint32 maxV)
{
mRanges.add(boost::icl::discrete_interval<uint32>(minV, maxV + 1));
while (hasValue(minV))
{
++minV;
if (minV >= maxV)
return;
}
mRanges[minV] = maxV;
simplify();
}
void RangeSet::clearValue(uint32 v)
{
clearRange(v, v);
}
void RangeSet::clearRange(uint32 minV, uint32 maxV)
{
mRanges.erase(boost::icl::discrete_interval<uint32>(minV, maxV + 1));
for (iterator it = mRanges.begin(); it != mRanges.end(); ++it)
{
if (contains(*it, v))
{
if (it->first == v)
{
if (it->second == v)
mRanges.erase(it);
else
{
mRanges[v + 1] = it->second;
it->second = v - 1;
}
}
else if (it->second == v)
--(it->second);
else
{
uint32 oldEnd = it->second;
it->second = v - 1;
mRanges[v + 1] = oldEnd;
}
return;
}
}
}
std::string RangeSet::toString() const
{
std::string ret;
for (const_iterator it = begin(); it != end(); ++it)
BOOST_FOREACH(value_type const& it, mRanges)
{
if (!ret.empty())
ret += ",";
if (lower(it) == upper(it))
ret += boost::lexical_cast<std::string>(lower(it));
if (it.first == it.second)
ret += boost::lexical_cast<std::string>((it.first));
else
ret += boost::lexical_cast<std::string>(lower(it)) + "-"
+ boost::lexical_cast<std::string>(upper(it));
ret += boost::lexical_cast<std::string>(it.first) + "-"
+ boost::lexical_cast<std::string>(it.second);
}
if (ret.empty())
return "empty";
return ret;
}
void RangeSet::simplify()
{
iterator it = mRanges.begin();
while (1)
{
iterator nit = it;
if (++nit == mRanges.end())
return;
if (it->second >= (nit->first - 1))
{ // ranges overlap
it->second = nit->second;
mRanges.erase(nit);
}
else
it = nit;
}
}
BOOST_AUTO_TEST_SUITE(RangeSet_suite)
BOOST_AUTO_TEST_CASE(RangeSet_test)

View File

@@ -4,15 +4,22 @@
class RangeSet
{
public:
typedef boost::icl::interval_set<uint32> iRangeSet;
typedef iRangeSet::iterator iterator;
typedef iRangeSet::const_iterator const_iterator;
typedef iRangeSet::reverse_iterator reverse_iterator;
typedef iRangeSet::const_reverse_iterator const_reverse_iterator;
static const uint32 RangeSetAbsent = static_cast<uint32>(-1);
protected:
iRangeSet mRanges;
std::map<uint32, uint32> mRanges; // First is lowest value in range, last is highest value in range
typedef std::map<uint32, uint32>::const_iterator const_iterator;
typedef std::map<uint32, uint32>::const_reverse_iterator const_reverse_iterator;
typedef std::map<uint32, uint32>::value_type value_type;
typedef std::map<uint32, uint32>::iterator iterator;
static bool contains(value_type const& it, uint32 v)
{
return (it.first <= v) && (it.second >= v);
}
void simplify();
public:
@@ -29,71 +36,10 @@ public:
void setValue(uint32);
void setRange(uint32, uint32);
void clearValue(uint32);
void clearRange(uint32, uint32);
// iterator stuff
iterator begin() { return mRanges.begin(); }
iterator end() { return mRanges.end(); }
const_iterator begin() const { return mRanges.begin(); }
const_iterator end() const { return mRanges.end(); }
reverse_iterator rbegin() { return mRanges.rbegin(); }
reverse_iterator rend() { return mRanges.rend(); }
const_reverse_iterator rbegin() const { return mRanges.rbegin(); }
const_reverse_iterator rend() const { return mRanges.rend(); }
static uint32 lower(const_iterator& it) { return it->lower(); }
static uint32 upper(const_iterator& it) { return it->upper() - 1; }
static uint32 lower(const_reverse_iterator& it) { return it->lower(); }
static uint32 upper(const_reverse_iterator& it) { return it->upper() - 1; }
std::string toString() const;
};
inline RangeSet::const_iterator range_begin(const RangeSet& r) { return r.begin(); }
inline RangeSet::iterator range_begin(RangeSet& r) { return r.begin(); }
inline RangeSet::const_iterator range_end(const RangeSet& r) { return r.end(); }
inline RangeSet::iterator range_end(RangeSet& r) { return r.end(); }
namespace boost
{
template<> struct range_mutable_iterator<RangeSet>
{
typedef RangeSet::iterator type;
};
template<> struct range_const_iterator<RangeSet>
{
typedef RangeSet::const_iterator type;
};
}
// VFALCO Maybe not the best place for this but it sort of makes sense here
// VFALCO NOTE these three are unused.
/*
template<typename T> T range_check(const T& value, const T& minimum, const T& maximum)
{
if ((value < minimum) || (value > maximum))
throw std::runtime_error("Value out of range");
return value;
}
template<typename T> T range_check_min(const T& value, const T& minimum)
{
if (value < minimum)
throw std::runtime_error("Value out of range");
return value;
}
template<typename T> T range_check_max(const T& value, const T& maximum)
{
if (value > maximum)
throw std::runtime_error("Value out of range");
return value;
}
*/
// VFALCO TODO these parameters should not be const references.
template<typename T, typename U> T range_check_cast(const U& value, const T& minimum, const T& maximum)
{
@@ -102,6 +48,7 @@ template<typename T, typename U> T range_check_cast(const U& value, const T& min
return static_cast<T>(value);
}
#endif
// vim:ts=4

View File

@@ -72,7 +72,7 @@ namespace boost {
// RangeSet
#include <boost/foreach.hpp>
#include <boost/icl/interval_set.hpp> // oof this one is ugly
//#include <boost/icl/interval_set.hpp> // oof this one is ugly
// InstanceCounter
//#include <string>

View File

@@ -1,7 +1,7 @@
#ifndef RIPPLE_INSTANCECOUNTER_H
#define RIPPLE_INSTANCECOUNTER_H
// VFALCO TODO Clean up this junk, remove the macros, replace
// VFALCO TODO Clean this up, remove the macros, replace
// with a robust leak checker when we have atomics.
//
@@ -38,7 +38,7 @@ protected:
public:
typedef std::pair<std::string, int> InstanceCount;
InstanceType(const char *n) : mInstances(0), mName(n)
explicit InstanceType (const char *n) : mInstances(0), mName(n)
{
mNextInstance = sHeadInstance;
sHeadInstance = this;
@@ -65,7 +65,7 @@ public:
{
if (sMultiThreaded)
{
// VFALCO NOTE Junk that will go away with atomics
// VFALCO NOTE This will go away with atomics
mLock.lock();
++mInstances;
mLock.unlock();

View File

@@ -160,7 +160,7 @@ bool RandomNumbers::platformAddEntropy ()
void RandomNumbers::platformAddPerformanceMonitorEntropy ()
{
// VFALCO This is how we simulate local functions
// VFALCO TODO Remove all this fancy stuff
struct
{
int64 operator() () const

View File

@@ -19,7 +19,10 @@
#ifndef RIPPLE_SUSTAIN_H
#define RIPPLE_SUSTAIN_H
// VFALCO TODO figure out what the heck this is??
// "Sustain" is a system for a buddy process that monitors the main process
// and relaunches it on a fault.
//
// VFALCO TODO Rename this and put it in a class.
extern bool HaveSustain();
extern std::string StopSustain();
extern std::string DoSustain();

View File

@@ -22,4 +22,51 @@
@ingroup ripple_client
*/
#include <set>
#include <boost/unordered_set.hpp>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
#include "ripple_client.h"
#include "../ripple_basics/ripple_basics.h"
#include "../ripple_data/ripple_data.h"
#include "src/cpp/ripple/ripple_InfoSub.h"
// Order and indentation reflect the hierarchy of dependencies
#include "src/cpp/ripple/ripple_HashedObject.h"
#include "src/cpp/ripple/ripple_SHAMapItem.h"
#include "src/cpp/ripple/ripple_SHAMapNode.h"
#include "src/cpp/ripple/ripple_SHAMapAddNode.h"
#include "src/cpp/ripple/ripple_SHAMapMissingNode.h"
#include "src/cpp/ripple/ripple_SHAMapTreeNode.h"
#include "src/cpp/ripple/ripple_SHAMapSyncFilter.h"
#include "src/cpp/ripple/ripple_SHAMap.h"
#include "src/cpp/ripple/ripple_SerializedTransaction.h"
#include "src/cpp/ripple/ripple_SerializedLedger.h"
#include "src/cpp/ripple/TransactionMeta.h"
#include "src/cpp/ripple/Transaction.h"
#include "src/cpp/ripple/AccountState.h"
#include "src/cpp/ripple/NicknameState.h"
#include "src/cpp/ripple/Ledger.h"
#include "src/cpp/ripple/LedgerEntrySet.h"
#include "src/cpp/ripple/TransactionEngine.h"
#include "src/cpp/ripple/LoadManager.h"
#include "src/cpp/ripple/ripple_Peer.h"
#include "src/cpp/ripple/ripple_PeerSet.h"
#include "src/cpp/ripple/ripple_LedgerAcquire.h"
#include "src/cpp/ripple/ripple_LedgerHistory.h"
#include "src/cpp/ripple/ripple_CanonicalTXSet.h"
#include "src/cpp/ripple/LedgerMaster.h"
#include "src/cpp/ripple/ripple_InfoSub.h"
#include "src/cpp/ripple/SerializedValidation.h"
#include "src/cpp/ripple/LedgerProposal.h"
#include "src/cpp/ripple/ripple_AcceptedLedgerTx.h"
#include "src/cpp/ripple/NetworkOPs.h"
#include "src/cpp/ripple/ripple_IApplication.h"
#include "src/cpp/ripple/ripple_InfoSub.cpp"
//#include "src/cpp/ripple/NetworkOPs.cpp"

View File

@@ -32,6 +32,4 @@
#ifndef RIPPLE_CLIENT_H
#define RIPPLE_CLIENT_H
#include "modules/ripple_basics/ripple_basics.h"
#endif

View File

@@ -3,8 +3,6 @@ std::map <int, LedgerEntryFormat*> LedgerEntryFormat::byType;
std::map <std::string, LedgerEntryFormat*> LedgerEntryFormat::byName;
// VFALCO TODO surely we can think of a better way than macros?
#define LEF_BASE \
<< SOElement(sfLedgerIndex, SOE_OPTIONAL) \
<< SOElement(sfLedgerEntryType, SOE_REQUIRED) \

View File

@@ -1,13 +1,8 @@
// VFALCO TODO remove this when it's safe to do so.
#ifdef __APPLICATION__
#error Including Application.h is disallowed!
#endif
SETUP_LOG (RippleAddress)
RippleAddress::RippleAddress() : mIsValid(false)
RippleAddress::RippleAddress ()
: mIsValid (false)
{
nVersion = VER_NONE;
}

View File

@@ -1021,13 +1021,13 @@ UPTR_T<STObject> STObject::parseJson(const Json::Value& object, SField::ref inNa
else if (value.isInt())
{
if (value.asInt() < 0 || value.asInt() > 255)
throw std::runtime_error("value out of rand");
throw std::runtime_error("value out of range");
data.push_back(new STUInt8(field, range_check_cast<unsigned char>(value.asInt(), 0, 255)));
}
else if (value.isUInt())
{
if (value.asUInt() > 255)
throw std::runtime_error("value out of rand");
throw std::runtime_error("value out of range");
data.push_back(new STUInt8(field, range_check_cast<unsigned char>(value.asUInt(), 0, 255)));
}
else

View File

@@ -30,7 +30,7 @@ static const uint160 u160_zero(0), u160_one(1);
static inline const uint160& get_u160_zero() { return u160_zero; }
static inline const uint160& get_u160_one() { return u160_one; }
// VFALCO TODO replace these with language constructs, gah!
// VFALCO TODO replace these with language constructs
#define CURRENCY_XRP get_u160_zero()
#define CURRENCY_ONE get_u160_one() // Used as a place holder.
#define CURRENCY_BAD uint160(0x5852500000000000) // Do not allow XRP as an IOU currency.

View File

@@ -57,6 +57,15 @@
// VFALCO TODO try to reduce these dependencies
#include "../ripple_basics/ripple_basics.h"
//------------------------------------------------------------------------------
// VFALCO TODO prepare a unity header for LevelDB
// VFALCO TODO don't expose leveldb throughout the headers
#include "leveldb/cache.h"
#include "leveldb/filter_policy.h"
#include "leveldb/db.h"
#include "leveldb/write_batch.h"
// VFALCO TODO figure out a good place for this file, perhaps give it some
// additional hierarchy via directories.
#include "ripple.pb.h"

View File

@@ -34,11 +34,14 @@
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
// VFALCO NOTE Holy smokes...that's a lot of boost!!!
#include <boost/algorithm/string.hpp>
#include <boost/array.hpp>
#include <boost/asio.hpp>
@@ -55,11 +58,14 @@
#include <boost/function.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/make_shared.hpp>
#include <boost/mem_fn.hpp>
#include <boost/pointer_cast.hpp>
#include <boost/program_options.hpp>
#include <boost/ptr_container/ptr_vector.hpp>
#include <boost/ref.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/smart_ptr/shared_ptr.hpp>
#include <boost/test/included/unit_test.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/thread.hpp>
#include <boost/thread/condition_variable.hpp>
@@ -77,14 +83,6 @@
//------------------------------------------------------------------------------
// VFALCO TODO prepare a unity header for LevelDB
#include "leveldb/cache.h"
#include "leveldb/filter_policy.h"
#include "leveldb/db.h"
#include "leveldb/write_batch.h"
//------------------------------------------------------------------------------
// VFALCO TODO fix these warnings!
#ifdef _MSC_VER
//#pragma warning (push) // Causes spurious C4503 "decorated name exceeds maximum length"
@@ -197,7 +195,16 @@
//
// -----------
#include "src/cpp/ripple/Application.h"
#include "src/cpp/ripple/TransactionMaster.h"
#include "src/cpp/ripple/Wallet.h"
#include "src/cpp/ripple/WSDoor.h"
#include "src/cpp/ripple/SNTPClient.h"
#include "src/cpp/ripple/RPCHandler.h"
#include "src/cpp/ripple/TransactionQueue.h"
#include "src/cpp/ripple/OrderBookDB.h"
#include "src/cpp/ripple/ripple_DatabaseCon.h"
#include "src/cpp/ripple/ripple_IApplication.h"
#include "src/cpp/ripple/AutoSocket.h"
#include "src/cpp/ripple/CallRPC.h"
#include "src/cpp/ripple/ChangeTransactor.h"
@@ -210,8 +217,7 @@
#include "src/cpp/ripple/OfferCancelTransactor.h"
#include "src/cpp/ripple/OfferCreateTransactor.h"
#include "src/cpp/ripple/OrderBook.h"
#include "src/cpp/ripple/OrderBookDB.h"
#include "src/cpp/ripple/PFRequest.h"
#include "src/cpp/ripple/ripple_PathRequest.h"
#include "src/cpp/ripple/ParameterTable.h"
#include "src/cpp/ripple/ParseSection.h"
#include "src/cpp/ripple/Pathfinder.h"
@@ -220,24 +226,18 @@
#include "src/cpp/ripple/RPC.h"
#include "src/cpp/ripple/RPCDoor.h"
#include "src/cpp/ripple/RPCErr.h"
#include "src/cpp/ripple/RPCHandler.h"
#include "src/cpp/ripple/RPCServer.h"
#include "src/cpp/ripple/RPCSub.h"
#include "src/cpp/ripple/RegularKeySetTransactor.h"
#include "src/cpp/ripple/RippleCalc.h"
#include "src/cpp/ripple/RippleState.h"
#include "src/cpp/ripple/SNTPClient.h"
#include "src/cpp/ripple/SerializedValidation.h"
#include "src/cpp/ripple/TransactionMaster.h"
#include "src/cpp/ripple/TransactionQueue.h"
#include "src/cpp/ripple/Transactor.h"
#include "src/cpp/ripple/AccountSetTransactor.h"
#include "src/cpp/ripple/TrustSetTransactor.h"
#include "src/cpp/ripple/Version.h"
#include "src/cpp/ripple/WSConnection.h"
#include "src/cpp/ripple/WSDoor.h"
#include "src/cpp/ripple/WSHandler.h"
#include "src/cpp/ripple/Wallet.h"
#include "src/cpp/ripple/WalletAddTransactor.h"
#include "../websocketpp/src/logger/logger.hpp" // for ripple_LogWebSockets.cpp
@@ -270,7 +270,6 @@ static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength)
#include "src/cpp/ripple/AccountItems.cpp" // no log
#include "src/cpp/ripple/AccountSetTransactor.cpp"
#include "src/cpp/ripple/AccountState.cpp" // no log
#include "src/cpp/ripple/Application.cpp"
#include "src/cpp/ripple/CallRPC.cpp"
#include "src/cpp/ripple/ripple_CanonicalTXSet.cpp"
#include "src/cpp/ripple/ChangeTransactor.cpp" // no log
@@ -300,7 +299,6 @@ static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength)
#include "src/cpp/ripple/Pathfinder.cpp"
#include "src/cpp/ripple/PaymentTransactor.cpp"
#include "src/cpp/ripple/PeerDoor.cpp"
#include "src/cpp/ripple/PFRequest.cpp"
#include "src/cpp/ripple/RegularKeySetTransactor.cpp"
#include "src/cpp/ripple/RippleCalc.cpp"
#include "src/cpp/ripple/RippleState.cpp" // no log
@@ -322,7 +320,6 @@ static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength)
#include "src/cpp/ripple/TransactionQueue.cpp" // no log
#include "src/cpp/ripple/Transactor.cpp"
#include "src/cpp/ripple/TrustSetTransactor.cpp"
#include "src/cpp/ripple/UpdateTables.cpp"
#include "src/cpp/ripple/Wallet.cpp"
#include "src/cpp/ripple/WalletAddTransactor.cpp"
#include "src/cpp/ripple/WSDoor.cpp" // uses logging in WSConnection.h
@@ -339,13 +336,14 @@ static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength)
#include "src/cpp/ripple/ripple_AcceptedLedgerTx.cpp"
#include "src/cpp/ripple/ripple_AcceptedLedger.cpp"
#include "src/cpp/ripple/ripple_Application.cpp"
#include "src/cpp/ripple/ripple_Config.cpp"
#include "src/cpp/ripple/ripple_DatabaseCon.cpp"
#include "src/cpp/ripple/ripple_Features.cpp"
#include "src/cpp/ripple/ripple_FeeVote.cpp"
#include "src/cpp/ripple/ripple_HashedObjectStore.cpp"
#include "src/cpp/ripple/ripple_HashRouter.cpp"
#include "src/cpp/ripple/ripple_InfoSub.cpp"
//#include "src/cpp/ripple/ripple_InfoSub.cpp"
#include "src/cpp/ripple/ripple_Job.cpp"
#include "src/cpp/ripple/ripple_JobQueue.cpp"
#include "src/cpp/ripple/ripple_LedgerAcquire.cpp"
@@ -355,6 +353,7 @@ static DH* handleTmpDh(SSL* ssl, int is_export, int iKeyLength)
#include "src/cpp/ripple/ripple_LoadMonitor.cpp"
#include "src/cpp/ripple/ripple_LogWebsockets.cpp"
#include "src/cpp/ripple/ripple_LoadFeeTrack.cpp"
#include "src/cpp/ripple/ripple_PathRequest.cpp"
#include "src/cpp/ripple/ripple_Peer.cpp"
#include "src/cpp/ripple/ripple_Peers.cpp"
#include "src/cpp/ripple/ripple_PeerSet.cpp"

View File

@@ -734,7 +734,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\cpp\ripple\Application.cpp">
<ClCompile Include="src\cpp\ripple\ripple_Application.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>
@@ -990,7 +990,7 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\cpp\ripple\PFRequest.cpp">
<ClCompile Include="src\cpp\ripple\ripple_PathRequest.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
</ClCompile>
@@ -1264,12 +1264,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\cpp\ripple\UpdateTables.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>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="src\cpp\ripple\Wallet.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -1702,7 +1696,7 @@
<ClInclude Include="src\cpp\ripple\AccountItems.h" />
<ClInclude Include="src\cpp\ripple\AccountSetTransactor.h" />
<ClInclude Include="src\cpp\ripple\AccountState.h" />
<ClInclude Include="src\cpp\ripple\Application.h" />
<ClInclude Include="src\cpp\ripple\ripple_IApplication.h" />
<ClInclude Include="src\cpp\ripple\AutoSocket.h" />
<ClInclude Include="src\cpp\ripple\CallRPC.h" />
<ClInclude Include="src\cpp\ripple\ripple_AcceptedLedgerTx.h" />
@@ -1745,7 +1739,7 @@
<ClInclude Include="src\cpp\ripple\Pathfinder.h" />
<ClInclude Include="src\cpp\ripple\PaymentTransactor.h" />
<ClInclude Include="src\cpp\ripple\PeerDoor.h" />
<ClInclude Include="src\cpp\ripple\PFRequest.h" />
<ClInclude Include="src\cpp\ripple\ripple_PathRequest.h" />
<ClInclude Include="src\cpp\ripple\RegularKeySetTransactor.h" />
<ClInclude Include="src\cpp\ripple\RippleCalc.h" />
<ClInclude Include="src\cpp\ripple\RippleState.h" />

View File

@@ -91,9 +91,6 @@
<Filter Include="2. Empty\ripple_net">
<UniqueIdentifier>{7f76ce57-c428-487e-97a0-979c0990a81d}</UniqueIdentifier>
</Filter>
<Filter Include="2. Empty\ripple_client">
<UniqueIdentifier>{97c96b68-70fd-4679-89fc-c1c8c87c265e}</UniqueIdentifier>
</Filter>
<Filter Include="2. Empty\ripple_db">
<UniqueIdentifier>{a5190241-c5bc-4e23-8ef1-6adf757c75e3}</UniqueIdentifier>
</Filter>
@@ -130,9 +127,12 @@
<Filter Include="1. Modules\ripple_data\protocol">
<UniqueIdentifier>{2f3572a9-2882-4656-ab93-82b7761c9e3d}</UniqueIdentifier>
</Filter>
<Filter Include="1. Modules\ripple_ledger">
<Filter Include="2. Empty\ripple_ledger">
<UniqueIdentifier>{b6175f9a-7d46-4b57-877f-f58b0b3bba89}</UniqueIdentifier>
</Filter>
<Filter Include="1. Modules\ripple_client">
<UniqueIdentifier>{97c96b68-70fd-4679-89fc-c1c8c87c265e}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="src\cpp\database\sqlite3.c">
@@ -469,10 +469,10 @@
<Filter>1. Modules\ripple_basics</Filter>
</ClCompile>
<ClCompile Include="modules\ripple_ledger\ripple_ledger.cpp">
<Filter>1. Modules\ripple_ledger</Filter>
<Filter>2. Empty\ripple_ledger</Filter>
</ClCompile>
<ClCompile Include="modules\ripple_client\ripple_client.cpp">
<Filter>2. Empty\ripple_client</Filter>
<Filter>1. Modules\ripple_client</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\ChangeTransactor.cpp">
<Filter>1. Modules\ripple_main\_unfactored\transactions</Filter>
@@ -579,18 +579,12 @@
<ClCompile Include="build\proto\ripple.pb.cc">
<Filter>1. Modules\ripple_data\protobuf</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\Application.cpp">
<Filter>1. Modules\ripple_main\_unfactored\main</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\LoadManager.cpp">
<Filter>1. Modules\ripple_main\_unfactored\main</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\main.cpp">
<Filter>1. Modules\ripple_main\_unfactored\main</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\UpdateTables.cpp">
<Filter>1. Modules\ripple_main\_unfactored\main</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\NetworkOPs.cpp">
<Filter>1. Modules\ripple_main\_unfactored\network</Filter>
</ClCompile>
@@ -678,9 +672,6 @@
<ClCompile Include="src\cpp\ripple\Pathfinder.cpp">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\PFRequest.cpp">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\RippleCalc.cpp">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClCompile>
@@ -840,6 +831,12 @@
<ClCompile Include="src\cpp\ripple\ripple_AcceptedLedger.cpp">
<Filter>1. Modules\ripple_main\refactored</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\ripple_PathRequest.cpp">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClCompile>
<ClCompile Include="src\cpp\ripple\ripple_Application.cpp">
<Filter>1. Modules\ripple_main\_unfactored\main</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="database\sqlite3ext.h">
@@ -1170,10 +1167,10 @@
<Filter>1. Modules\ripple_basics</Filter>
</ClInclude>
<ClInclude Include="modules\ripple_ledger\ripple_ledger.h">
<Filter>1. Modules\ripple_ledger</Filter>
<Filter>2. Empty\ripple_ledger</Filter>
</ClInclude>
<ClInclude Include="modules\ripple_client\ripple_client.h">
<Filter>2. Empty\ripple_client</Filter>
<Filter>1. Modules\ripple_client</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\ChangeTransactor.h">
<Filter>1. Modules\ripple_main\_unfactored\transactions</Filter>
@@ -1316,9 +1313,6 @@
<ClInclude Include="build\proto\ripple.pb.h">
<Filter>1. Modules\ripple_data\protobuf</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\Application.h">
<Filter>1. Modules\ripple_main\_unfactored\main</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\LoadManager.h">
<Filter>1. Modules\ripple_main\_unfactored\main</Filter>
</ClInclude>
@@ -1412,9 +1406,6 @@
<ClInclude Include="src\cpp\ripple\Pathfinder.h">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\PFRequest.h">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\RippleCalc.h">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClInclude>
@@ -1583,6 +1574,12 @@
<ClInclude Include="src\cpp\ripple\ripple_AcceptedLedger.h">
<Filter>1. Modules\ripple_main\refactored</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\ripple_PathRequest.h">
<Filter>1. Modules\ripple_main\_unfactored\ledger</Filter>
</ClInclude>
<ClInclude Include="src\cpp\ripple\ripple_IApplication.h">
<Filter>1. Modules\ripple_main\_unfactored\main</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="SConstruct" />

View File

@@ -117,20 +117,6 @@ bool SqliteDatabase::executeSQL(const char* sql, bool fail_ok)
return true;
}
// tells you how many rows were changed by an update or insert
int SqliteDatabase::getNumRowsAffected()
{
// TODO: SqliteDatabase::getNumRowsAffected()
return(0);
}
// VFALCO TODO This must be fixed!!! return value needs to be int64
//
int SqliteDatabase::getLastInsertID()
{
return(sqlite3_last_insert_rowid(mConnection));
}
// returns false if there are no results
bool SqliteDatabase::startIterRows(bool finalize)
{

View File

@@ -27,7 +27,6 @@ public:
// tells you how many rows were changed by an update or insert
int getNumRowsAffected();
int getLastInsertID();
// returns false if there are no results
bool startIterRows(bool finalize);

View File

@@ -43,10 +43,6 @@ public:
return executeSQL(strSql.c_str(), fail_okay);
}
// tells you how many rows were changed by an update or insert
virtual int getNumRowsAffected()=0;
virtual int getLastInsertID()=0;
// returns false if there are no results
virtual bool startIterRows(bool finalize = true)=0;
virtual void endIterRows()=0;

View File

@@ -26,7 +26,7 @@ std::string AccountState::createGravatarUrl(uint128 uEmailHash)
std::string strMD5Lower = strHex(vucMD5);
boost::to_lower(strMD5Lower);
return str(boost::format("http://www.gravatar.com/avatar/%s") % strMD5Lower);
return str(boost::format("https://www.gravatar.com/avatar/%s") % strMD5Lower);
}
void AccountState::addJson(Json::Value& val)

View File

@@ -1,151 +0,0 @@
#ifndef __APPLICATION__
#define __APPLICATION__
#include "leveldb/db.h"
#include <boost/asio.hpp>
#include "../database/database.h"
#include "LedgerMaster.h"
#include "TransactionMaster.h"
#include "Wallet.h"
#include "WSDoor.h"
#include "SNTPClient.h"
#include "RPCHandler.h"
#include "LoadManager.h"
#include "TransactionQueue.h"
#include "OrderBookDB.h"
#include "ripple_DatabaseCon.h"
// VFALCO TODO Fix forward declares required for header dependency loops
class IFeatures;
class IFeeVote;
class IHashRouter;
class ILoadFeeTrack;
class IValidations;
class IUniqueNodeList;
class IProofOfWorkFactory;
class IPeers;
class RPCDoor;
class PeerDoor;
typedef TaggedCache <uint256, Blob , UptimeTimerAdapter> NodeCache;
typedef TaggedCache <uint256, SLE, UptimeTimerAdapter> SLECache;
class Application
{
public:
Application();
~Application();
Wallet& getWallet() { return mWallet ; }
NetworkOPs& getOPs() { return mNetOps; }
boost::asio::io_service& getIOService() { return mIOService; }
boost::asio::io_service& getAuxService() { return mAuxService; }
LedgerMaster& getLedgerMaster() { return mLedgerMaster; }
LedgerAcquireMaster& getMasterLedgerAcquire() { return mMasterLedgerAcquire; }
TransactionMaster& getMasterTransaction() { return mMasterTransaction; }
NodeCache& getTempNodeCache() { return mTempNodeCache; }
HashedObjectStore& getHashedObjectStore() { return mHashedObjectStore; }
JobQueue& getJobQueue() { return mJobQueue; }
boost::recursive_mutex& getMasterLock() { return mMasterLock; }
LoadManager& getLoadManager() { return mLoadMgr; }
TXQueue& getTxnQueue() { return mTxnQueue; }
PeerDoor& getPeerDoor() { return *mPeerDoor; }
OrderBookDB& getOrderBookDB() { return mOrderBookDB; }
SLECache& getSLECache() { return mSLECache; }
IFeatures& getFeatureTable() { return *mFeatures; }
ILoadFeeTrack& getFeeTrack() { return *mFeeTrack; }
IFeeVote& getFeeVote() { return *mFeeVote; }
IHashRouter& getHashRouter() { return *mHashRouter; }
IValidations& getValidations() { return *mValidations; }
IUniqueNodeList& getUNL() { return *mUNL; }
IProofOfWorkFactory& getProofOfWorkFactory() { return *mProofOfWorkFactory; }
IPeers& getPeers () { return *mPeers; }
// VFALCO TODO Move these to the .cpp
bool running() { return mTxnDB != NULL; } // VFALCO TODO replace with nullptr when beast is available
bool getSystemTimeOffset(int& offset) { return mSNTPClient.getOffset(offset); }
DatabaseCon* getRpcDB() { return mRpcDB; }
DatabaseCon* getTxnDB() { return mTxnDB; }
DatabaseCon* getLedgerDB() { return mLedgerDB; }
DatabaseCon* getWalletDB() { return mWalletDB; }
DatabaseCon* getNetNodeDB() { return mNetNodeDB; }
DatabaseCon* getPathFindDB() { return mPathFindDB; }
DatabaseCon* getHashNodeDB() { return mHashNodeDB; }
leveldb::DB* getHashNodeLDB() { return mHashNodeLDB; }
leveldb::DB* getEphemeralLDB() { return mEphemeralLDB; }
bool isShutdown() { return mShutdown; }
void setup();
void run();
void stop();
void sweep();
private:
void updateTables (bool);
void startNewLedger ();
bool loadOldLedger (const std::string&);
boost::asio::io_service mIOService;
boost::asio::io_service mAuxService;
boost::asio::io_service::work mIOWork;
boost::asio::io_service::work mAuxWork;
boost::recursive_mutex mMasterLock;
Wallet mWallet;
LedgerMaster mLedgerMaster;
LedgerAcquireMaster mMasterLedgerAcquire;
TransactionMaster mMasterTransaction;
NetworkOPs mNetOps;
NodeCache mTempNodeCache;
HashedObjectStore mHashedObjectStore;
SLECache mSLECache;
SNTPClient mSNTPClient;
JobQueue mJobQueue;
LoadManager mLoadMgr;
TXQueue mTxnQueue;
OrderBookDB mOrderBookDB;
// VFALCO Clean stuff
beast::ScopedPointer <IFeatures> mFeatures;
beast::ScopedPointer <IFeeVote> mFeeVote;
beast::ScopedPointer <ILoadFeeTrack> mFeeTrack;
beast::ScopedPointer <IHashRouter> mHashRouter;
beast::ScopedPointer <IValidations> mValidations;
beast::ScopedPointer <IUniqueNodeList> mUNL;
beast::ScopedPointer <IProofOfWorkFactory> mProofOfWorkFactory;
beast::ScopedPointer <IPeers> mPeers;
// VFALCO End Clean stuff
DatabaseCon *mRpcDB, *mTxnDB, *mLedgerDB, *mWalletDB, *mNetNodeDB, *mPathFindDB, *mHashNodeDB;
leveldb::DB *mHashNodeLDB;
leveldb::DB *mEphemeralLDB;
PeerDoor* mPeerDoor;
RPCDoor* mRPCDoor;
WSDoor* mWSPublicDoor;
WSDoor* mWSPrivateDoor;
boost::asio::deadline_timer mSweepTimer;
std::map<std::string, Peer::pointer> mPeerMap;
boost::recursive_mutex mPeerMapLock;
volatile bool mShutdown;
};
extern Application* theApp;
#endif
// vim:ts=4

View File

@@ -20,7 +20,6 @@
#include <openssl/buffer.h>
#include <openssl/evp.h>
#include "Application.h"
#include "RPC.h"
#include "RPCErr.h"

View File

@@ -39,7 +39,14 @@ public:
LedgerEntrySetEntry(SLE::ref e, LedgerEntryAction a, int s) : mEntry(e), mAction(a), mSeq(s) { ; }
};
/** An LES is a LedgerEntrySet.
It's a view into a ledger used while a transaction is processing.
The transaction manipulates the LES rather than the ledger
(because it's cheaper, can be checkpointed, and so on). When the
transaction finishes, the LES is committed into the ledger to make
the modifications. The transaction metadata is built from the LES too.
*/
class LedgerEntrySet : private IS_INSTANCE(LedgerEntrySet)
{
public:

View File

@@ -726,12 +726,13 @@ void LedgerMaster::updatePaths()
mPathFindNewRequest = false;
}
PFRequest::updateAll(lastLedger, newOnly);
// VFALCO TODO Fix this global variable
PathRequest::updateAll (lastLedger, newOnly);
} while(1);
}
void LedgerMaster::newPFRequest()
void LedgerMaster::newPathRequest()
{
boost::recursive_mutex::scoped_lock ml(mLock);
mPathFindNewRequest = true;

View File

@@ -11,7 +11,7 @@
class LedgerMaster
{
public:
typedef FUNCTION_TYPE<void(Ledger::ref)> callback;
typedef FUNCTION_TYPE <void(Ledger::ref)> callback;
public:
LedgerMaster ()
@@ -125,7 +125,7 @@ public:
void checkAccept(uint256 const& hash);
void checkAccept(uint256 const& hash, uint32 seq);
void tryPublish();
void newPFRequest();
void newPathRequest();
static bool shouldAcquire(uint32 currentLedgerID, uint32 ledgerHistory, uint32 targetLedger);

View File

@@ -1,10 +1,4 @@
#include "Application.h"
#include "Transaction.h"
#include "HashPrefixes.h"
#include "LedgerConsensus.h"
#include "LedgerTiming.h"
SETUP_LOG (NetworkOPs)
// This is the primary interface into the "client" portion of the program.
@@ -977,16 +971,21 @@ void NetworkOPs::mapComplete(uint256 const& hash, SHAMap::ref map)
mConsensus->mapComplete(hash, map, true);
}
void NetworkOPs::endConsensus(bool correctLCL)
void NetworkOPs::endConsensus (bool correctLCL)
{
uint256 deadLedger = mLedgerMaster->getClosedLedger()->getParentHash();
std::vector<Peer::pointer> peerList = theApp->getPeers().getPeerVector();
BOOST_FOREACH(Peer::ref it, peerList)
std::vector <Peer::pointer> peerList = theApp->getPeers().getPeerVector ();
BOOST_FOREACH(Peer::ref it, peerList)
{
if (it && (it->getClosedLedgerHash() == deadLedger))
{
WriteLog (lsTRACE, NetworkOPs) << "Killing obsolete peer status";
it->cycleStatus();
}
}
mConsensus = boost::shared_ptr<LedgerConsensus>();
}
@@ -996,33 +995,43 @@ void NetworkOPs::consensusViewChange()
setMode(omCONNECTED);
}
void NetworkOPs::pubServer()
void NetworkOPs::pubServer ()
{
boost::recursive_mutex::scoped_lock sl(mMonitorLock);
// VFALCO TODO Don't hold the lock across calls to send...make a copy of the
// list into a local array while holding the lock then release the
// lock and call send on everyone.
//
boost::recursive_mutex::scoped_lock sl (mMonitorLock);
if (!mSubServer.empty())
{
Json::Value jvObj(Json::objectValue);
if (!mSubServer.empty ())
{
Json::Value jvObj (Json::objectValue);
jvObj["type"] = "serverStatus";
jvObj["server_status"] = strOperatingMode();
jvObj["load_base"] = (mLastLoadBase = theApp->getFeeTrack().getLoadBase());
jvObj["load_factor"] = (mLastLoadFactor = theApp->getFeeTrack().getLoadFactor());
jvObj ["type"] = "serverStatus";
jvObj ["server_status"] = strOperatingMode();
jvObj ["load_base"] = (mLastLoadBase = theApp->getFeeTrack().getLoadBase());
jvObj ["load_factor"] = (mLastLoadFactor = theApp->getFeeTrack().getLoadFactor());
NetworkOPs::subMapType::const_iterator it = mSubServer.begin();
while (it != mSubServer.end())
{
InfoSub::pointer p = it->second.lock();
if (p)
{
p->send(jvObj, true);
++it;
}
else
it = mSubServer.erase(it);
}
NetworkOPs::subMapType::const_iterator it = mSubServer.begin();
}
while (it != mSubServer.end())
{
InfoSub::pointer p = it->second.lock();
// VFALCO TODO research the possibility of using thread queues and linearizing
// the deletion of subscribers with the sending of JSON data.
if (p)
{
p->send(jvObj, true);
++it;
}
else
{
it = mSubServer.erase(it);
}
}
}
}
void NetworkOPs::setMode(OperatingMode om)
@@ -1668,9 +1677,11 @@ bool NetworkOPs::subBook(InfoSub::ref isrListener, const uint160& currencyPays,
{
BookListeners::pointer listeners =
theApp->getOrderBookDB().makeBookListeners(currencyPays, currencyGets, issuerPays, issuerGets);
if (listeners)
if (listeners)
listeners->addSubscriber(isrListener);
return true;
return true;
}
bool NetworkOPs::unsubBook(uint64 uSeq,

View File

@@ -25,7 +25,22 @@ public:
omFULL = 4 // we have the ledger and can even validate
};
typedef boost::unordered_map<uint64, InfoSub::wptr> subMapType;
#if 0
/** Subscription data interface.
*/
class Subscriber
{
public:
typedef boost::weak_ptr <Subscriber> WeakPtr;
/** Called every time new JSON data is available.
*/
virtual void onSubscriberReceiveJSON (Json::Value const& json) { }
};
typedef boost::unordered_map <uint64, Subscriber::WeakPtr> subMapType;
#endif
typedef boost::unordered_map <uint64, InfoSub::wptr> subMapType;
public:
NetworkOPs(boost::asio::io_service& io_service, LedgerMaster* pLedgerMaster);

View File

@@ -1,12 +1,4 @@
#include "Pathfinder.h"
#include <queue>
#include <boost/foreach.hpp>
#include "Application.h"
SETUP_LOG (Pathfinder)
/*

View File

@@ -1,13 +1,4 @@
#include "PeerDoor.h"
#include <iostream>
#include <boost/bind.hpp>
#include <boost/mem_fn.hpp>
#include "Application.h"
SETUP_LOG (PeerDoor)
using namespace std;

View File

@@ -1,5 +1,4 @@
#include "RPCDoor.h"
#include "Application.h"
#include <boost/bind.hpp>
#include <iostream>

View File

@@ -11,7 +11,6 @@
#include "Pathfinder.h"
#include "RPCHandler.h"
#include "RPCSub.h"
#include "Application.h"
#include "AccountItems.h"
#include "Wallet.h"
#include "RippleCalc.h"
@@ -19,7 +18,6 @@
#include "AccountState.h"
#include "NicknameState.h"
#include "Offer.h"
#include "PFRequest.h"
SETUP_LOG (RPCHandler)
@@ -1326,29 +1324,29 @@ Json::Value RPCHandler::doPathFind(Json::Value jvRequest, int& cost, ScopedLock&
if (sSubCommand == "create")
{
mInfoSub->clearPFRequest();
PFRequest::pointer request = boost::make_shared<PFRequest>(mInfoSub);
mInfoSub->clearPathRequest();
PathRequest::pointer request = boost::make_shared<PathRequest>(mInfoSub);
Json::Value result = request->doCreate(mNetOps->getClosedLedger(), jvRequest);
if (request->isValid())
{
mInfoSub->setPFRequest(request);
theApp->getLedgerMaster().newPFRequest();
mInfoSub->setPathRequest(request);
theApp->getLedgerMaster().newPathRequest();
}
return result;
}
if (sSubCommand == "close")
{
PFRequest::pointer request = mInfoSub->getPFRequest();
PathRequest::pointer request = mInfoSub->getPathRequest();
if (!request)
return rpcError(rpcNO_PF_REQUEST);
mInfoSub->clearPFRequest();
mInfoSub->clearPathRequest();
return request->doClose(jvRequest);
}
if (sSubCommand == "status")
{
PFRequest::pointer request = mInfoSub->getPFRequest();
PathRequest::pointer request = mInfoSub->getPathRequest();
if (!request)
return rpcNO_PF_REQUEST;
return request->doStatus(jvRequest);

View File

@@ -1,6 +1,5 @@
#include <boost/thread.hpp>
#include "Application.h"
#include "RPCSub.h"
#include "CallRPC.h"

View File

@@ -1,136 +0,0 @@
//VFALCO TODO clean this up since it is just a file holding a single member function definition
static std::vector<std::string> getSchema(DatabaseCon* dbc, const std::string& dbName)
{
std::vector<std::string> schema;
std::string sql = "SELECT sql FROM sqlite_master WHERE tbl_name='";
sql += dbName;
sql += "';";
SQL_FOREACH(dbc->getDB(), sql)
{
dbc->getDB()->getStr("sql", sql);
schema.push_back(sql);
}
return schema;
}
static bool schemaHas(DatabaseCon* dbc, const std::string& dbName, int line, const std::string& content)
{
std::vector<std::string> schema = getSchema(dbc, dbName);
if (static_cast<int>(schema.size()) <= line)
{
Log(lsFATAL) << "Schema for " << dbName << " has too few lines";
throw std::runtime_error("bad schema");
}
return schema[line].find(content) != std::string::npos;
}
static void addTxnSeqField()
{
if (schemaHas(theApp->getTxnDB(), "AccountTransactions", 0, "TxnSeq"))
return;
Log(lsWARNING) << "Transaction sequence field is missing";
Database* db = theApp->getTxnDB()->getDB();
std::vector< std::pair<uint256, int> > txIDs;
txIDs.reserve(300000);
Log(lsINFO) << "Parsing transactions";
int i = 0;
uint256 transID;
SQL_FOREACH(db, "SELECT TransID,TxnMeta FROM Transactions;")
{
Blob rawMeta;
int metaSize = 2048;
rawMeta.resize(metaSize);
metaSize = db->getBinary("TxnMeta", &*rawMeta.begin(), rawMeta.size());
if (metaSize > static_cast<int>(rawMeta.size()))
{
rawMeta.resize(metaSize);
db->getBinary("TxnMeta", &*rawMeta.begin(), rawMeta.size());
}
else rawMeta.resize(metaSize);
std::string tid;
db->getStr("TransID", tid);
transID.SetHex(tid, true);
if (rawMeta.size() == 0)
{
txIDs.push_back(std::make_pair(transID, -1));
Log(lsINFO) << "No metadata for " << transID;
}
else
{
TransactionMetaSet m(transID, 0, rawMeta);
txIDs.push_back(std::make_pair(transID, m.getIndex()));
}
if ((++i % 1000) == 0)
Log(lsINFO) << i << " transactions read";
}
Log(lsINFO) << "All " << i << " transactions read";
db->executeSQL("BEGIN TRANSACTION;");
Log(lsINFO) << "Dropping old index";
db->executeSQL("DROP INDEX AcctTxIndex;");
Log(lsINFO) << "Altering table";
db->executeSQL("ALTER TABLE AccountTransactions ADD COLUMN TxnSeq INTEGER;");
typedef std::pair<uint256, int> u256_int_pair_t;
boost::format fmt("UPDATE AccountTransactions SET TxnSeq = %d WHERE TransID = '%s';");
i = 0;
BOOST_FOREACH(u256_int_pair_t& t, txIDs)
{
db->executeSQL(boost::str(fmt % t.second % t.first.GetHex()));
if ((++i % 1000) == 0)
Log(lsINFO) << i << " transactions updated";
}
Log(lsINFO) << "Building new index";
db->executeSQL("CREATE INDEX AcctTxIndex ON AccountTransactions(Account, LedgerSeq, TxnSeq, TransID);");
db->executeSQL("END TRANSACTION;");
}
void Application::updateTables(bool ldbImport)
{ // perform any needed table updates
assert(schemaHas(theApp->getTxnDB(), "AccountTransactions", 0, "TransID"));
assert(!schemaHas(theApp->getTxnDB(), "AccountTransactions", 0, "foobar"));
addTxnSeqField();
if (schemaHas(theApp->getTxnDB(), "AccountTransactions", 0, "PRIMARY"))
{
Log(lsFATAL) << "AccountTransactions database should not have a primary key";
StopSustain();
exit(1);
}
if (theApp->getHashedObjectStore().isLevelDB())
{
boost::filesystem::path hashPath = theConfig.DATA_DIR / "hashnode.db";
if (boost::filesystem::exists(hashPath))
{
if (theConfig.LDB_IMPORT)
{
Log(lsWARNING) << "Importing SQLite -> LevelDB";
theApp->getHashedObjectStore().import(hashPath.string());
Log(lsWARNING) << "Remove or remname the hashnode.db file";
}
else
{
Log(lsWARNING) << "SQLite hashnode database exists. Please either remove or import";
Log(lsWARNING) << "To import, start with the '--import' option. Otherwise, remove hashnode.db";
StopSustain();
exit(1);
}
}
}
}

View File

@@ -11,7 +11,6 @@
#include <boost/pointer_cast.hpp>
#include "WSDoor.h"
#include "Application.h"
#include "CallRPC.h"
#include "LoadManager.h"
#include "RPCErr.h"

View File

@@ -4,7 +4,6 @@
//#include "../websocketpp/src/sockets/autotls.hpp"
//#include "../websocketpp/src/websocketpp.hpp"
#include "Application.h"
#include "WSConnection.h"
#include "WSHandler.h"

View File

@@ -1,8 +1,6 @@
#ifndef __WSHANDLER__
#define __WSHANDLER__
#include "Application.h"
extern void initSSLContext(boost::asio::ssl::context& context,
std::string key_file, std::string cert_file, std::string chain_file);

View File

@@ -1,15 +1,4 @@
#include <iostream>
#include <boost/asio.hpp>
#include <boost/foreach.hpp>
#include <boost/program_options.hpp>
#include <boost/test/included/unit_test.hpp>
#include "Application.h"
#include "CallRPC.h"
#include "RPCHandler.h"
namespace po = boost::program_options;
// VFALCO TODO make these singletons that initialize statically
@@ -21,7 +10,7 @@ using namespace boost::unit_test;
void setupServer()
{
theApp = new Application();
theApp = IApplication::New ();
theApp->setup();
}
@@ -54,7 +43,7 @@ void startServer()
bool init_unit_test()
{
theApp = new Application();
theApp = IApplication::New ();
return true;
}

View File

@@ -1,27 +1,125 @@
// VFALCO TODO Replace these with beast "unsigned long long" generators
#define SYSTEM_CURRENCY_GIFT 1000ull
#define SYSTEM_CURRENCY_USERS 100000000ull
#define SYSTEM_CURRENCY_PARTS 1000000ull // 10^SYSTEM_CURRENCY_PRECISION
#define SYSTEM_CURRENCY_START (SYSTEM_CURRENCY_GIFT*SYSTEM_CURRENCY_USERS*SYSTEM_CURRENCY_PARTS)
/* VFALCO NOTE
IApplication* theApp = NULL;
The master lock protects:
- The open ledger
- Server global state
* What the last closed ledger is
* State of the consensus engine
other things
*/
class Application;
SETUP_LOG (Application)
// VFALCO TODO fix/clean this, it might have broken with the Log changes
LogPartition AutoSocketPartition("AutoSocket");
Application* theApp = NULL;
// VFALCO TODO Move the function definitions into the class declaration
class Application : public IApplication
{
public:
Application();
~Application();
Wallet& getWallet() { return mWallet ; }
NetworkOPs& getOPs() { return mNetOps; }
boost::asio::io_service& getIOService() { return mIOService; }
boost::asio::io_service& getAuxService() { return mAuxService; }
LedgerMaster& getLedgerMaster() { return mLedgerMaster; }
LedgerAcquireMaster& getMasterLedgerAcquire() { return mMasterLedgerAcquire; }
TransactionMaster& getMasterTransaction() { return mMasterTransaction; }
NodeCache& getTempNodeCache() { return mTempNodeCache; }
HashedObjectStore& getHashedObjectStore() { return mHashedObjectStore; }
JobQueue& getJobQueue() { return mJobQueue; }
boost::recursive_mutex& getMasterLock() { return mMasterLock; }
LoadManager& getLoadManager() { return mLoadMgr; }
TXQueue& getTxnQueue() { return mTxnQueue; }
PeerDoor& getPeerDoor() { return *mPeerDoor; }
OrderBookDB& getOrderBookDB() { return mOrderBookDB; }
SLECache& getSLECache() { return mSLECache; }
IFeatures& getFeatureTable() { return *mFeatures; }
ILoadFeeTrack& getFeeTrack() { return *mFeeTrack; }
IFeeVote& getFeeVote() { return *mFeeVote; }
IHashRouter& getHashRouter() { return *mHashRouter; }
IValidations& getValidations() { return *mValidations; }
IUniqueNodeList& getUNL() { return *mUNL; }
IProofOfWorkFactory& getProofOfWorkFactory() { return *mProofOfWorkFactory; }
IPeers& getPeers () { return *mPeers; }
// VFALCO TODO Move these to the .cpp
bool running() { return mTxnDB != NULL; } // VFALCO TODO replace with nullptr when beast is available
bool getSystemTimeOffset(int& offset) { return mSNTPClient.getOffset(offset); }
DatabaseCon* getRpcDB() { return mRpcDB; }
DatabaseCon* getTxnDB() { return mTxnDB; }
DatabaseCon* getLedgerDB() { return mLedgerDB; }
DatabaseCon* getWalletDB() { return mWalletDB; }
DatabaseCon* getNetNodeDB() { return mNetNodeDB; }
DatabaseCon* getPathFindDB() { return mPathFindDB; }
DatabaseCon* getHashNodeDB() { return mHashNodeDB; }
leveldb::DB* getHashNodeLDB() { return mHashNodeLDB; }
leveldb::DB* getEphemeralLDB() { return mEphemeralLDB; }
bool isShutdown() { return mShutdown; }
void setup();
void run();
void stop();
void sweep();
private:
void updateTables (bool);
void startNewLedger ();
bool loadOldLedger (const std::string&);
boost::asio::io_service mIOService;
boost::asio::io_service mAuxService;
boost::asio::io_service::work mIOWork;
boost::asio::io_service::work mAuxWork;
boost::recursive_mutex mMasterLock;
Wallet mWallet;
LedgerMaster mLedgerMaster;
LedgerAcquireMaster mMasterLedgerAcquire;
TransactionMaster mMasterTransaction;
NetworkOPs mNetOps;
NodeCache mTempNodeCache;
HashedObjectStore mHashedObjectStore;
SLECache mSLECache;
SNTPClient mSNTPClient;
JobQueue mJobQueue;
LoadManager mLoadMgr;
TXQueue mTxnQueue;
OrderBookDB mOrderBookDB;
// VFALCO Clean stuff
beast::ScopedPointer <IFeatures> mFeatures;
beast::ScopedPointer <IFeeVote> mFeeVote;
beast::ScopedPointer <ILoadFeeTrack> mFeeTrack;
beast::ScopedPointer <IHashRouter> mHashRouter;
beast::ScopedPointer <IValidations> mValidations;
beast::ScopedPointer <IUniqueNodeList> mUNL;
beast::ScopedPointer <IProofOfWorkFactory> mProofOfWorkFactory;
beast::ScopedPointer <IPeers> mPeers;
// VFALCO End Clean stuff
DatabaseCon *mRpcDB, *mTxnDB, *mLedgerDB, *mWalletDB, *mNetNodeDB, *mPathFindDB, *mHashNodeDB;
leveldb::DB *mHashNodeLDB;
leveldb::DB *mEphemeralLDB;
PeerDoor* mPeerDoor;
RPCDoor* mRPCDoor;
WSDoor* mWSPublicDoor;
WSDoor* mWSPrivateDoor;
boost::asio::deadline_timer mSweepTimer;
std::map<std::string, Peer::pointer> mPeerMap;
boost::recursive_mutex mPeerMapLock;
volatile bool mShutdown;
};
Application::Application ()
: mIOService ((theConfig.NODE_SIZE >= 2) ? 2 : 1)
@@ -568,4 +666,143 @@ bool serverOkay(std::string& reason)
return true;
}
// vim:ts=4
//VFALCO TODO clean this up since it is just a file holding a single member function definition
static std::vector<std::string> getSchema(DatabaseCon* dbc, const std::string& dbName)
{
std::vector<std::string> schema;
std::string sql = "SELECT sql FROM sqlite_master WHERE tbl_name='";
sql += dbName;
sql += "';";
SQL_FOREACH(dbc->getDB(), sql)
{
dbc->getDB()->getStr("sql", sql);
schema.push_back(sql);
}
return schema;
}
static bool schemaHas(DatabaseCon* dbc, const std::string& dbName, int line, const std::string& content)
{
std::vector<std::string> schema = getSchema(dbc, dbName);
if (static_cast<int>(schema.size()) <= line)
{
Log(lsFATAL) << "Schema for " << dbName << " has too few lines";
throw std::runtime_error("bad schema");
}
return schema[line].find(content) != std::string::npos;
}
static void addTxnSeqField()
{
if (schemaHas(theApp->getTxnDB(), "AccountTransactions", 0, "TxnSeq"))
return;
Log(lsWARNING) << "Transaction sequence field is missing";
Database* db = theApp->getTxnDB()->getDB();
std::vector< std::pair<uint256, int> > txIDs;
txIDs.reserve(300000);
Log(lsINFO) << "Parsing transactions";
int i = 0;
uint256 transID;
SQL_FOREACH(db, "SELECT TransID,TxnMeta FROM Transactions;")
{
Blob rawMeta;
int metaSize = 2048;
rawMeta.resize(metaSize);
metaSize = db->getBinary("TxnMeta", &*rawMeta.begin(), rawMeta.size());
if (metaSize > static_cast<int>(rawMeta.size()))
{
rawMeta.resize(metaSize);
db->getBinary("TxnMeta", &*rawMeta.begin(), rawMeta.size());
}
else rawMeta.resize(metaSize);
std::string tid;
db->getStr("TransID", tid);
transID.SetHex(tid, true);
if (rawMeta.size() == 0)
{
txIDs.push_back(std::make_pair(transID, -1));
Log(lsINFO) << "No metadata for " << transID;
}
else
{
TransactionMetaSet m(transID, 0, rawMeta);
txIDs.push_back(std::make_pair(transID, m.getIndex()));
}
if ((++i % 1000) == 0)
Log(lsINFO) << i << " transactions read";
}
Log(lsINFO) << "All " << i << " transactions read";
db->executeSQL("BEGIN TRANSACTION;");
Log(lsINFO) << "Dropping old index";
db->executeSQL("DROP INDEX AcctTxIndex;");
Log(lsINFO) << "Altering table";
db->executeSQL("ALTER TABLE AccountTransactions ADD COLUMN TxnSeq INTEGER;");
typedef std::pair<uint256, int> u256_int_pair_t;
boost::format fmt("UPDATE AccountTransactions SET TxnSeq = %d WHERE TransID = '%s';");
i = 0;
BOOST_FOREACH(u256_int_pair_t& t, txIDs)
{
db->executeSQL(boost::str(fmt % t.second % t.first.GetHex()));
if ((++i % 1000) == 0)
Log(lsINFO) << i << " transactions updated";
}
Log(lsINFO) << "Building new index";
db->executeSQL("CREATE INDEX AcctTxIndex ON AccountTransactions(Account, LedgerSeq, TxnSeq, TransID);");
db->executeSQL("END TRANSACTION;");
}
void Application::updateTables(bool ldbImport)
{ // perform any needed table updates
assert(schemaHas(theApp->getTxnDB(), "AccountTransactions", 0, "TransID"));
assert(!schemaHas(theApp->getTxnDB(), "AccountTransactions", 0, "foobar"));
addTxnSeqField();
if (schemaHas(theApp->getTxnDB(), "AccountTransactions", 0, "PRIMARY"))
{
Log(lsFATAL) << "AccountTransactions database should not have a primary key";
StopSustain();
exit(1);
}
if (theApp->getHashedObjectStore().isLevelDB())
{
boost::filesystem::path hashPath = theConfig.DATA_DIR / "hashnode.db";
if (boost::filesystem::exists(hashPath))
{
if (theConfig.LDB_IMPORT)
{
Log(lsWARNING) << "Importing SQLite -> LevelDB";
theApp->getHashedObjectStore().import(hashPath.string());
Log(lsWARNING) << "Remove or remname the hashnode.db file";
}
else
{
Log(lsWARNING) << "SQLite hashnode database exists. Please either remove or import";
Log(lsWARNING) << "To import, start with the '--import' option. Otherwise, remove hashnode.db";
StopSustain();
exit(1);
}
}
}
}
IApplication* IApplication::New ()
{
return new Application;
}

View File

@@ -3,6 +3,7 @@
/** Persistency layer for hashed objects.
*/
// VFALCO TODO Move all definitions to the .cpp
class HashedObjectStore
{
public:

View File

@@ -0,0 +1,111 @@
#ifndef RIPPLE_IAPPLICATION_H
#define RIPPLE_IAPPLICATION_H
// VFALCO TODO Replace these with beast "unsigned long long" generators
// VFALCO NOTE Apparently these are used elsewhere. Make them constants in the config
// or in the IApplication
//
#define SYSTEM_CURRENCY_GIFT 1000ull
#define SYSTEM_CURRENCY_USERS 100000000ull
#define SYSTEM_CURRENCY_PARTS 1000000ull // 10^SYSTEM_CURRENCY_PRECISION
#define SYSTEM_CURRENCY_START (SYSTEM_CURRENCY_GIFT*SYSTEM_CURRENCY_USERS*SYSTEM_CURRENCY_PARTS)
// VFALCO TODO Fix forward declares required for header dependency loops
class IFeatures;
class IFeeVote;
class IHashRouter;
class ILoadFeeTrack;
class IPeers;
class IProofOfWorkFactory;
class IUniqueNodeList;
class IValidations;
class HashedObjectStore;
class JobQueue;
class LedgerAcquireMaster;
class LedgerMaster;
class LoadManager;
class NetworkOPs;
class OrderBookDB;
class PeerDoor;
class SerializedLedgerEntry;
class TransactionMaster;
class TXQueue;
class Wallet;
class DatabaseCon;
typedef TaggedCache <uint256, Blob , UptimeTimerAdapter> NodeCache;
typedef TaggedCache <uint256, SerializedLedgerEntry, UptimeTimerAdapter> SLECache;
class IApplication
{
public:
static IApplication* New ();
virtual ~IApplication () { }
/* VFALCO NOTE
The master lock protects:
- The open ledger
- Server global state
* What the last closed ledger is
* State of the consensus engine
other things
*/
virtual boost::recursive_mutex& getMasterLock () = 0;
virtual boost::asio::io_service& getIOService () = 0;
virtual boost::asio::io_service& getAuxService () = 0;
virtual NodeCache& getTempNodeCache () = 0;
virtual SLECache& getSLECache () = 0;
virtual IFeatures& getFeatureTable () = 0;
virtual IFeeVote& getFeeVote () = 0;
virtual IHashRouter& getHashRouter () = 0;
virtual ILoadFeeTrack& getFeeTrack () = 0;
virtual IPeers& getPeers () = 0;
virtual IProofOfWorkFactory& getProofOfWorkFactory () = 0;
virtual IUniqueNodeList& getUNL () = 0;
virtual IValidations& getValidations () = 0;
virtual HashedObjectStore& getHashedObjectStore () = 0;
virtual JobQueue& getJobQueue () = 0;
virtual LedgerAcquireMaster& getMasterLedgerAcquire () = 0;
virtual LedgerMaster& getLedgerMaster () = 0;
virtual LoadManager& getLoadManager () = 0;
virtual NetworkOPs& getOPs () = 0;
virtual OrderBookDB& getOrderBookDB () = 0;
virtual PeerDoor& getPeerDoor () = 0;
virtual TransactionMaster& getMasterTransaction () = 0;
virtual TXQueue& getTxnQueue () = 0;
virtual Wallet& getWallet () = 0;
virtual DatabaseCon* getRpcDB () = 0;
virtual DatabaseCon* getTxnDB () = 0;
virtual DatabaseCon* getLedgerDB () = 0;
virtual DatabaseCon* getWalletDB () = 0;
virtual DatabaseCon* getNetNodeDB () = 0;
virtual DatabaseCon* getPathFindDB () = 0;
virtual DatabaseCon* getHashNodeDB () = 0;
virtual leveldb::DB* getHashNodeLDB () = 0;
virtual leveldb::DB* getEphemeralLDB () = 0;
virtual bool getSystemTimeOffset (int& offset) = 0;
virtual bool isShutdown () = 0;
virtual bool running () = 0;
virtual void setup () = 0;
virtual void run () = 0;
virtual void stop () = 0;
virtual void sweep () = 0;
};
extern IApplication* theApp;
#endif
// vim:ts=4

View File

@@ -10,7 +10,7 @@
// code assumes this node is synched (and will continue to do so until
// there's a functional network.
DECLARE_INSTANCE(InfoSub);
DECLARE_INSTANCE (InfoSub);
// VFALCO TODO Figure out how to clean up these globals
uint64 InfoSub::sSeq = 0;
@@ -54,17 +54,17 @@ void InfoSub::insertSubAccountInfo (RippleAddress addr, uint32 uLedgerIndex)
mSubAccountInfo.insert(addr);
}
void InfoSub::clearPFRequest()
void InfoSub::clearPathRequest()
{
mPFRequest.reset();
mPathRequest.reset();
}
void InfoSub::setPFRequest(const boost::shared_ptr<PFRequest>& req)
void InfoSub::setPathRequest(const boost::shared_ptr<PathRequest>& req)
{
mPFRequest = req;
mPathRequest = req;
}
const boost::shared_ptr<PFRequest>& InfoSub::getPFRequest()
const boost::shared_ptr<PathRequest>& InfoSub::getPathRequest()
{
return mPFRequest;
return mPathRequest;
}

View File

@@ -4,11 +4,10 @@
// Operations that clients may wish to perform against the network
// Master operational handler, server sequencer, network tracker
class PFRequest;
class PathRequest;
DEFINE_INSTANCE(InfoSub);
// VFALCO TODO Move InfoSub to a separate file
class InfoSub : public IS_INSTANCE(InfoSub)
{
public:
@@ -35,23 +34,24 @@ public:
void insertSubAccountInfo (RippleAddress addr, uint32 uLedgerIndex);
void clearPFRequest();
void clearPathRequest();
void setPFRequest (const boost::shared_ptr<PFRequest>& req);
void setPathRequest (const boost::shared_ptr<PathRequest>& req);
boost::shared_ptr <PFRequest> const& getPFRequest ();
boost::shared_ptr <PathRequest> const& getPathRequest ();
protected:
// VFALCO TODO make accessor for this member
boost::mutex mLockInfo;
private:
// VFALCO TODO Move these globals to class instance
static uint64 sSeq;
static boost::mutex sSeqLock;
boost::unordered_set<RippleAddress> mSubAccountInfo;
boost::unordered_set<RippleAddress> mSubAccountTransaction;
boost::shared_ptr <PFRequest> mPFRequest;
boost::unordered_set <RippleAddress> mSubAccountInfo;
boost::unordered_set <RippleAddress> mSubAccountTransaction;
boost::shared_ptr <PathRequest> mPathRequest;
uint64 mSeq;
};

View File

@@ -215,10 +215,8 @@ void JobQueue::IOThread(boost::mutex::scoped_lock& sl)
// do jobs until asked to stop
void JobQueue::threadEntry()
{
// VFALCO TODO Replace this mutex nonsense
//
boost::mutex::scoped_lock sl(mJobLock);
while (1)
{
setCallingThreadName("waiting");

View File

@@ -1,7 +1,3 @@
//#include <boost/test/unit_test.hpp>
//#include <boost/thread.hpp>
//#include <boost/date_time/posix_time/posix_time.hpp>
//#include "Application.h"
class LoadFeeTrack : public ILoadFeeTrack
{

View File

@@ -1,35 +1,30 @@
#include "PFRequest.h"
SETUP_LOG (PathRequest)
#include "RPCErr.h"
#include "Ledger.h"
#include "Application.h"
#include "Pathfinder.h"
#include "RippleCalc.h"
// VFALCO TODO Move these globals into a PathRequests collection inteface
boost::recursive_mutex PathRequest::sLock;
std::set <PathRequest::wptr> PathRequest::sRequests;
SETUP_LOG (PFRequest)
boost::recursive_mutex PFRequest::sLock;
std::set<PFRequest::wptr> PFRequest::sRequests;
PFRequest::PFRequest(const boost::shared_ptr<InfoSub>& subscriber) :
wpSubscriber(subscriber), jvStatus(Json::objectValue), bValid(false), bNew(true)
PathRequest::PathRequest (const boost::shared_ptr<InfoSub>& subscriber)
: wpSubscriber (subscriber)
, jvStatus (Json::objectValue)
, bValid (false)
, bNew (true)
{
;
}
bool PFRequest::isValid()
bool PathRequest::isValid()
{
boost::recursive_mutex::scoped_lock sl(mLock);
return bValid;
}
bool PFRequest::isNew()
bool PathRequest::isNew()
{
boost::recursive_mutex::scoped_lock sl(mLock);
return bNew;
}
bool PFRequest::isValid(Ledger::ref lrLedger)
bool PathRequest::isValid(Ledger::ref lrLedger)
{
boost::recursive_mutex::scoped_lock sl(mLock);
bValid = raSrcAccount.isSet() && raDstAccount.isSet() && saDstAmount.isPositive();
@@ -74,7 +69,7 @@ bool PFRequest::isValid(Ledger::ref lrLedger)
return bValid;
}
Json::Value PFRequest::doCreate(Ledger::ref lrLedger, const Json::Value& value)
Json::Value PathRequest::doCreate(Ledger::ref lrLedger, const Json::Value& value)
{
assert(lrLedger->isClosed());
@@ -98,9 +93,9 @@ Json::Value PFRequest::doCreate(Ledger::ref lrLedger, const Json::Value& value)
if (mValid)
{
WriteLog (lsINFO, PFRequest) << "Request created: " << raSrcAccount.humanAccountID() <<
WriteLog (lsINFO, PathRequest) << "Request created: " << raSrcAccount.humanAccountID() <<
" -> " << raDstAccount.humanAccountID();
WriteLog (lsINFO, PFRequest) << "Deliver: " << saDstAmount.getFullText();
WriteLog (lsINFO, PathRequest) << "Deliver: " << saDstAmount.getFullText();
boost::recursive_mutex::scoped_lock sl(sLock);
sRequests.insert(shared_from_this());
@@ -109,7 +104,7 @@ Json::Value PFRequest::doCreate(Ledger::ref lrLedger, const Json::Value& value)
return jvStatus;
}
int PFRequest::parseJson(const Json::Value& jvParams, bool complete)
int PathRequest::parseJson(const Json::Value& jvParams, bool complete)
{
int ret = PFR_PJ_NOCHANGE;
@@ -194,19 +189,19 @@ int PFRequest::parseJson(const Json::Value& jvParams, bool complete)
return ret;
}
Json::Value PFRequest::doClose(const Json::Value&)
Json::Value PathRequest::doClose(const Json::Value&)
{
boost::recursive_mutex::scoped_lock sl(mLock);
return jvStatus;
}
Json::Value PFRequest::doStatus(const Json::Value&)
Json::Value PathRequest::doStatus(const Json::Value&)
{
boost::recursive_mutex::scoped_lock sl(mLock);
return jvStatus;
}
bool PFRequest::doUpdate(RLCache::ref cache, bool fast)
bool PathRequest::doUpdate(RLCache::ref cache, bool fast)
{
boost::recursive_mutex::scoped_lock sl(mLock);
jvStatus = Json::objectValue;
@@ -246,13 +241,13 @@ bool PFRequest::doUpdate(RLCache::ref cache, bool fast)
{
{
STAmount test(currIssuer.first, currIssuer.second, 1);
WriteLog (lsDEBUG, PFRequest) << "Trying to find paths: " << test.getFullText();
WriteLog (lsDEBUG, PathRequest) << "Trying to find paths: " << test.getFullText();
}
bool valid;
STPathSet spsPaths;
Pathfinder pf(cache, raSrcAccount, raDstAccount,
currIssuer.first, currIssuer.second, saDstAmount, valid);
CondLog (!valid, lsINFO, PFRequest) << "PF request not valid";
CondLog (!valid, lsINFO, PathRequest) << "PF request not valid";
if (valid && pf.findPaths(theConfig.PATH_SEARCH_SIZE - (fast ? 0 : 1), 3, spsPaths))
{
LedgerEntrySet lesSandbox(cache->getLedger(), tapNONE);
@@ -263,7 +258,7 @@ bool PFRequest::doUpdate(RLCache::ref cache, bool fast)
currIssuer.second.isNonZero() ? currIssuer.second :
(currIssuer.first.isZero() ? ACCOUNT_XRP : raSrcAccount.getAccountID()), 1);
saMaxAmount.negate();
WriteLog (lsDEBUG, PFRequest) << "Paths found, calling rippleCalc";
WriteLog (lsDEBUG, PathRequest) << "Paths found, calling rippleCalc";
TER terResult = RippleCalc::rippleCalc(lesSandbox, saMaxAmountAct, saDstAmountAct,
vpsExpanded, saMaxAmount, saDstAmount, raDstAccount.getAccountID(), raSrcAccount.getAccountID(),
spsPaths, false, false, false, true);
@@ -276,19 +271,19 @@ bool PFRequest::doUpdate(RLCache::ref cache, bool fast)
}
else
{
WriteLog (lsINFO, PFRequest) << "rippleCalc returns " << transHuman(terResult);
WriteLog (lsINFO, PathRequest) << "rippleCalc returns " << transHuman(terResult);
}
}
else
{
WriteLog (lsINFO, PFRequest) << "No paths found";
WriteLog (lsINFO, PathRequest) << "No paths found";
}
}
jvStatus["alternatives"] = jvArray;
return true;
}
void PFRequest::updateAll(Ledger::ref ledger, bool newOnly)
void PathRequest::updateAll(Ledger::ref ledger, bool newOnly)
{
std::set<wptr> requests;
@@ -305,7 +300,7 @@ void PFRequest::updateAll(Ledger::ref ledger, bool newOnly)
BOOST_FOREACH(wref wRequest, requests)
{
bool remove = true;
PFRequest::pointer pRequest = wRequest.lock();
PathRequest::pointer pRequest = wRequest.lock();
if (pRequest && (!newOnly || pRequest->isNew()))
{
InfoSub::pointer ipSub = pRequest->wpSubscriber.lock();

View File

@@ -14,7 +14,6 @@
// A pathfinding request submitted by a client
// The request issuer must maintain a strong pointer
class Ledger;
class InfoSub;
class STAmount;
class RLCache;
@@ -24,17 +23,18 @@ class RLCache;
#define PFR_PJ_NOCHANGE 0
#define PFR_PJ_CHANGE 1
class PFRequest : public boost::enable_shared_from_this<PFRequest>
class PathRequest : public boost::enable_shared_from_this<PathRequest>
{
public:
typedef boost::weak_ptr<PFRequest> wptr;
typedef boost::shared_ptr<PFRequest> pointer;
typedef boost::weak_ptr<PathRequest> wptr;
typedef boost::shared_ptr<PathRequest> pointer;
typedef const pointer& ref;
typedef const wptr& wref;
typedef std::pair<uint160, uint160> currIssuer_t;
public:
PFRequest(const boost::shared_ptr<InfoSub>& subscriber);
// VFALCO TODO Break the cyclic dependency on InfoSub
explicit PathRequest (boost::shared_ptr <InfoSub> const& subscriber);
bool isValid(const boost::shared_ptr<Ledger>&);
bool isValid();

View File

@@ -1,9 +1,4 @@
#include <boost/foreach.hpp>
#include "Application.h"
#include "LedgerTiming.h"
class Validations;
SETUP_LOG (Validations)

View File

@@ -3,8 +3,8 @@
//
// VFALCO TODO Fix this right. It's not really needed
// to include this file, its a hack to keep
// __STDC_LIMIT_MACROS from generating redefinition warnings
// to include this file, its a hack to keep
// __STDC_LIMIT_MACROS from generating redefinition warnings
#include "websocketpp/src/rng/boost_rng.hpp"
// Must come first to prevent compile errors