diff --git a/src/ripple/validators/impl/Logic.h b/src/ripple/validators/impl/Logic.h index 5d1776f7d1..91a699e0c3 100644 --- a/src/ripple/validators/impl/Logic.h +++ b/src/ripple/validators/impl/Logic.h @@ -264,16 +264,35 @@ public: // load data from m_store } + // Returns `true` if a Source with the same unique ID already exists + // + bool findSourceByID (String id) + { + SharedState::Access state (m_state); + for (SourcesType::const_iterator iter (state->sources.begin()); + iter != state->sources.end(); ++iter) + if (iter->source->uniqueID() == id) + return true; + return false; + } + // Add a one-time static source. // Fetch is called right away, this call blocks. // void addStatic (Source* source) { + ScopedPointer object (source); + + if (findSourceByID (source->uniqueID())) + { + m_journal.error << "Duplicate static " << source->name(); + return; + } + m_journal.info << "Addding static " << source->name(); - ScopedPointer object (source); Source::Result result; - object->fetch (result, m_journal); + source->fetch (result, m_journal); if (result.success) { @@ -293,6 +312,13 @@ public: // void add (Source* source) { + if (findSourceByID (source->uniqueID())) + { + ScopedPointer object (source); + m_journal.error << "Duplicate " << source->name(); + return; + } + m_journal.info << "Adding " << source->name(); { @@ -301,6 +327,7 @@ public: SourceDesc& desc (state->sources.back()); desc.source = source; m_store.insert (desc); + merge (desc.result.list, desc.source, state); } } @@ -414,8 +441,6 @@ public: { Source* const source (desc.source); - m_journal.info << "fetch " << source->name(); - Source::Result result; source->fetch (result, m_journal); @@ -427,6 +452,10 @@ public: { SharedState::Access state (m_state); + // Count the number fetched + std::size_t const numFetched ( + result.list.size()); + // Add the new source info to the map std::size_t const numAdded ( merge (result.list, source, state)); @@ -438,12 +467,27 @@ public: std::size_t const numRemoved ( remove (result.list, source, state)); + // Report if (numAdded > numRemoved) - m_journal.info << "Added " << (numAdded - numRemoved) << + { + m_journal.info << + "Fetched " << numFetched << + "(" << (numAdded - numRemoved) << " new) " << " trusted validators from " << source->name(); + } else if (numRemoved > numAdded) - m_journal.info << "Removed " << (numRemoved - numAdded) << + { + m_journal.info << + "Fetched " << numFetched << + "(" << numRemoved - numAdded << " removed) " << " trusted validators from " << source->name(); + } + else + { + m_journal.info << + "Fetched " << numFetched << + " trusted validators from " << source->name(); + } // See if we need to rebuild checkChosen (); @@ -457,6 +501,8 @@ public: } else { + m_journal.error << "Failed to fetch " << source->name(); + ++desc.numberOfFailures; desc.status = SourceDesc::statusFailed; diff --git a/src/ripple/validators/impl/SourceURL.cpp b/src/ripple/validators/impl/SourceURL.cpp index bf00ad97c5..d19c7097ce 100644 --- a/src/ripple/validators/impl/SourceURL.cpp +++ b/src/ripple/validators/impl/SourceURL.cpp @@ -57,11 +57,6 @@ public: if (httpResult.first == 0) { -#if 0 - journal.debug << std::endl << httpResult.second->toString (); - journal.debug << std::endl << httpResult.second->body().to_string(); -#endif - Utilities::ParseResultLine lineFunction (result, journal); std::string const s (httpResult.second->body().to_string()); Utilities::processLines (s.begin(), s.end(), lineFunction); diff --git a/src/ripple/validators/impl/StoreSqdb.cpp b/src/ripple/validators/impl/StoreSqdb.cpp index 229e2a0b84..07010cef5b 100644 --- a/src/ripple/validators/impl/StoreSqdb.cpp +++ b/src/ripple/validators/impl/StoreSqdb.cpp @@ -206,10 +206,18 @@ bool StoreSqdb::select (SourceDesc& desc) if (st.execute_and_fetch (error)) { + m_journal.debug << "Found record for " << + desc.source->name (); + found = true; desc.lastFetchTime = Utilities::stringToTime (lastFetchTime); desc.expirationTime = Utilities::stringToTime (expirationTime); } + else if (! error) + { + m_journal.info << "No previous record for " << + desc.source->name (); + } if (error) { @@ -293,6 +301,12 @@ void StoreSqdb::selectList (SourceDesc& desc) } } while (st.fetch (error)); + + if (! error) + { + m_journal.info << "Loaded " << desc.result.list.size() << + " trusted validators for " << desc.source->name (); + } } } diff --git a/src/ripple_app/main/Application.cpp b/src/ripple_app/main/Application.cpp index 174100db31..04a574af40 100644 --- a/src/ripple_app/main/Application.cpp +++ b/src/ripple_app/main/Application.cpp @@ -614,7 +614,7 @@ public: // Initialize the Validators object with Config information. void prepareValidators () { -#if 0 +#if 1 { std::vector const& strings (getConfig().validators); m_validators->addStrings ("rippled.cfg", strings); @@ -628,7 +628,7 @@ public: } #endif -#if 0 +#if 1 if (getConfig().getValidatorsFile() != File::nonexistent ()) { m_validators->addFile (getConfig().getValidatorsFile());