diff --git a/Builds/QtCreator/rippled.pro b/Builds/QtCreator/rippled.pro
index cd9790388d..b4801a55fb 100644
--- a/Builds/QtCreator/rippled.pro
+++ b/Builds/QtCreator/rippled.pro
@@ -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 += \
diff --git a/Builds/VisualStudio2013/RippleD.vcxproj b/Builds/VisualStudio2013/RippleD.vcxproj
index f72eb902af..dd23303f96 100644
--- a/Builds/VisualStudio2013/RippleD.vcxproj
+++ b/Builds/VisualStudio2013/RippleD.vcxproj
@@ -1132,30 +1132,6 @@
true
true
-
- true
- true
- true
- true
-
-
- true
- true
- true
- true
-
-
- true
- true
- true
- true
-
-
- true
- true
- true
- true
-
true
true
@@ -1825,6 +1801,25 @@
true
true
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
+ true
+ true
+ true
+ true
+
+
true
true
@@ -2500,11 +2495,7 @@
-
-
-
-
@@ -2627,6 +2618,12 @@
+
+
+
+
+
+
@@ -2760,6 +2757,8 @@
+
+
diff --git a/Builds/VisualStudio2013/RippleD.vcxproj.filters b/Builds/VisualStudio2013/RippleD.vcxproj.filters
index cd77cd3e15..06fa9c29b9 100644
--- a/Builds/VisualStudio2013/RippleD.vcxproj.filters
+++ b/Builds/VisualStudio2013/RippleD.vcxproj.filters
@@ -307,6 +307,15 @@
{b86f01de-f924-4584-bb22-d70280b224f3}
+
+ {75191c6f-e636-4314-8bee-0d6f40051390}
+
+
+ {92b0fcc6-acfc-4ede-90e1-8f39e87dee4c}
+
+
+ {0ff855ac-5038-4b16-a324-ba85d782c0e2}
+
@@ -702,15 +711,9 @@
[2] Old Ripple\ripple_app\paths
-
- [2] Old Ripple\ripple_app\peers
-
[2] Old Ripple\ripple_app\peers
-
- [2] Old Ripple\ripple_app\peers
-
[2] Old Ripple\ripple_app\rpc
@@ -1077,9 +1080,6 @@
[1] Ripple\sslutil\impl
-
- [2] Old Ripple\ripple_app\peers
-
[1] Ripple\types\impl
@@ -1461,8 +1461,17 @@
[1] Ripple\peerfinder\impl
-
- [2] Old Ripple\ripple_app\peers
+
+ [2] Old Ripple\ripple_overlay\impl
+
+
+ [2] Old Ripple\ripple_overlay\impl
+
+
+ [2] Old Ripple\ripple_overlay\impl
+
+
+ [2] Old Ripple\ripple_overlay
@@ -1910,12 +1919,6 @@
[2] Old Ripple\ripple_app\paths
-
- [2] Old Ripple\ripple_app\peers
-
-
- [2] Old Ripple\ripple_app\peers
-
[2] Old Ripple\ripple_app\peers
@@ -2009,9 +2012,6 @@
[2] Old Ripple\ripple_app\websocket
-
- [2] Old Ripple\ripple_app\peers
-
[2] Old Ripple\ripple_app\main
@@ -2409,9 +2409,6 @@
[1] Ripple\sslutil\api
-
- [2] Old Ripple\ripple_app\peers
-
[1] Ripple\types\api
@@ -3021,6 +3018,24 @@
[1] Ripple\peerfinder\impl
+
+ [2] Old Ripple\ripple_overlay\impl
+
+
+ [2] Old Ripple\ripple_overlay\impl
+
+
+ [2] Old Ripple\ripple_overlay\api
+
+
+ [2] Old Ripple\ripple_overlay\api
+
+
+ [2] Old Ripple\ripple_overlay\api
+
+
+ [2] Old Ripple\ripple_overlay
+
@@ -3142,6 +3157,12 @@
[2] Old Ripple\ripple_rpc
+
+ [2] Old Ripple\ripple_overlay
+
+
+ [2] Old Ripple\ripple_overlay
+
diff --git a/SConstruct b/SConstruct
index 92e48e19be..2de9d57b00 100644
--- a/SConstruct
+++ b/SConstruct
@@ -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'
])
diff --git a/src/ripple/peerfinder/api/Endpoint.h b/src/ripple/peerfinder/api/Endpoint.h
index 6950935640..77edea6ca7 100644
--- a/src/ripple/peerfinder/api/Endpoint.h
+++ b/src/ripple/peerfinder/api/Endpoint.h
@@ -29,8 +29,7 @@ struct Endpoint
Endpoint ();
int hops;
- IPAddress address;
- std::string features;
+ IP::Endpoint address;
};
}
diff --git a/src/ripple/peerfinder/impl/Counts.h b/src/ripple/peerfinder/impl/Counts.h
index 08b2d8cd81..040df3f351 100644
--- a/src/ripple/peerfinder/impl/Counts.h
+++ b/src/ripple/peerfinder/impl/Counts.h
@@ -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
{
diff --git a/src/ripple/peerfinder/impl/Livecache.h b/src/ripple/peerfinder/impl/Livecache.h
index 14ca8456ea..ff8540aaef 100644
--- a/src/ripple/peerfinder/impl/Livecache.h
+++ b/src/ripple/peerfinder/impl/Livecache.h
@@ -58,7 +58,7 @@ public:
};
typedef std::set SortedTable;
- typedef std::unordered_map AddressTable;
+ typedef std::unordered_map 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();
+ }
+ }
};
}
diff --git a/src/ripple/peerfinder/impl/Logic.h b/src/ripple/peerfinder/impl/Logic.h
index 6090ccf2a0..468067f3e8 100644
--- a/src/ripple/peerfinder/impl/Logic.h
+++ b/src/ripple/peerfinder/impl/Logic.h
@@ -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);
diff --git a/src/ripple_app/misc/NetworkOPs.cpp b/src/ripple_app/misc/NetworkOPs.cpp
index e6765b1dae..04369424e6 100644
--- a/src/ripple_app/misc/NetworkOPs.cpp
+++ b/src/ripple_app/misc/NetworkOPs.cpp
@@ -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;
}
}
diff --git a/src/ripple_app/misc/PowResult.h b/src/ripple_app/misc/PowResult.h
index f36d08d8c9..7db4bb4859 100644
--- a/src/ripple_app/misc/PowResult.h
+++ b/src/ripple_app/misc/PowResult.h
@@ -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
diff --git a/src/ripple_app/misc/ProofOfWork.h b/src/ripple_app/misc/ProofOfWork.h
index deb8665df8..ce10ce377e 100644
--- a/src/ripple_app/misc/ProofOfWork.h
+++ b/src/ripple_app/misc/ProofOfWork.h
@@ -20,6 +20,10 @@
#ifndef RIPPLE_PROOFOFWORK_H
#define RIPPLE_PROOFOFWORK_H
+#include "PowResult.h"
+
+namespace ripple {
+
class ProofOfWork : LeakChecked
{
public:
@@ -73,6 +77,7 @@ private:
static const int maxIterations;
};
+}
+
#endif
-// vim:ts=4
diff --git a/src/ripple_app/misc/ProofOfWorkFactory.h b/src/ripple_app/misc/ProofOfWorkFactory.h
index e1337b1998..7eb9810c69 100644
--- a/src/ripple_app/misc/ProofOfWorkFactory.h
+++ b/src/ripple_app/misc/ProofOfWorkFactory.h
@@ -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
diff --git a/src/ripple_app/ripple_app.cpp b/src/ripple_app/ripple_app.cpp
index b5545123a3..abb29ca205 100644
--- a/src/ripple_app/ripple_app.cpp
+++ b/src/ripple_app/ripple_app.cpp
@@ -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"
diff --git a/src/ripple_app/ripple_app.h b/src/ripple_app/ripple_app.h
index 8026aaec0b..e8b9652cd0 100644
--- a/src/ripple_app/ripple_app.h
+++ b/src/ripple_app/ripple_app.h
@@ -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"
diff --git a/src/ripple_app/ripple_app_pt1.cpp b/src/ripple_app/ripple_app_pt1.cpp
index 35b24c113c..4cda340bef 100644
--- a/src/ripple_app/ripple_app_pt1.cpp
+++ b/src/ripple_app/ripple_app_pt1.cpp
@@ -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"
diff --git a/src/ripple_app/ripple_app_pt5.cpp b/src/ripple_app/ripple_app_pt5.cpp
index c00d7784b1..7e2099acf3 100644
--- a/src/ripple_app/ripple_app_pt5.cpp
+++ b/src/ripple_app/ripple_app_pt5.cpp
@@ -31,6 +31,8 @@
#include
+#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"
diff --git a/src/ripple_overlay/README.md b/src/ripple_overlay/README.md
new file mode 100644
index 0000000000..49b21cf958
--- /dev/null
+++ b/src/ripple_overlay/README.md
@@ -0,0 +1,4 @@
+# Overlay
+
+A module which manages peer connections that operate the _Ripple
+peer protocol_.
diff --git a/src/ripple_overlay/TODO.md b/src/ripple_overlay/TODO.md
new file mode 100644
index 0000000000..b53301ceec
--- /dev/null
+++ b/src/ripple_overlay/TODO.md
@@ -0,0 +1 @@
+# Overlay
diff --git a/src/ripple_app/peers/PackedMessage.h b/src/ripple_overlay/api/PackedMessage.h
similarity index 89%
rename from src/ripple_app/peers/PackedMessage.h
rename to src/ripple_overlay/api/PackedMessage.h
index 798c09120f..a1b59894d1 100644
--- a/src/ripple_app/peers/PackedMessage.h
+++ b/src/ripple_overlay/api/PackedMessage.h
@@ -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.
//
diff --git a/src/ripple_app/peers/Peer.h b/src/ripple_overlay/api/Peer.h
similarity index 65%
rename from src/ripple_app/peers/Peer.h
rename to src/ripple_overlay/api/Peer.h
index de062d7ecd..1cc49705d4 100644
--- a/src/ripple_app/peers/Peer.h
+++ b/src/ripple_overlay/api/Peer.h
@@ -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
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
diff --git a/src/ripple_app/peers/Peers.h b/src/ripple_overlay/api/Peers.h
similarity index 97%
rename from src/ripple_app/peers/Peers.h
rename to src/ripple_overlay/api/Peers.h
index 5923c2f6f5..115904f63f 100644
--- a/src/ripple_app/peers/Peers.h
+++ b/src/ripple_overlay/api/Peers.h
@@ -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
+
+#include
+#include
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 const& peerSet;
+ std::set const& peerSet;
peer_in_set (std::set const& peers)
: peerSet (peers)
diff --git a/src/ripple_app/peers/PackedMessage.cpp b/src/ripple_overlay/impl/PackedMessage.cpp
similarity index 99%
rename from src/ripple_app/peers/PackedMessage.cpp
rename to src/ripple_overlay/impl/PackedMessage.cpp
index f996993ed9..36280ff62b 100644
--- a/src/ripple_app/peers/PackedMessage.cpp
+++ b/src/ripple_overlay/impl/PackedMessage.cpp
@@ -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 ((type >> 8) & 0xFF);
mBuffer[5] = static_cast (type & 0xFF);
}
+
+}
diff --git a/src/ripple_app/peers/PeerDoor.cpp b/src/ripple_overlay/impl/PeerDoor.cpp
similarity index 100%
rename from src/ripple_app/peers/PeerDoor.cpp
rename to src/ripple_overlay/impl/PeerDoor.cpp
diff --git a/src/ripple_app/peers/PeerDoor.h b/src/ripple_overlay/impl/PeerDoor.h
similarity index 100%
rename from src/ripple_app/peers/PeerDoor.h
rename to src/ripple_overlay/impl/PeerDoor.h
diff --git a/src/ripple_app/peers/PeerImp.h b/src/ripple_overlay/impl/PeerImp.h
similarity index 99%
rename from src/ripple_app/peers/PeerImp.h
rename to src/ripple_overlay/impl/PeerImp.h
index b4009109b6..5f9b8f07a4 100644
--- a/src/ripple_app/peers/PeerImp.h
+++ b/src/ripple_overlay/impl/PeerImp.h
@@ -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 ptr;
boost::shared_ptr 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())
diff --git a/src/ripple_app/peers/Peers.cpp b/src/ripple_overlay/impl/Peers.cpp
similarity index 99%
rename from src/ripple_app/peers/Peers.cpp
rename to src/ripple_overlay/impl/Peers.cpp
index 6ed71326a0..690f63ff6a 100644
--- a/src/ripple_app/peers/Peers.cpp
+++ b/src/ripple_overlay/impl/Peers.cpp
@@ -20,6 +20,8 @@
#include "PeerDoor.h"
#include "PeerImp.h"
+#include "../../ripple/common/seconds_clock.h"
+
#include
#include
#include
diff --git a/src/ripple_overlay/ripple_overlay.cpp b/src/ripple_overlay/ripple_overlay.cpp
new file mode 100644
index 0000000000..a9e32f68af
--- /dev/null
+++ b/src/ripple_overlay/ripple_overlay.cpp
@@ -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"
+
diff --git a/src/ripple_overlay/ripple_overlay.h b/src/ripple_overlay/ripple_overlay.h
new file mode 100644
index 0000000000..72777b4484
--- /dev/null
+++ b/src/ripple_overlay/ripple_overlay.h
@@ -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