mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 06:25:51 +00:00
Validators work
This commit is contained in:
@@ -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 <Source> object (source);
|
||||
|
||||
if (findSourceByID (source->uniqueID()))
|
||||
{
|
||||
m_journal.error << "Duplicate static " << source->name();
|
||||
return;
|
||||
}
|
||||
|
||||
m_journal.info << "Addding static " << source->name();
|
||||
|
||||
ScopedPointer <Source> 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 <Source> 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;
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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 ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -614,7 +614,7 @@ public:
|
||||
// Initialize the Validators object with Config information.
|
||||
void prepareValidators ()
|
||||
{
|
||||
#if 0
|
||||
#if 1
|
||||
{
|
||||
std::vector <std::string> 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());
|
||||
|
||||
Reference in New Issue
Block a user