Cleanups:

* Reduce Beast dependencies
* Remove unnecessary includes
* Don't use deprecated bassert macros
* Don't use beast::String in Json::Value
This commit is contained in:
Nik Bougalis
2016-01-18 21:20:08 -08:00
parent b4f8dc7abf
commit 555cd59a59
28 changed files with 39 additions and 49 deletions

View File

@@ -32,8 +32,8 @@
#include <ripple/protocol/RippleLedgerHash.h>
#include <ripple/protocol/STValidation.h>
#include <beast/insight/Collector.h>
#include <beast/module/core/threads/ScopedLock.h>
#include <beast/threads/Stoppable.h>
#include <beast/threads/UnlockGuard.h>
#include <beast/utility/PropertyStream.h>
#include <mutex>

View File

@@ -19,6 +19,7 @@
#include <BeastConfig.h>
#include <ripple/app/main/NodeStoreScheduler.h>
#include <cassert>
namespace ripple {
@@ -40,7 +41,7 @@ void NodeStoreScheduler::onStop ()
void NodeStoreScheduler::onChildrenStopped ()
{
bassert (m_taskCount == 0);
assert (m_taskCount == 0);
stopped ();
}

View File

@@ -30,6 +30,7 @@
#include <ripple/basics/chrono.h>
#include <ripple/core/JobQueue.h>
#include <ripple/core/TimeKeeper.h>
#include <beast/module/core/threads/ScopedLock.h>
#include <memory>
#include <mutex>
#include <thread>

View File

@@ -23,6 +23,7 @@
#include <beast/unit_test/suite.h>
#include <beast/module/core/text/LexicalCast.h>
#include <boost/foreach.hpp>
#include <cassert>
#include <cstdint>
namespace ripple {
@@ -121,7 +122,7 @@ std::uint32_t RangeSet::prevMissing (std::uint32_t v) const
}
}
bassert (result == absent || !hasValue (result));
assert (result == absent || !hasValue (result));
return result;
}

View File

@@ -28,7 +28,6 @@
#include <ripple/json/json_value.h>
#include <beast/http/URL.h>
#include <beast/net/IPEndpoint.h>
#include <beast/module/core/files/File.h>
#include <beast/utility/ci_char_traits.h>
#include <beast/utility/Journal.h>
#include <boost/asio/ip/tcp.hpp> // VFALCO FIX: This include should not be here

View File

@@ -22,6 +22,7 @@
#include <ripple/json/json_value.h>
#include <beast/utility/Journal.h>
#include <algorithm>
#include <cstdint>
#include <mutex>

View File

@@ -19,6 +19,7 @@
#include <BeastConfig.h>
#include <ripple/core/Job.h>
#include <cassert>
namespace ripple {
@@ -57,7 +58,7 @@ JobType Job::getType () const
Job::CancelCallback Job::getCancelCallback () const
{
bassert (m_cancelCallback);
assert (m_cancelCallback);
return m_cancelCallback;
}

View File

@@ -20,6 +20,7 @@
#include <BeastConfig.h>
#include <ripple/core/LoadEvent.h>
#include <ripple/core/LoadMonitor.h>
#include <cassert>
namespace ripple {
@@ -86,7 +87,7 @@ void LoadEvent::start ()
void LoadEvent::stop ()
{
bassert (m_isRunning);
assert (m_isRunning);
m_timeStopped = beast::RelativeTime::fromStartup();
m_secondsRunning += (m_timeStopped - m_timeStarted).inSeconds();

View File

@@ -20,6 +20,7 @@
#include <BeastConfig.h>
#include <ripple/basics/contract.h>
#include <ripple/json/Object.h>
#include <cassert>
namespace Json {

View File

@@ -20,6 +20,7 @@
#include <BeastConfig.h>
#include <ripple/basics/contract.h>
#include <ripple/json/json_reader.h>
#include <algorithm>
#include <string>
#include <cctype>

View File

@@ -276,15 +276,6 @@ Value::Value ( std::string const& value )
}
Value::Value (beast::String const& beastString)
: type_ ( stringValue )
, allocated_ ( true )
{
value_.string_ = valueAllocator ()->duplicateStringValue ( beastString.toStdString ().c_str (),
(unsigned int)beastString.length () );
}
Value::Value ( const StaticString& value )
: type_ ( stringValue )
, allocated_ ( false )

View File

@@ -19,6 +19,7 @@
#include <BeastConfig.h>
#include <ripple/json/json_writer.h>
#include <cassert>
#include <iomanip>
#include <sstream>
#include <string>

View File

@@ -21,9 +21,10 @@
#define RIPPLE_JSON_JSON_VALUE_H_INCLUDED
#include <ripple/json/json_forwards.h>
#include <beast/strings/String.h>
#include <cstring>
#include <functional>
#include <map>
#include <string>
#include <vector>
/** \brief JSON (JavaScript Object Notation).
@@ -89,26 +90,26 @@ private:
const char* str_;
};
inline bool operator!= (StaticString x, StaticString y)
inline bool operator== (StaticString x, StaticString y)
{
// TODO(tom): could I use x != y here because StaticStrings are supposed to
// be unique?
return strcmp (x, y);
return strcmp (x.c_str(), y.c_str()) == 0;
}
inline bool operator== (StaticString x, StaticString y)
inline bool operator!= (StaticString x, StaticString y)
{
return ! (x != y);
return ! (x == y);
}
inline bool operator== (std::string const& x, StaticString y)
{
return x == y.c_str();
return strcmp(x.c_str(), y.c_str()) == 0;
}
inline bool operator!= (std::string const& x, StaticString y)
{
return x != y.c_str();
return ! (x == y);
}
inline bool operator== (StaticString x, std::string const& y)
@@ -118,7 +119,7 @@ inline bool operator== (StaticString x, std::string const& y)
inline bool operator!= (StaticString x, std::string const& y)
{
return y != x;
return ! (y == x);
}
/** \brief Represents a <a HREF="http://www.json.org">JSON</a> value.
@@ -228,8 +229,6 @@ public:
*/
Value ( const StaticString& value );
Value ( std::string const& value );
// VFALCO DEPRECATED Avoid this conversion
Value (beast::String const& beastString);
Value ( bool value );
Value ( const Value& other );
~Value ();

View File

@@ -21,6 +21,7 @@
#include <ripple/nodestore/impl/DecodedBlob.h>
#include <beast/ByteOrder.h>
#include <algorithm>
#include <cassert>
namespace ripple {
namespace NodeStore {
@@ -73,7 +74,7 @@ DecodedBlob::DecodedBlob (void const* key, void const* value, int valueBytes)
std::shared_ptr<NodeObject> DecodedBlob::createObject ()
{
bassert (m_success);
assert (m_success);
std::shared_ptr<NodeObject> object;

View File

@@ -25,7 +25,6 @@
#include <ripple/resource/ResourceManager.h>
#include <ripple/basics/Resolver.h>
#include <beast/threads/Stoppable.h>
#include <beast/module/core/files/File.h>
#include <boost/asio/io_service.hpp>
#include <boost/asio/ssl/context.hpp>

View File

@@ -22,7 +22,6 @@
#include <ripple/peerfinder/Slot.h>
#include <beast/chrono/abstract_clock.h>
#include <beast/module/core/files/File.h>
#include <beast/threads/Stoppable.h>
#include <beast/utility/PropertyStream.h>
#include <boost/asio/ip/tcp.hpp>

View File

@@ -20,6 +20,7 @@
#include <BeastConfig.h>
#include <ripple/basics/contract.h>
#include <ripple/protocol/ErrorCodes.h>
#include <cassert>
#include <unordered_map>
#include <utility>

View File

@@ -19,6 +19,7 @@
#include <BeastConfig.h>
#include <ripple/protocol/SField.h>
#include <cassert>
#include <map>
#include <memory>
#include <mutex>

View File

@@ -21,6 +21,7 @@
#include <ripple/resource/Consumer.h>
#include <ripple/resource/impl/Entry.h>
#include <ripple/resource/impl/Logic.h>
#include <cassert>
namespace ripple {
namespace Resource {
@@ -97,31 +98,31 @@ Disposition Consumer::disposition() const
Disposition Consumer::charge (Charge const& what)
{
bassert (m_entry != nullptr);
assert (m_entry != nullptr);
return m_logic->charge (*m_entry, what);
}
bool Consumer::warn ()
{
bassert (m_entry != nullptr);
assert (m_entry != nullptr);
return m_logic->warn (*m_entry);
}
bool Consumer::disconnect ()
{
bassert (m_entry != nullptr);
assert (m_entry != nullptr);
return m_logic->disconnect (*m_entry);
}
int Consumer::balance()
{
bassert (m_entry != nullptr);
assert (m_entry != nullptr);
return m_logic->balance (*m_entry);
}
Entry& Consumer::entry()
{
bassert (m_entry != nullptr);
assert (m_entry != nullptr);
return *m_entry;
}

View File

@@ -25,6 +25,7 @@
#include <ripple/resource/impl/Tuning.h>
#include <beast/chrono/abstract_clock.h>
#include <beast/intrusive/List.h>
#include <cassert>
namespace ripple {
namespace Resource {
@@ -58,7 +59,7 @@ struct Entry
case kindOutbound: return key->address.to_string();
case kindUnlimited: return std::string ("\"") + key->name + "\"";
default:
bassertfalse;
assert(false);
}
return "(undefined)";

View File

@@ -30,6 +30,7 @@
#include <beast/chrono/abstract_clock.h>
#include <beast/Insight.h>
#include <beast/utility/PropertyStream.h>
#include <cassert>
#include <mutex>
namespace ripple {
@@ -429,7 +430,7 @@ public:
admin_.iterator_to (entry));
break;
default:
bassertfalse;
assert(false);
break;
}
inactive_.push_back (entry);

View File

@@ -22,6 +22,7 @@
#include <ripple/protocol/TER.h>
#include <ripple/protocol/ErrorCodes.h>
#include <cassert>
namespace ripple {
namespace RPC {

View File

@@ -21,6 +21,7 @@
#include <ripple/rpc/Status.h>
#include <ripple/basics/contract.h>
#include <beast/unit_test/suite.h>
#include <algorithm>
namespace ripple {
namespace RPC {

View File

@@ -28,7 +28,6 @@
#include <beast/asio/error.h> // for is_short_read?
#include <beast/http/message.h>
#include <beast/http/parser.h>
#include <beast/module/core/time/Time.h>
#include <boost/asio/ip/tcp.hpp>
#include <boost/asio/ssl/stream.hpp>
#include <boost/asio/streambuf.hpp>
@@ -104,7 +103,6 @@ protected:
boost::system::error_code ec_;
clock_type::time_point when_;
std::string when_str_;
int request_count_ = 0;
std::size_t bytes_in_ = 0;
std::size_t bytes_out_ = 0;
@@ -248,8 +246,6 @@ Peer<Impl>::Peer (Door& door, boost::asio::io_service& io_service,
if (journal_.trace) journal_.trace << id_ <<
"accept: " << remote_address_.address();
when_ = clock_type::now();
when_str_ = beast::Time::getCurrentTime().formatted (
"%Y-%b-%d %H:%M:%S").toStdString();
}
template <class Impl>
@@ -257,7 +253,6 @@ Peer<Impl>::~Peer()
{
Stat stat;
stat.id = nid_;
stat.when = std::move (when_str_);
stat.elapsed = std::chrono::duration_cast <
std::chrono::seconds> (clock_type::now() - when_);
stat.requests = request_count_;

View File

@@ -90,7 +90,6 @@ ServerImpl::onWrite (beast::PropertyStream::Map& map)
beast::PropertyStream::Map item (set);
item ["id"] = stat.id;
item ["when"] = stat.when;
{
std::stringstream ss;

View File

@@ -45,7 +45,6 @@ class Door;
struct Stat
{
std::size_t id;
std::string when;
std::chrono::seconds elapsed;
int requests;
std::size_t bytes_in;

View File

@@ -19,12 +19,6 @@
#include <BeastConfig.h>
#ifndef NDEBUG
# define consistency_check(cond) bassert(cond)
#else
# define consistency_check(cond)
#endif
#include <ripple/peerfinder/impl/Bootcache.cpp>
#include <ripple/peerfinder/impl/PeerfinderConfig.cpp>
#include <ripple/peerfinder/impl/Endpoint.cpp>

View File

@@ -25,7 +25,6 @@
#include <ripple/protocol/RippleLedgerHash.h>
#include <beast/threads/Stoppable.h>
#include <beast/http/URL.h>
#include <beast/module/core/files/File.h>
#include <beast/utility/PropertyStream.h>
namespace ripple {