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
This commit is contained in:
Nik Bougalis
2014-03-03 18:31:55 -08:00
committed by Vinnie Falco
parent 7c81eec30c
commit 8b1df06a94
4 changed files with 44 additions and 20 deletions

View File

@@ -507,10 +507,12 @@ std::string
Livecache <Allocator>::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();
}

View File

@@ -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();

View File

@@ -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 ()

View File

@@ -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 <IP::Endpoint> const& addresses)