From 8b1df06a94ccd22fbdd96a64c57017d0ade65454 Mon Sep 17 00:00:00 2001 From: Nik Bougalis Date: Mon, 3 Mar 2014 18:31:55 -0800 Subject: [PATCH] PeerFinder fixes: * Fix local advertisement (was missing) * Fix Livecache histogram display * If no [ips] are specified, use r.ripple.com * Use different backing stores for PeerFinder and Validator databases --- src/ripple/peerfinder/impl/Livecache.h | 8 +++--- src/ripple/peerfinder/impl/Logic.h | 36 +++++++++++++++++--------- src/ripple_core/functional/Config.cpp | 9 ++++--- src/ripple_overlay/impl/Peers.cpp | 11 ++++++-- 4 files changed, 44 insertions(+), 20 deletions(-) diff --git a/src/ripple/peerfinder/impl/Livecache.h b/src/ripple/peerfinder/impl/Livecache.h index 3ecf299cf..e26711ea8 100644 --- a/src/ripple/peerfinder/impl/Livecache.h +++ b/src/ripple/peerfinder/impl/Livecache.h @@ -507,10 +507,12 @@ std::string Livecache ::hops_t::histogram() const { std::stringstream ss; - for (auto i : m_hist) - ss << - i << + for (typename decltype(m_hist)::size_type i (0); + i < m_hist.size(); ++i) + { + ss << m_hist[i] << ((i < Tuning::maxHops + 1) ? ", " : ""); + } return ss.str(); } diff --git a/src/ripple/peerfinder/impl/Logic.h b/src/ripple/peerfinder/impl/Logic.h index a9e660f83..6dda1af63 100644 --- a/src/ripple/peerfinder/impl/Logic.h +++ b/src/ripple/peerfinder/impl/Logic.h @@ -1003,18 +1003,6 @@ public: // //-------------------------------------------------------------------------- - // Returns a suitable Endpoint representing us. - Endpoint thisEndpoint (SharedState::Access& state) - { - // Why would someone call this if we don't want incoming? - consistency_check (state->config.wantIncoming); - Endpoint ep; - ep.hops = 0; - ep.address = IP::Endpoint ( - IP::AddressV4 ()).at_port (state->config.listeningPort); - return ep; - } - // Returns true if the IP::Endpoint contains no invalid data. bool is_valid_address (IP::Endpoint const& address) { @@ -1080,6 +1068,30 @@ public: targets.emplace_back (slot); }); } + + /* VFALCO NOTE + This is a temporary measure. Once we know our own IP + address, the correct solution is to put it into the Livecache + at hops 0, and go through the regular handout path. This way + we avoid handing our address out too frequenty, which this code + suffers from. + */ + // Add an entry for ourselves if: + // 1. We want incoming + // 2. We have slots + // 3. We haven't failed the firewalled test + // + if (state->config.wantIncoming && + state->counts.inboundSlots() > 0) + { + Endpoint ep; + ep.hops = 0; + ep.address = IP::Endpoint ( + IP::AddressV4 ()).at_port ( + state->config.listeningPort); + for (auto& t : targets) + t.insert (ep); + } // build sequence of endpoints by hops state->livecache.hops.shuffle(); diff --git a/src/ripple_core/functional/Config.cpp b/src/ripple_core/functional/Config.cpp index 4c16394e7..49efb90a8 100644 --- a/src/ripple_core/functional/Config.cpp +++ b/src/ripple_core/functional/Config.cpp @@ -242,9 +242,12 @@ void Config::setup (const std::string& strConf, bool bQuiet) // Create the new unified database m_moduleDbPath = getDatabaseDir(); - - if (m_moduleDbPath.isDirectory ()) - m_moduleDbPath = m_moduleDbPath.getChildFile("rippled.sqlite"); + + // This code is temporarily disabled, and modules will fall back to using + // per-module databases (e.g. "peerfinder.sqlite") under the module db path + // + //if (m_moduleDbPath.isDirectory ()) + // m_moduleDbPath = m_moduleDbPath.getChildFile("rippled.sqlite"); } void Config::load () diff --git a/src/ripple_overlay/impl/Peers.cpp b/src/ripple_overlay/impl/Peers.cpp index 077fa7fab..e26c7243f 100644 --- a/src/ripple_overlay/impl/Peers.cpp +++ b/src/ripple_overlay/impl/Peers.cpp @@ -411,9 +411,16 @@ public: m_peerFinder->setConfig (config); - if (!getConfig ().IPS.empty ()) + auto bootstrapIps (getConfig ().IPS); + + // If no IPs are specified, use the Ripple Labs round robin + // pool to get some servers to insert into the boot cache. + if (bootstrapIps.empty ()) + bootstrapIps.push_back ("r.ripple.com 51235"); + + if (!bootstrapIps.empty ()) { - m_resolver.resolve (getConfig ().IPS, + m_resolver.resolve (bootstrapIps, [this]( std::string const& name, std::vector const& addresses)