PeerFinder fixes:

* Add Livecache property stream support
* Tidy up log output
* Move peer code to ripple_overlay module
* Remove or hide some Peer interfaces
* Fix asserts by removing isConnected which was not thread safe
This commit is contained in:
Vinnie Falco
2014-02-13 18:17:01 -08:00
parent 645b9a01c7
commit 5bb194cf89
28 changed files with 268 additions and 175 deletions

View File

@@ -95,8 +95,9 @@ SOURCES += \
../../src/ripple_data/ripple_data.cpp \
../../src/ripple_hyperleveldb/ripple_hyperleveldb.cpp \
../../src/ripple_leveldb/ripple_leveldb.cpp \
../../src/ripple_rpc/ripple_rpc.cpp \
../../src/ripple_net/ripple_net.cpp \
../../src/ripple_overlay/ripple_overlay.cpp \
../../src/ripple_rpc/ripple_rpc.cpp \
../../src/ripple_websocket/ripple_websocket.cpp
LIBS += \

View File

@@ -1132,30 +1132,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple_app\peers\PackedMessage.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\ripple_app\peers\PeerDoor.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\ripple_app\peers\PeerImp.h">
<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\ripple_app\peers\Peers.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\ripple_app\peers\PeerSet.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -1825,6 +1801,25 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple_overlay\impl\PackedMessage.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\ripple_overlay\impl\PeerDoor.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\ripple_overlay\impl\Peers.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\ripple_overlay\ripple_overlay.cpp" />
<ClCompile Include="..\..\src\ripple_rpc\impl\DoPrint.h">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
@@ -2500,11 +2495,7 @@
<ClInclude Include="..\..\src\ripple_app\paths\RippleCalc.h" />
<ClInclude Include="..\..\src\ripple_app\paths\RippleLineCache.h" />
<ClInclude Include="..\..\src\ripple_app\paths\RippleState.h" />
<ClInclude Include="..\..\src\ripple_app\peers\PackedMessage.h" />
<ClInclude Include="..\..\src\ripple_app\peers\PeerDoor.h" />
<ClInclude Include="..\..\src\ripple_app\peers\ClusterNodeStatus.h" />
<ClInclude Include="..\..\src\ripple_app\peers\Peers.h" />
<ClInclude Include="..\..\src\ripple_app\peers\Peer.h" />
<ClInclude Include="..\..\src\ripple_app\peers\PeerSet.h" />
<ClInclude Include="..\..\src\ripple_app\peers\UniqueNodeList.h" />
<ClInclude Include="..\..\src\ripple_app\ripple_app.h" />
@@ -2627,6 +2618,12 @@
<ClInclude Include="..\..\src\ripple_net\rpc\RPCErr.h" />
<ClInclude Include="..\..\src\ripple_net\rpc\RPCSub.h" />
<ClInclude Include="..\..\src\ripple_net\rpc\RPCUtil.h" />
<ClInclude Include="..\..\src\ripple_overlay\api\PackedMessage.h" />
<ClInclude Include="..\..\src\ripple_overlay\api\Peer.h" />
<ClInclude Include="..\..\src\ripple_overlay\api\Peers.h" />
<ClInclude Include="..\..\src\ripple_overlay\impl\PeerDoor.h" />
<ClInclude Include="..\..\src\ripple_overlay\impl\PeerImp.h" />
<ClInclude Include="..\..\src\ripple_overlay\ripple_overlay.h" />
<ClInclude Include="..\..\src\ripple_rpc\api\ErrorCodes.h" />
<ClInclude Include="..\..\src\ripple_rpc\api\Manager.h" />
<ClInclude Include="..\..\src\ripple_rpc\api\Request.h" />
@@ -2760,6 +2757,8 @@
<None Include="..\..\src\ripple\validators\README.md" />
<None Include="..\..\src\ripple_app\ledger\TODO.md" />
<None Include="..\..\src\ripple_app\TODO.md" />
<None Include="..\..\src\ripple_overlay\README.md" />
<None Include="..\..\src\ripple_overlay\TODO.md" />
<None Include="..\..\src\ripple_rpc\README.md" />
<None Include="..\..\src\ripple_rpc\TODO.md" />
<None Include="..\QtCreator\rippled.pro" />

View File

@@ -307,6 +307,15 @@
<Filter Include="[2] Old Ripple\ripple_rpc\impl">
<UniqueIdentifier>{b86f01de-f924-4584-bb22-d70280b224f3}</UniqueIdentifier>
</Filter>
<Filter Include="[2] Old Ripple\ripple_overlay">
<UniqueIdentifier>{75191c6f-e636-4314-8bee-0d6f40051390}</UniqueIdentifier>
</Filter>
<Filter Include="[2] Old Ripple\ripple_overlay\api">
<UniqueIdentifier>{92b0fcc6-acfc-4ede-90e1-8f39e87dee4c}</UniqueIdentifier>
</Filter>
<Filter Include="[2] Old Ripple\ripple_overlay\impl">
<UniqueIdentifier>{0ff855ac-5038-4b16-a324-ba85d782c0e2}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\ripple_basics\containers\RangeSet.cpp">
@@ -702,15 +711,9 @@
<ClCompile Include="..\..\src\ripple_app\paths\RippleState.cpp">
<Filter>[2] Old Ripple\ripple_app\paths</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple_app\peers\Peers.cpp">
<Filter>[2] Old Ripple\ripple_app\peers</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple_app\peers\UniqueNodeList.cpp">
<Filter>[2] Old Ripple\ripple_app\peers</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple_app\peers\PeerDoor.cpp">
<Filter>[2] Old Ripple\ripple_app\peers</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple_app\rpc\RPCHandler.cpp">
<Filter>[2] Old Ripple\ripple_app\rpc</Filter>
</ClCompile>
@@ -1077,9 +1080,6 @@
<ClCompile Include="..\..\src\ripple\sslutil\impl\DHUtil.cpp">
<Filter>[1] Ripple\sslutil\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple_app\peers\PackedMessage.cpp">
<Filter>[2] Old Ripple\ripple_app\peers</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple\types\impl\RippleIdentifierTests.cpp">
<Filter>[1] Ripple\types\impl</Filter>
</ClCompile>
@@ -1461,8 +1461,17 @@
<ClCompile Include="..\..\src\ripple\peerfinder\impl\SlotImp.h">
<Filter>[1] Ripple\peerfinder\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple_app\peers\PeerImp.h">
<Filter>[2] Old Ripple\ripple_app\peers</Filter>
<ClCompile Include="..\..\src\ripple_overlay\impl\PeerDoor.cpp">
<Filter>[2] Old Ripple\ripple_overlay\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple_overlay\impl\Peers.cpp">
<Filter>[2] Old Ripple\ripple_overlay\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple_overlay\impl\PackedMessage.cpp">
<Filter>[2] Old Ripple\ripple_overlay\impl</Filter>
</ClCompile>
<ClCompile Include="..\..\src\ripple_overlay\ripple_overlay.cpp">
<Filter>[2] Old Ripple\ripple_overlay</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
@@ -1910,12 +1919,6 @@
<ClInclude Include="..\..\src\ripple_app\paths\RippleState.h">
<Filter>[2] Old Ripple\ripple_app\paths</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_app\peers\PeerDoor.h">
<Filter>[2] Old Ripple\ripple_app\peers</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_app\peers\Peer.h">
<Filter>[2] Old Ripple\ripple_app\peers</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_app\peers\UniqueNodeList.h">
<Filter>[2] Old Ripple\ripple_app\peers</Filter>
</ClInclude>
@@ -2009,9 +2012,6 @@
<ClInclude Include="..\..\src\ripple_app\websocket\WSServerHandler.h">
<Filter>[2] Old Ripple\ripple_app\websocket</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_app\peers\Peers.h">
<Filter>[2] Old Ripple\ripple_app\peers</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_app\main\LoadManager.h">
<Filter>[2] Old Ripple\ripple_app\main</Filter>
</ClInclude>
@@ -2409,9 +2409,6 @@
<ClInclude Include="..\..\src\ripple\sslutil\api\DHUtil.h">
<Filter>[1] Ripple\sslutil\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_app\peers\PackedMessage.h">
<Filter>[2] Old Ripple\ripple_app\peers</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\types\api\RipplePublicKey.h">
<Filter>[1] Ripple\types\api</Filter>
</ClInclude>
@@ -3021,6 +3018,24 @@
<ClInclude Include="..\..\src\ripple\peerfinder\impl\Fixed.h">
<Filter>[1] Ripple\peerfinder\impl</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_overlay\impl\PeerDoor.h">
<Filter>[2] Old Ripple\ripple_overlay\impl</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_overlay\impl\PeerImp.h">
<Filter>[2] Old Ripple\ripple_overlay\impl</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_overlay\api\Peer.h">
<Filter>[2] Old Ripple\ripple_overlay\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_overlay\api\Peers.h">
<Filter>[2] Old Ripple\ripple_overlay\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_overlay\api\PackedMessage.h">
<Filter>[2] Old Ripple\ripple_overlay\api</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple_overlay\ripple_overlay.h">
<Filter>[2] Old Ripple\ripple_overlay</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<CustomBuild Include="..\..\src\ripple_data\protocol\ripple.proto">
@@ -3142,6 +3157,12 @@
<None Include="..\..\src\ripple_rpc\TODO.md">
<Filter>[2] Old Ripple\ripple_rpc</Filter>
</None>
<None Include="..\..\src\ripple_overlay\README.md">
<Filter>[2] Old Ripple\ripple_overlay</Filter>
</None>
<None Include="..\..\src\ripple_overlay\TODO.md">
<Filter>[2] Old Ripple\ripple_overlay</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Text Include="..\..\doc\todo\NIKB_TODO.txt">

View File

@@ -213,6 +213,7 @@ COMPILED_FILES.extend([
'src/ripple_hyperleveldb/ripple_hyperleveldb.cpp',
'src/ripple_leveldb/ripple_leveldb.cpp',
'src/ripple_net/ripple_net.cpp',
'src/ripple_overlay/ripple_overlay.cpp',
'src/ripple_rpc/ripple_rpc.cpp',
'src/ripple_websocket/ripple_websocket.cpp'
])

View File

@@ -29,8 +29,7 @@ struct Endpoint
Endpoint ();
int hops;
IPAddress address;
std::string features;
IP::Endpoint address;
};
}

View File

@@ -44,7 +44,7 @@ public:
, m_acceptCount (0)
, m_closingCount (0)
{
#if 0
#if 1
std::random_device rd;
std::mt19937 gen (rd());
m_roundingThreshold =
@@ -210,20 +210,6 @@ public:
//--------------------------------------------------------------------------
/** Returns the number of new connection attempts we should make. */
int additionalAttemptsNeeded () const
{
// Don't go over the maximum concurrent attempt limit
if (m_attempts >= Tuning::maxConnectAttempts)
return 0;
int needed (outboundSlotsFree ());
// This is the most we could attempt right now
int const available (
Tuning::maxConnectAttempts - m_attempts);
//return std::min (needed, available);
return available;
}
/** Returns true if the slot logic considers us "connected" to the network. */
bool isConnectedToNetwork () const
{

View File

@@ -58,7 +58,7 @@ public:
};
typedef std::set <Endpoint, LessEndpoints> SortedTable;
typedef std::unordered_map <IPAddress, Entry> AddressTable;
typedef std::unordered_map <IP::Endpoint, Entry> AddressTable;
clock_type& m_clock;
Journal m_journal;
@@ -118,7 +118,7 @@ public:
{
if (m_journal.debug) m_journal.debug << leftw (18) <<
"Livecache expired " << count <<
((count > 1) ? "entries" : "entry");
((count > 1) ? " entries" : " entry");
}
}
@@ -163,7 +163,6 @@ public:
" at hops " << endpoint.hops;
}
entry.endpoint.features = endpoint.features;
entry.whenExpires = whenExpires;
m_list.erase (m_list.iterator_to(entry));
@@ -246,6 +245,24 @@ public:
++h[iter->endpoint.hops];
return h;
}
/** Output statistics. */
void onWrite (PropertyStream::Map& map)
{
clock_type::time_point const now (m_clock.now ());
map ["size"] = size ();
PropertyStream::Set set ("entries", map);
for (auto entry : m_byAddress)
{
PropertyStream::Map item (set);
Entry const& e (entry.second);
item ["hops"] = e.endpoint.hops;
item ["address"] = e.endpoint.address.to_string ();
std::stringstream ss;
ss << e.whenExpires - now;
item ["expires"] = ss.str();
}
}
};
}

View File

@@ -1110,7 +1110,6 @@ public:
ep.hops = 0;
ep.address = IPAddress (
IP::AddressV4 ()).at_port (state->config.listeningPort);
ep.features = state->config.features;
return ep;
}
@@ -1360,7 +1359,6 @@ public:
// VFALCO NOTE These ugly casts are needed because
// of how std::size_t is declared on some linuxes
//
map ["livecache"] = uint32 (state->livecache.size());
map ["bootcache"] = uint32 (state->bootcache.size());
map ["fixed"] = uint32 (state->fixed.size());
@@ -1379,6 +1377,11 @@ public:
state->config.onWrite (child);
}
{
PropertyStream::Map child ("livecache", map);
state->livecache.onWrite (child);
}
{
PropertyStream::Map child ("bootcache", map);
state->bootcache.onWrite (child);

View File

@@ -1257,21 +1257,18 @@ bool NetworkOPsImp::checkLastClosedLedger (const Peers::PeerSequence& peerList,
ourVC.highNodeUsing = ourAddress;
}
BOOST_FOREACH (Peer::ref it, peerList)
BOOST_FOREACH (Peer::ref peer, peerList)
{
if (it && it->isConnected ())
uint256 peerLedger = peer->getClosedLedgerHash ();
if (peerLedger.isNonZero ())
{
uint256 peerLedger = it->getClosedLedgerHash ();
ValidationCount& vc = ledgers[peerLedger];
if (peerLedger.isNonZero ())
{
ValidationCount& vc = ledgers[peerLedger];
if ((vc.nodesUsing == 0) || (peer->getNodePublic ().getNodeID () > vc.highNodeUsing))
vc.highNodeUsing = peer->getNodePublic ().getNodeID ();
if ((vc.nodesUsing == 0) || (it->getNodePublic ().getNodeID () > vc.highNodeUsing))
vc.highNodeUsing = it->getNodePublic ().getNodeID ();
++vc.nodesUsing;
}
++vc.nodesUsing;
}
}

View File

@@ -20,6 +20,8 @@
#ifndef RIPPLE_POWRESULT_H_INCLUDED
#define RIPPLE_POWRESULT_H_INCLUDED
namespace ripple {
enum PowResult
{
powOK = 0,
@@ -30,4 +32,6 @@ enum PowResult
powTOOEASY = 5, // the difficulty increased too much while you solved it
};
}
#endif

View File

@@ -20,6 +20,10 @@
#ifndef RIPPLE_PROOFOFWORK_H
#define RIPPLE_PROOFOFWORK_H
#include "PowResult.h"
namespace ripple {
class ProofOfWork : LeakChecked <ProofOfWork>
{
public:
@@ -73,6 +77,7 @@ private:
static const int maxIterations;
};
}
#endif
// vim:ts=4

View File

@@ -20,6 +20,11 @@
#ifndef RIPPLE_PROOFOFWORKFACTORY_H_INCLUDED
#define RIPPLE_PROOFOFWORKFACTORY_H_INCLUDED
#include "PowResult.h"
#include "ProofOfWork.h"
namespace ripple {
class ProofOfWorkFactory
{
public:
@@ -51,4 +56,6 @@ public:
virtual void setSecret (uint256 const& secret) = 0;
};
}
#endif

View File

@@ -48,6 +48,7 @@
# include "main/CollectorManager.h"
#include "main/CollectorManager.cpp"
#include "misc/ProofOfWorkFactory.h"
namespace ripple {
# include "main/NodeStoreScheduler.h"
@@ -60,9 +61,8 @@ namespace ripple {
#include "main/FatalErrorReporter.cpp"
# include "rpc/RPCHandler.h"
# include "misc/PowResult.h"
# include "misc/ProofOfWork.h"
# include "misc/ProofOfWorkFactory.h"
}
namespace ripple {
#include "rpc/RPCHandler.cpp"
# include "rpc/RPCServerHandler.h"

View File

@@ -59,18 +59,14 @@
//#include "beast/modules/beast_sqdb/beast_sqdb.h"
#include "beast/modules/beast_sqlite/beast_sqlite.h"
// VFALCO NOTE If we forward declare PackedMessage and write out shared_ptr
// instead of using the in-class typedef, we can remove the entire
// ripple.pb.h from the main headers.
//
#include "peers/PackedMessage.h"
// Order matters here. If you get compile errors,
// reorder the include lines until the order is correct.
#include "../../ripple/common/KeyCache.h"
#include "../../ripple/common/TaggedCache.h"
#include "../../ripple_overlay/ripple_overlay.h"
namespace ripple {
#include "data/Database.h"
#include "data/DatabaseCon.h"
@@ -103,11 +99,6 @@ namespace ripple {
#include "misc/IFeatures.h"
#include "misc/IFeeVote.h"
#include "misc/IHashRouter.h"
}
// escape the ripple namespace
#include "peers/Peer.h"
#include "peers/Peers.h"
namespace ripple {
#include "peers/ClusterNodeStatus.h"
#include "peers/UniqueNodeList.h"
#include "misc/Validations.h"

View File

@@ -28,14 +28,14 @@
#include "../ripple/validators/ripple_validators.h"
namespace ripple
{
#include "misc/PowResult.h"
#include "misc/ProofOfWorkFactory.h"
namespace ripple {
#include "peers/PeerSet.cpp"
#include "misc/OrderBook.cpp"
# include "misc/PowResult.h"
# include "misc/ProofOfWork.h"
# include "misc/ProofOfWorkFactory.h"
#include "misc/ProofOfWorkFactory.cpp"
#include "misc/ProofOfWork.cpp"
#include "misc/SerializedTransaction.cpp"

View File

@@ -31,6 +31,8 @@
#include <deque>
#include "misc/ProofOfWork.h"
namespace ripple {
#include "ledger/LedgerTiming.cpp"
@@ -40,11 +42,4 @@ namespace ripple {
#include "tx/OfferCreateTransactor.cpp"
#include "tx/WalletAddTransactor.cpp"
#include "misc/FeeVote.cpp"
# include "misc/PowResult.h"
# include "misc/ProofOfWork.h"
# include "misc/ProofOfWorkFactory.h"
#include "peers/PackedMessage.cpp"
}
#include "peers/PeerDoor.cpp"
#include "peers/Peers.cpp"

View File

@@ -0,0 +1,4 @@
# Overlay
A module which manages peer connections that operate the _Ripple
peer protocol_.

View File

@@ -0,0 +1 @@
# Overlay

View File

@@ -17,8 +17,8 @@
*/
//==============================================================================
#ifndef RIPPLE_PACKEDMESSAGE_H_INCLUDED
#define RIPPLE_PACKEDMESSAGE_H_INCLUDED
#ifndef RIPPLE_OVERLAY_PACKEDMESSAGE_H_INCLUDED
#define RIPPLE_OVERLAY_PACKEDMESSAGE_H_INCLUDED
#include "ripple.pb.h"
@@ -28,6 +28,11 @@
namespace ripple {
// VFALCO NOTE If we forward declare PackedMessage and write out shared_ptr
// instead of using the in-class typedef, we can remove the entire
// ripple.pb.h from the main headers.
//
// packaging of messages into length/type-prepended buffers
// ready for transmission.
//

View File

@@ -17,8 +17,10 @@
*/
//==============================================================================
#ifndef RIPPLE_PEER_H_INCLUDED
#define RIPPLE_PEER_H_INCLUDED
#ifndef RIPPLE_OVERLAY_PEER_H_INCLUDED
#define RIPPLE_OVERLAY_PEER_H_INCLUDED
#include <boost/asio.hpp>
namespace ripple {
@@ -51,45 +53,8 @@ public:
*/
typedef uint32 ShortId;
/** Current state */
enum State
{
/** An connection is being established (outbound) */
stateConnecting
/** Connection has been successfully established */
,stateConnected
/** Handshake has been received from this peer */
,stateHandshaked
/** Running the Ripple protocol actively */
,stateActive
/** Gracefully closing */
,stateGracefulClose
};
public:
//--------------------------------------------------------------------------
/** Called when an open slot is assigned to a handshaked peer. */
virtual void activate () = 0;
//--------------------------------------------------------------------------
//virtual void connect (IP::Endpoint const &address) = 0;
//--------------------------------------------------------------------------
virtual State state () const = 0;
virtual void state (State new_state) = 0;
//--------------------------------------------------------------------------
//virtual void detach (const char*, bool onIOStrand) = 0;
virtual void sendPacket (const PackedMessage::pointer& packet, bool onStrand) = 0;
// VFALCO NOTE what's with this odd parameter passing? Why the static member?
//
/** Adjust this peer's load balance based on the type of load imposed.
@note Formerly named punishPeer
@@ -105,10 +70,6 @@ public:
virtual std::string getClusterNodeName() const = 0;
virtual bool isInbound () const = 0;
virtual bool isOutbound () const = 0;
virtual uint256 const& getClosedLedgerHash () const = 0;
virtual bool hasLedger (uint256 const& hash, uint32 seq) const = 0;
@@ -136,12 +97,6 @@ public:
virtual NativeSocketType& getNativeSocket () = 0;
};
std::string to_string (Peer const& peer);
std::ostream& operator<< (std::ostream& os, Peer const& peer);
std::string to_string (Peer const* peer);
std::ostream& operator<< (std::ostream& os, Peer const* peer);
}
#endif

View File

@@ -22,6 +22,12 @@
// VFALCO TODO Remove this include dependency it shouldn't be needed
#include "../../ripple/peerfinder/api/Slot.h"
#include "../../ripple/common/Resolver.h"
#include <set>
#include <boost/asio.hpp>
#include <boost/asio/ssl.hpp>
namespace ripple {
@@ -271,7 +277,7 @@ struct peer_in_cluster
/** Select all peers that are in the specified set */
struct peer_in_set
{
std::set<Peer::ShortId> const& peerSet;
std::set <Peer::ShortId> const& peerSet;
peer_in_set (std::set<Peer::ShortId> const& peers)
: peerSet (peers)

View File

@@ -17,6 +17,8 @@
*/
//==============================================================================
namespace ripple {
PackedMessage::PackedMessage (::google::protobuf::Message const& message, int type)
{
unsigned const messageBytes = message.ByteSize ();
@@ -85,3 +87,5 @@ void PackedMessage::encodeHeader (unsigned size, int type)
mBuffer[4] = static_cast<boost::uint8_t> ((type >> 8) & 0xFF);
mBuffer[5] = static_cast<boost::uint8_t> (type & 0xFF);
}
}

View File

@@ -24,6 +24,12 @@ namespace ripple {
class PeerImp;
std::string to_string (Peer const& peer);
std::ostream& operator<< (std::ostream& os, Peer const& peer);
std::string to_string (Peer const* peer);
std::ostream& operator<< (std::ostream& os, Peer const* peer);
std::string to_string (PeerImp const& peer);
std::ostream& operator<< (std::ostream& os, PeerImp const& peer);
@@ -74,6 +80,25 @@ private:
static const size_t sslMinimumFinishedLength = 12;
public:
/** Current state */
enum State
{
/** An connection is being established (outbound) */
stateConnecting
/** Connection has been successfully established */
,stateConnected
/** Handshake has been received from this peer */
,stateHandshaked
/** Running the Ripple protocol actively */
,stateActive
/** Gracefully closing */
,stateGracefulClose
};
typedef boost::shared_ptr <PeerImp> ptr;
boost::shared_ptr <NativeSocketType> m_shared_socket;
@@ -217,12 +242,13 @@ public:
static char const* getCountedObjectName () { return "Peer"; }
//--------------------------------------------------------------------------
Peer::State state() const
State state() const
{
return m_state;
}
void state(Peer::State new_state)
void state (State new_state)
{
m_state = new_state;
}
@@ -404,7 +430,6 @@ public:
}
/** Indicates that the peer must be activated.
A peer is activated after the handshake is completed and if it is not
a second connection from a peer that we already have. Once activated
the peer transitions to `stateActive` and begins operating.
@@ -544,14 +569,6 @@ public:
{
return m_clusterNode;
}
bool isInbound () const
{
return m_inbound;
}
bool isOutbound () const
{
return !m_inbound;
}
uint256 const& getClosedLedgerHash () const
{
@@ -2096,6 +2113,8 @@ private:
uint256 response;
memcpy (response.begin (), packet.response ().data (), 256 / 8);
// VFALCO TODO Use a dependency injection here
PowResult r = getApp().getProofOfWorkFactory ().checkProof (packet.token (), response);
if (r == powOK)
@@ -2768,6 +2787,7 @@ std::ostream& operator<< (std::ostream& os, PeerImp const* peer)
}
//------------------------------------------------------------------------------
std::string to_string (Peer const& peer)
{
if (peer.isInCluster())

View File

@@ -20,6 +20,8 @@
#include "PeerDoor.h"
#include "PeerImp.h"
#include "../../ripple/common/seconds_clock.h"
#include <boost/config.hpp>
#include <condition_variable>
#include <mutex>

View File

@@ -0,0 +1,35 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include "BeastConfig.h"
#include "ripple_overlay.h"
#include "../ripple_app/ripple_app.h"
#include "../ripple/validators/ripple_validators.h"
#include "../ripple/peerfinder/ripple_peerfinder.h"
#include "../ripple_app/misc/ProofOfWork.h"
#include "../ripple_app/misc/ProofOfWorkFactory.h"
#include "impl/PackedMessage.cpp"
#include "impl/PeerImp.h"
#include "impl/PeerDoor.cpp"
#include "impl/Peers.cpp"

View File

@@ -0,0 +1,35 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef RIPPLE_OVERLAY_H_INCLUDED
#define RIPPLE_OVERLAY_H_INCLUDED
#include "beast/modules/beast_core/beast_core.h"
#include "../ripple_data/ripple_data.h"
namespace ripple {
using namespace beast;
}
#include "api/PackedMessage.h"
#include "api/Peer.h"
#include "api/Peers.h"
#endif