General tidy and refactoring:

* Use nullptr (C++11) instead of NULL.
* Put each file into its own namespace declaration.
* Remove "using namespace" directives and add scope qualifiers.
* Control when beast's implementation of std::equal (C++14) is used.
* Tidy up some const declarations.

Conflicts:
	src/ripple_app/shamap/SHAMapSync.cpp
	src/ripple_app/tx/TransactionEngine.cpp
This commit is contained in:
Howard Hinnant
2014-03-07 18:54:11 -05:00
committed by Vinnie Falco
parent c581ffb8a4
commit cad50c68a8
519 changed files with 3618 additions and 2726 deletions

View File

@@ -23,10 +23,10 @@
namespace ripple {
namespace Validators {
class ChosenList : public SharedObject
class ChosenList : public beast::SharedObject
{
public:
typedef SharedPtr <ChosenList> Ptr;
typedef beast::SharedPtr <ChosenList> Ptr;
struct Info
{

View File

@@ -67,7 +67,7 @@ struct Count
}
/** Output to PropertyStream. */
void onWrite (PropertyStream::Map& map)
void onWrite (beast::PropertyStream::Map& map)
{
map["received"] = received;
map["expected"] = expected;

View File

@@ -41,15 +41,15 @@ public:
bool stopping;
/** The source we are currently fetching. */
SharedPtr <Source> fetchSource;
beast::SharedPtr <Source> fetchSource;
};
typedef SharedData <State> SharedState;
typedef beast::SharedData <State> SharedState;
SharedState m_state;
Store& m_store;
Journal m_journal;
beast::Journal m_journal;
// A small integer assigned to each closed ledger
//
@@ -88,7 +88,7 @@ public:
//--------------------------------------------------------------------------
explicit Logic (Store& store, Journal journal = Journal ())
explicit Logic (Store& store, beast::Journal journal = beast::Journal ())
: m_store (store)
, m_journal (journal)
, m_ledgerID (0)
@@ -122,7 +122,7 @@ public:
// Returns `true` if a Source with the same unique ID already exists
//
bool findSourceByID (String id)
bool findSourceByID (beast::String id)
{
for (SourceTable::const_iterator iter (m_sources.begin());
iter != m_sources.end(); ++iter)
@@ -134,7 +134,7 @@ public:
// Add a one-time static source.
// Fetch is called right away, this call blocks.
//
void addStatic (SharedPtr <Source> source)
void addStatic (beast::SharedPtr <Source> source)
{
if (findSourceByID (source->uniqueID()))
{
@@ -164,7 +164,7 @@ public:
// Add a live source to the list of sources.
//
void add (SharedPtr <Source> source)
void add (beast::SharedPtr <Source> source)
{
if (findSourceByID (source->uniqueID()))
{
@@ -258,7 +258,7 @@ public:
m_journal.debug <<
"Rebuilt chosen list with " <<
String::fromNumber (m_chosenList->size()) << " entries";
beast::String::fromNumber (m_chosenList->size()) << " entries";
}
/** Mark the Chosen List for a rebuild. */
@@ -294,7 +294,7 @@ public:
/** Perform a fetch on the source. */
void fetch (SourceDesc& desc)
{
SharedPtr <Source> const& source (desc.source);
beast::SharedPtr <Source> const& source (desc.source);
Source::Results results;
{
@@ -316,8 +316,8 @@ public:
}
// Reset fetch timer for the source->
desc.whenToFetch = Time::getCurrentTime () +
RelativeTime (secondsBetweenFetches);
desc.whenToFetch = beast::Time::getCurrentTime () +
beast::RelativeTime (secondsBetweenFetches);
if (results.success)
{
@@ -394,7 +394,7 @@ public:
std::size_t fetch_one ()
{
std::size_t n (0);
Time const currentTime (Time::getCurrentTime ());
beast::Time const currentTime (beast::Time::getCurrentTime ());
for (SourceTable::iterator iter = m_sources.begin ();
(n == 0) && iter != m_sources.end (); ++iter)

View File

@@ -127,21 +127,21 @@ namespace Validators {
class ManagerImp
: public Manager
, public Stoppable
, public Thread
, public DeadlineTimer::Listener
, public LeakChecked <ManagerImp>
, public beast::Stoppable
, public beast::Thread
, public beast::DeadlineTimer::Listener
, public beast::LeakChecked <ManagerImp>
{
public:
Journal m_journal;
File m_databaseFile;
beast::Journal m_journal;
beast::File m_databaseFile;
StoreSqdb m_store;
Logic m_logic;
DeadlineTimer m_checkTimer;
ServiceQueue m_queue;
beast::DeadlineTimer m_checkTimer;
beast::ServiceQueue m_queue;
typedef ScopedWrapperContext <
RecursiveMutex, RecursiveMutex::ScopedLockType> Context;
typedef beast::ScopedWrapperContext <
beast::RecursiveMutex, beast::RecursiveMutex::ScopedLockType> Context;
Context m_context;
@@ -152,8 +152,8 @@ public:
ManagerImp (
Stoppable& parent,
File const& pathToDbFileOrDirectory,
Journal journal)
beast::File const& pathToDbFileOrDirectory,
beast::Journal journal)
: Stoppable ("Validators::Manager", parent)
, Thread ("Validators")
, m_journal (journal)
@@ -187,16 +187,16 @@ public:
//
//--------------------------------------------------------------------------
void addStrings (String name, std::vector <std::string> const& strings)
void addStrings (beast::String name, std::vector <std::string> const& strings)
{
StringArray stringArray;
beast::StringArray stringArray;
stringArray.ensureStorageAllocated (strings.size());
for (std::size_t i = 0; i < strings.size(); ++i)
stringArray.add (strings [i]);
addStrings (name, stringArray);
}
void addStrings (String name, StringArray const& stringArray)
void addStrings (beast::String name, beast::StringArray const& stringArray)
{
if (stringArray.size() > 0)
{
@@ -208,25 +208,25 @@ public:
}
}
void addFile (File const& file)
void addFile (beast::File const& file)
{
addStaticSource (SourceFile::New (file));
}
void addStaticSource (Validators::Source* source)
{
m_queue.dispatch (m_context.wrap (bind (
m_queue.dispatch (m_context.wrap (std::bind (
&Logic::addStatic, &m_logic, source)));
}
void addURL (URL const& url)
void addURL (beast::URL const& url)
{
addSource (SourceURL::New (url));
}
void addSource (Validators::Source* source)
{
m_queue.dispatch (m_context.wrap (bind (
m_queue.dispatch (m_context.wrap (std::bind (
&Logic::add, &m_logic, source)));
}
@@ -235,14 +235,14 @@ public:
void receiveValidation (ReceivedValidation const& rv)
{
if (! isStopping())
m_queue.dispatch (m_context.wrap (bind (
m_queue.dispatch (m_context.wrap (std::bind (
&Logic::receiveValidation, &m_logic, rv)));
}
void ledgerClosed (RippleLedgerHash const& ledgerHash)
{
if (! isStopping())
m_queue.dispatch (m_context.wrap (bind (
m_queue.dispatch (m_context.wrap (std::bind (
&Logic::ledgerClosed, &m_logic, ledgerHash)));
}
@@ -259,7 +259,7 @@ public:
void onStart ()
{
// Do this late so the sources have a chance to be added.
m_queue.dispatch (m_context.wrap (bind (
m_queue.dispatch (m_context.wrap (std::bind (
&ManagerImp::setCheckSources, this)));
startThread();
@@ -269,7 +269,7 @@ public:
{
m_logic.stop ();
m_queue.dispatch (m_context.wrap (bind (
m_queue.dispatch (m_context.wrap (std::bind (
&Thread::signalThreadShouldExit, this)));
}
@@ -279,29 +279,29 @@ public:
//
//--------------------------------------------------------------------------
void onWrite (PropertyStream::Map& map)
void onWrite (beast::PropertyStream::Map& map)
{
Context::Scope scope (m_context);
map ["trusted"] = uint32 (
map ["trusted"] = beast::uint32 (
m_logic.m_chosenList ?
m_logic.m_chosenList->size() : 0);
{
PropertyStream::Set items ("sources", map);
beast::PropertyStream::Set items ("sources", map);
for (Logic::SourceTable::const_iterator iter (m_logic.m_sources.begin());
iter != m_logic.m_sources.end(); ++iter)
items.add (iter->source->to_string());
}
{
PropertyStream::Set items ("validators", map);
beast::PropertyStream::Set items ("validators", map);
for (Logic::ValidatorTable::iterator iter (m_logic.m_validators.begin());
iter != m_logic.m_validators.end(); ++iter)
{
RipplePublicKey const& publicKey (iter->first);
Validator const& validator (iter->second);
PropertyStream::Map item (items);
beast::PropertyStream::Map item (items);
item["public_key"] = publicKey.to_string();
validator.count().onWrite (item);
}
@@ -316,7 +316,7 @@ public:
void init ()
{
Error error (m_store.open (m_databaseFile));
beast::Error error (m_store.open (m_databaseFile));
if (! error)
{
@@ -324,12 +324,12 @@ public:
}
}
void onDeadlineTimer (DeadlineTimer& timer)
void onDeadlineTimer (beast::DeadlineTimer& timer)
{
if (timer == m_checkTimer)
{
m_journal.trace << "Check timer expired";
m_queue.dispatch (m_context.wrap (bind (
m_queue.dispatch (m_context.wrap (std::bind (
&ManagerImp::setCheckSources, this)));
}
}
@@ -354,7 +354,7 @@ public:
m_checkSources = false;
m_journal.trace << "Next check timer expires in " <<
RelativeTime::seconds (checkEverySeconds);
beast::RelativeTime::seconds (checkEverySeconds);
m_checkTimer.setExpiration (checkEverySeconds);
}
@@ -378,14 +378,14 @@ public:
//------------------------------------------------------------------------------
Manager::Manager ()
: PropertyStream::Source ("validators")
: beast::PropertyStream::Source ("validators")
{
}
Validators::Manager* Validators::Manager::New (
Stoppable& parent,
File const& pathToDbFileOrDirectory,
Journal journal)
beast::Stoppable& parent,
beast::File const& pathToDbFileOrDirectory,
beast::Journal journal)
{
return new Validators::ManagerImp (parent, pathToDbFileOrDirectory, journal);
}

View File

@@ -33,9 +33,9 @@ struct SourceDesc
statusFailed
};
SharedPtr <Source> source;
beast::SharedPtr <Source> source;
Status status;
Time whenToFetch;
beast::Time whenToFetch;
int numberOfFailures;
// The result of the last fetch
@@ -44,16 +44,16 @@ struct SourceDesc
//------------------------------------------------------------------
/** The time of the last successful fetch. */
Time lastFetchTime;
beast::Time lastFetchTime;
/** When to expire this source's list of cached results (if any) */
Time expirationTime;
beast::Time expirationTime;
//------------------------------------------------------------------
SourceDesc () noexcept
: status (statusNone)
, whenToFetch (Time::getCurrentTime ())
, whenToFetch (beast::Time::getCurrentTime ())
, numberOfFailures (0)
{
}

View File

@@ -22,10 +22,10 @@ namespace Validators {
class SourceFileImp
: public SourceFile
, public LeakChecked <SourceFileImp>
, public beast::LeakChecked <SourceFileImp>
{
public:
SourceFileImp (File const& file)
SourceFileImp (beast::File const& file)
: m_file (file)
{
}
@@ -42,29 +42,29 @@ public:
return ss.str();
}
String uniqueID () const
beast::String uniqueID () const
{
return "File," + m_file.getFullPathName ();
}
String createParam ()
beast::String createParam ()
{
return m_file.getFullPathName ();
}
void fetch (Results& results, Journal journal)
void fetch (Results& results, beast::Journal journal)
{
int64 const fileSize (m_file.getSize ());
beast::int64 const fileSize (m_file.getSize ());
if (fileSize != 0)
{
if (fileSize < std::numeric_limits<int32>::max())
if (fileSize < std::numeric_limits<beast::int32>::max())
{
MemoryBlock buffer (fileSize);
RandomAccessFile f;
RandomAccessFile::ByteCount amountRead;
beast::MemoryBlock buffer (fileSize);
beast::RandomAccessFile f;
beast::RandomAccessFile::ByteCount amountRead;
f.open (m_file, RandomAccessFile::readOnly);
f.open (m_file, beast::RandomAccessFile::readOnly);
f.read (buffer.begin(), fileSize, &amountRead);
if (amountRead == fileSize)
@@ -85,12 +85,12 @@ public:
}
private:
File m_file;
beast::File m_file;
};
//------------------------------------------------------------------------------
SourceFile* SourceFile::New (File const& file)
SourceFile* SourceFile::New (beast::File const& file)
{
return new SourceFileImp (file);
}

View File

@@ -29,7 +29,7 @@ namespace Validators {
class SourceFile : public Source
{
public:
static SourceFile* New (File const& path);
static SourceFile* New (beast::File const& path);
};
}

View File

@@ -22,11 +22,11 @@ namespace Validators {
class SourceStringsImp
: public SourceStrings
, public LeakChecked <SourceStringsImp>
, public beast::LeakChecked <SourceStringsImp>
{
public:
SourceStringsImp (
String name, StringArray const& strings)
beast::String name, beast::StringArray const& strings)
: m_name (name)
, m_strings (strings)
{
@@ -41,18 +41,18 @@ public:
return m_name.toStdString();
}
String uniqueID () const
beast::String uniqueID () const
{
// VFALCO TODO This can't be right...?
return String::empty;
return beast::String::empty;
}
String createParam ()
beast::String createParam ()
{
return String::empty;
return beast::String::empty;
}
void fetch (Results& results, Journal journal)
void fetch (Results& results, beast::Journal journal)
{
results.list.reserve (m_strings.size ());
@@ -63,18 +63,19 @@ public:
}
results.success = results.list.size () > 0;
results.expirationTime = Time::getCurrentTime () + RelativeTime::hours (24);
results.expirationTime = beast::Time::getCurrentTime () +
beast::RelativeTime::hours (24);
}
private:
String m_name;
StringArray m_strings;
beast::String m_name;
beast::StringArray m_strings;
};
//------------------------------------------------------------------------------
SourceStrings* SourceStrings::New (
String name, StringArray const& strings)
beast::String name, beast::StringArray const& strings)
{
return new SourceStringsImp (name, strings);
}

View File

@@ -30,7 +30,7 @@ class SourceStrings : public Source
{
public:
static SourceStrings* New (
String name, StringArray const& strings);
beast::String name, beast::StringArray const& strings);
};
}

View File

@@ -24,10 +24,10 @@ namespace Validators {
class SourceURLImp
: public SourceURL
, public LeakChecked <SourceURLImp>
, public beast::LeakChecked <SourceURLImp>
{
public:
explicit SourceURLImp (URL const& url)
explicit SourceURLImp (beast::URL const& url)
: m_url (url)
, m_client (beast::asio::HTTPClientBase::New ())
{
@@ -45,12 +45,12 @@ public:
return ss.str();
}
String uniqueID () const
beast::String uniqueID () const
{
return "URL," + m_url.toString();
}
String createParam ()
beast::String createParam ()
{
return m_url.toString();
}
@@ -60,7 +60,7 @@ public:
m_client->cancel ();
}
void fetch (Results& results, Journal journal)
void fetch (Results& results, beast::Journal journal)
{
auto httpResult (m_client->get (m_url));
@@ -79,14 +79,14 @@ public:
}
private:
URL m_url;
beast::URL m_url;
std::unique_ptr <beast::asio::HTTPClientBase> m_client;
};
//------------------------------------------------------------------------------
SourceURL* SourceURL::New (
URL const& url)
beast::URL const& url)
{
return new SourceURLImp (url);
}

View File

@@ -27,7 +27,7 @@ namespace Validators {
class SourceURL : public Source
{
public:
static SourceURL* New (URL const& url);
static SourceURL* New (beast::URL const& url);
};
}

View File

@@ -20,7 +20,7 @@
namespace ripple {
namespace Validators {
StoreSqdb::StoreSqdb (Journal journal)
StoreSqdb::StoreSqdb (beast::Journal journal)
: m_journal (journal)
{
}
@@ -29,9 +29,9 @@ StoreSqdb::~StoreSqdb ()
{
}
Error StoreSqdb::open (File const& file)
beast::Error StoreSqdb::open (beast::File const& file)
{
Error error (m_session.open (file.getFullPathName ()));
beast::Error error (m_session.open (file.getFullPathName ()));
m_journal.info <<
"Opening " << file.getFullPathName();
@@ -53,7 +53,7 @@ Error StoreSqdb::open (File const& file)
void StoreSqdb::insert (SourceDesc& desc)
{
sqdb::transaction tr (m_session);
beast::sqdb::transaction tr (m_session);
bool const found (select (desc));
@@ -63,14 +63,14 @@ void StoreSqdb::insert (SourceDesc& desc)
}
else
{
Error error;
beast::Error error;
String const sourceID (desc.source->uniqueID().toStdString());
String const createParam (desc.source->createParam().toStdString());
String const lastFetchTime (Utilities::timeToString (desc.lastFetchTime));
String const expirationTime (Utilities::timeToString (desc.expirationTime));
beast::String const sourceID (desc.source->uniqueID().toStdString());
beast::String const createParam (desc.source->createParam().toStdString());
beast::String const lastFetchTime (Utilities::timeToString (desc.lastFetchTime));
beast::String const expirationTime (Utilities::timeToString (desc.expirationTime));
sqdb::statement st = (m_session.prepare <<
beast::sqdb::statement st = (m_session.prepare <<
"INSERT INTO Validators_Source ( "
" sourceID, "
" createParam, "
@@ -79,10 +79,10 @@ void StoreSqdb::insert (SourceDesc& desc)
") VALUES ( "
" ?, ?, ?, ? "
"); "
,sqdb::use (sourceID)
,sqdb::use (createParam)
,sqdb::use (lastFetchTime)
,sqdb::use (expirationTime)
,beast::sqdb::use (sourceID)
,beast::sqdb::use (createParam)
,beast::sqdb::use (lastFetchTime)
,beast::sqdb::use (expirationTime)
);
st.execute_and_fetch (error);
@@ -104,13 +104,13 @@ void StoreSqdb::insert (SourceDesc& desc)
void StoreSqdb::update (SourceDesc& desc, bool updateFetchResults)
{
Error error;
beast::Error error;
String const sourceID (desc.source->uniqueID());
String const lastFetchTime (Utilities::timeToString (desc.lastFetchTime));
String const expirationTime (Utilities::timeToString (desc.expirationTime));
beast::String const sourceID (desc.source->uniqueID());
beast::String const lastFetchTime (Utilities::timeToString (desc.lastFetchTime));
beast::String const expirationTime (Utilities::timeToString (desc.expirationTime));
sqdb::transaction tr (m_session);
beast::sqdb::transaction tr (m_session);
m_session.once (error) <<
"UPDATE Validators_Source SET "
@@ -118,9 +118,9 @@ void StoreSqdb::update (SourceDesc& desc, bool updateFetchResults)
" expirationTime = ? "
"WHERE "
" sourceID = ? "
,sqdb::use (lastFetchTime)
,sqdb::use (expirationTime)
,sqdb::use (sourceID)
,beast::sqdb::use (lastFetchTime)
,beast::sqdb::use (expirationTime)
,beast::sqdb::use (sourceID)
;
if (! error && updateFetchResults)
@@ -129,16 +129,16 @@ void StoreSqdb::update (SourceDesc& desc, bool updateFetchResults)
m_session.once (error) <<
"DELETE FROM Validators_SourceItem WHERE "
" sourceID = ?; "
,sqdb::use (sourceID)
,beast::sqdb::use (sourceID)
;
// Insert the new data set
if (! error)
{
std::string publicKeyString;
String label;
beast::String label;
sqdb::statement st = (m_session.prepare <<
beast::sqdb::statement st = (m_session.prepare <<
"INSERT INTO Validators_SourceItem ( "
" sourceID, "
" publicKey, "
@@ -146,9 +146,9 @@ void StoreSqdb::update (SourceDesc& desc, bool updateFetchResults)
") VALUES ( "
" ?, ?, ? "
");"
,sqdb::use (sourceID)
,sqdb::use (publicKeyString)
,sqdb::use (label)
,beast::sqdb::use (sourceID)
,beast::sqdb::use (publicKeyString)
,beast::sqdb::use (label)
);
std::vector <Source::Item>& list (desc.results.list);
@@ -176,13 +176,13 @@ void StoreSqdb::update (SourceDesc& desc, bool updateFetchResults)
//--------------------------------------------------------------------------
void StoreSqdb::report (Error const& error, char const* fileName, int lineNumber)
void StoreSqdb::report (beast::Error const& error, char const* fileName, int lineNumber)
{
if (error)
{
m_journal.error <<
"Failure: '"<< error.getReasonText() << "' " <<
" at " << Debug::getSourceLocation (fileName, lineNumber);
" at " << beast::Debug::getSourceLocation (fileName, lineNumber);
}
}
@@ -195,20 +195,20 @@ bool StoreSqdb::select (SourceDesc& desc)
{
bool found (false);
Error error;
beast::Error error;
String const sourceID (desc.source->uniqueID());
String lastFetchTime;
String expirationTime;
sqdb::statement st = (m_session.prepare <<
beast::String const sourceID (desc.source->uniqueID());
beast::String lastFetchTime;
beast::String expirationTime;
beast::sqdb::statement st = (m_session.prepare <<
"SELECT "
" lastFetchTime, "
" expirationTime "
"FROM Validators_Source WHERE "
" sourceID = ? "
,sqdb::into (lastFetchTime)
,sqdb::into (expirationTime)
,sqdb::use (sourceID)
,beast::sqdb::into (lastFetchTime)
,beast::sqdb::into (expirationTime)
,beast::sqdb::use (sourceID)
);
if (st.execute_and_fetch (error))
@@ -241,9 +241,9 @@ bool StoreSqdb::select (SourceDesc& desc)
*/
void StoreSqdb::selectList (SourceDesc& desc)
{
Error error;
beast::Error error;
String const sourceID (desc.source->uniqueID());
beast::String const sourceID (desc.source->uniqueID());
// Get the count
std::size_t count;
@@ -254,8 +254,8 @@ void StoreSqdb::selectList (SourceDesc& desc)
" COUNT(*) "
"FROM Validators_SourceItem WHERE "
" sourceID = ? "
,sqdb::into (count)
,sqdb::use (sourceID)
,beast::sqdb::into (count)
,beast::sqdb::use (sourceID)
;
}
@@ -275,15 +275,15 @@ void StoreSqdb::selectList (SourceDesc& desc)
{
std::string publicKeyString;
std::string label;
sqdb::statement st = (m_session.prepare <<
beast::sqdb::statement st = (m_session.prepare <<
"SELECT "
" publicKey, "
" label "
"FROM Validators_SourceItem WHERE "
" sourceID = ? "
,sqdb::into (publicKeyString)
,sqdb::into (label)
,sqdb::use (sourceID)
,beast::sqdb::into (publicKeyString)
,beast::sqdb::into (label)
,beast::sqdb::use (sourceID)
);
// Add all the records to the list
@@ -328,11 +328,11 @@ void StoreSqdb::selectList (SourceDesc& desc)
//--------------------------------------------------------------------------
// Update the database for the current schema
Error StoreSqdb::update ()
beast::Error StoreSqdb::update ()
{
Error error;
beast::Error error;
sqdb::transaction tr (m_session);
beast::sqdb::transaction tr (m_session);
// Get the version from the database
int version (0);
@@ -343,7 +343,7 @@ Error StoreSqdb::update ()
" version "
"FROM SchemaVersion WHERE "
" name = 'Validators' "
,sqdb::into (version)
,beast::sqdb::into (version)
;
if (! m_session.got_data ())
@@ -388,7 +388,7 @@ Error StoreSqdb::update ()
") VALUES ( "
" 'Validators', ? "
"); "
,sqdb::use (version)
,beast::sqdb::use (version)
;
}
@@ -408,11 +408,11 @@ Error StoreSqdb::update ()
//--------------------------------------------------------------------------
Error StoreSqdb::init ()
beast::Error StoreSqdb::init ()
{
Error error;
beast::Error error;
sqdb::transaction tr (m_session);
beast::sqdb::transaction tr (m_session);
if (! error)
{

View File

@@ -26,7 +26,7 @@ namespace Validators {
/** Database persistence for Validators using SQLite */
class StoreSqdb
: public Store
, public LeakChecked <StoreSqdb>
, public beast::LeakChecked <StoreSqdb>
{
public:
enum
@@ -35,11 +35,11 @@ public:
currentSchemaVersion = 2
};
explicit StoreSqdb (Journal journal = Journal());
explicit StoreSqdb (beast::Journal journal = beast::Journal());
~StoreSqdb ();
Error open (File const& file);
beast::Error open (beast::File const& file);
void insert (SourceDesc& desc);
@@ -48,16 +48,16 @@ public:
void remove (RipplePublicKey const& publicKey);
private:
void report (Error const& error, char const* fileName, int lineNumber);
void report (beast::Error const& error, char const* fileName, int lineNumber);
bool select (SourceDesc& desc);
void selectList (SourceDesc& desc);
Error update ();
Error init ();
beast::Error update ();
beast::Error init ();
Journal m_journal;
sqdb::session m_session;
beast::Journal m_journal;
beast::sqdb::session m_session;
};
}

View File

@@ -20,7 +20,7 @@
namespace ripple {
namespace Validators {
class Tests : public UnitTest
class Tests : public beast::UnitTest
{
public:
enum
@@ -97,7 +97,7 @@ public:
struct TestSource : Source
{
TestSource (String const& name, uint32 start, uint32 end)
TestSource (beast::String const& name, beast::uint32 start, beast::uint32 end)
: m_name (name)
, m_start (start)
, m_end (end)
@@ -109,34 +109,35 @@ public:
return uniqueID().toStdString();
}
String uniqueID () const
beast::String uniqueID () const
{
using beast::String;
return String ("Test,") + m_name + "," +
String::fromNumber (m_start) + "," +
String::fromNumber (m_end);
}
String createParam ()
beast::String createParam ()
{
return String::empty;
return beast::String::empty;
}
void fetch (Results& results, Journal)
void fetch (Results& results, beast::Journal)
{
results.success = true;
results.message = String::empty;
results.message = beast::String::empty;
results.list.reserve (numberOfTestValidators);
for (uint32 i = m_start ; i < m_end; ++i)
for (beast::uint32 i = m_start ; i < m_end; ++i)
{
Item item;;
item.publicKey = RipplePublicKey::createFromInteger (i);
item.label = String::fromNumber (i);
item.label = beast::String::fromNumber (i);
results.list.push_back (item);
}
}
String m_name;
beast::String m_name;
std::size_t m_start;
std::size_t m_end;
};
@@ -173,9 +174,9 @@ public:
{
for (int i = 1; i <= numberofTestSources; ++i)
{
String const name (String::fromNumber (i));
uint32 const start = random().nextInt (numberOfTestValidators);
uint32 const end = start + random().nextInt (numberOfTestValidators);
beast::String const name (beast::String::fromNumber (i));
beast::uint32 const start = random().nextInt (numberOfTestValidators);
beast::uint32 const end = start + random().nextInt (numberOfTestValidators);
logic.add (new TestSource (name, start, end));
}
}
@@ -187,17 +188,17 @@ public:
//TestStore store;
StoreSqdb storage;
File const file (
File::getSpecialLocation (
File::userDocumentsDirectory).getChildFile (
beast::File const file (
beast::File::getSpecialLocation (
beast::File::userDocumentsDirectory).getChildFile (
"validators-test.sqlite"));
// Can't call this 'error' because of ADL and Journal::error
Error err (storage.open (file));
beast::Error err (storage.open (file));
unexpected (err, err.what());
Logic logic (storage, Journal ());
Logic logic (storage, beast::Journal ());
logic.load ();
addSources (logic);
@@ -214,7 +215,7 @@ public:
// We need to use the same seed so we create the
// same IDs for the set of TestSource objects.
//
int64 const seedValue = 10;
beast::int64 const seedValue = 10;
random().setSeed (seedValue);
testLogic ();

View File

@@ -77,7 +77,7 @@ struct Utilities::Helpers
bool Utilities::parseInfoLine (
Source::Item& item,
std::string const& line,
Journal journal)
beast::Journal journal)
{
bool success (false);
@@ -122,7 +122,7 @@ bool Utilities::parseInfoLine (
void Utilities::parseResultLine (
Source::Results& results,
std::string const& line,
Journal journal)
beast::Journal journal)
{
Source::Item item;
@@ -136,12 +136,12 @@ void Utilities::parseResultLine (
//--------------------------------------------------------------------------
String Utilities::itos (int i, int fieldSize)
beast::String Utilities::itos (int i, int fieldSize)
{
return String::fromNumber (i).paddedLeft (beast_wchar('0'), fieldSize);
return beast::String::fromNumber (i).paddedLeft (beast::beast_wchar('0'), fieldSize);
}
String Utilities::timeToString (Time const& t)
beast::String Utilities::timeToString (beast::Time const& t)
{
if (t.isNotNull ())
{
@@ -154,13 +154,14 @@ String Utilities::timeToString (Time const& t)
itos (t.getSeconds(), 2);
}
return String::empty;
return beast::String::empty;
}
int Utilities::stoi (String& s, int fieldSize, int minValue, int maxValue, beast_wchar delimiter)
int Utilities::stoi (beast::String& s, int fieldSize, int minValue, int maxValue,
beast::beast_wchar delimiter)
{
int const needed (fieldSize + ((delimiter != 0) ? 1 : 0));
String const v (s.substring (0, needed));
beast::String const v (s.substring (0, needed));
s = s.substring (v.length ());
if (s.length() == needed)
{
@@ -175,7 +176,7 @@ int Utilities::stoi (String& s, int fieldSize, int minValue, int maxValue, beast
return -1; // fail
}
Time Utilities::stringToTime (String s)
beast::Time Utilities::stringToTime (beast::String s)
{
if (s.isNotEmpty ())
{
@@ -193,11 +194,11 @@ Time Utilities::stringToTime (String s)
sec != -1)
{
// local time
return Time (year, mon, day, hour, min, sec, 0, true);
return beast::Time (year, mon, day, hour, min, sec, 0, true);
}
}
return Time (0);
return beast::Time (0);
}
//------------------------------------------------------------------------------

View File

@@ -33,7 +33,7 @@ public:
class ParseResultLine
{
public:
ParseResultLine (Source::Results& results, Journal journal)
ParseResultLine (Source::Results& results, beast::Journal journal)
: m_result (&results)
, m_journal (journal)
{ }
@@ -47,7 +47,7 @@ public:
private:
Source::Results* m_result;
Journal m_journal;
beast::Journal m_journal;
};
/** UnaryPredicate for breaking up lines.
@@ -119,15 +119,16 @@ public:
static void parseResultLine (
Source::Results& results,
std::string const& line,
Journal journal = Journal());
beast::Journal journal = beast::Journal());
// helpers
static String itos (int i, int fieldSize = 0);
static int stoi (String& s, int fieldSize, int minValue, int maxValue, beast_wchar delimiter);
static beast::String itos (int i, int fieldSize = 0);
static int stoi (beast::String& s, int fieldSize, int minValue, int maxValue,
beast::beast_wchar delimiter);
// conversion betwen Time and String
static String timeToString (Time const& t);
static Time stringToTime (String s);
static beast::String timeToString (beast::Time const& t);
static beast::Time stringToTime (beast::String s);
struct Helpers;
@@ -135,7 +136,7 @@ public:
@return `true` on success.
*/
static bool parseInfoLine (
Source::Item& item, std::string const& line, Journal journal);
Source::Item& item, std::string const& line, beast::Journal journal);
};
}