Skip to content

Commit

Permalink
Convert code to use boost::beast
Browse files Browse the repository at this point in the history
  • Loading branch information
seelabs committed Jan 29, 2018
1 parent eaff9a0 commit cc9c976
Show file tree
Hide file tree
Showing 72 changed files with 471 additions and 1,104 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ env:
# to boost's .tar.gz.
- LCOV_ROOT=$HOME/lcov
- GDB_ROOT=$HOME/gdb
- BOOST_ROOT=$HOME/boost_1_60_0
- BOOST_URL='http://sourceforge.net/projects/boost/files/boost/1.60.0/boost_1_60_0.tar.gz'
- BOOST_ROOT=$HOME/boost_1_66_0
- BOOST_URL='http://sourceforge.net/projects/boost/files/boost/1.66.0/boost_1_66_0.tar.gz'

# Travis is timing out on Trusty. So, for now, use Precise. July 2017
dist: precise
Expand Down
2 changes: 1 addition & 1 deletion Builds/Ubuntu/install_boost.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This script builds boost with the correct ABI flags for ubuntu
#

version=63
version=66
patch=0

if hash lsb_release 2>/dev/null; then
Expand Down
260 changes: 4 additions & 256 deletions Builds/VisualStudio2015/RippleD.vcxproj

Large diffs are not rendered by default.

414 changes: 0 additions & 414 deletions Builds/VisualStudio2015/RippleD.vcxproj.filters

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ check_gcc4_abi()
include_directories(
src
src/beast
src/beast/include
src/beast/extras
src/nudb/include
src/soci/src
Expand Down
1 change: 1 addition & 0 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ try {
withEnv(["CCACHE_BASEDIR=${cdir}",
"CCACHE_NOHASHDIR=true",
'LCOV_ROOT=""',
'BOOST_ROOT=/opt/local/boost_1_66_0',
"TARGET=${target}",
"CC=${compiler}",
'BUILD=cmake',
Expand Down
1 change: 0 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,6 @@ config_base(base)
base.Append(CPPPATH=[
'src',
os.path.join('src', 'beast'),
os.path.join('src', 'beast', 'include'),
os.path.join('src', 'beast', 'extras'),
os.path.join('src', 'nudb', 'include'),
os.path.join(build_dir, 'proto'),
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ environment:
# that it's a small download. We also use appveyor's free cache, avoiding fees
# downloading from S3 each time.
# TODO: script to create this package.
RIPPLED_DEPS_PATH: rippled_deps17.01
RIPPLED_DEPS_PATH: rippled_deps17.02
RIPPLED_DEPS_URL: https://ripple.github.io/Downloads/appveyor/%RIPPLED_DEPS_PATH%.zip

# Other dependencies we just download each time.
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/app/main/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1686,7 +1686,7 @@ bool ApplicationImp::loadOldLedger (
}
}
}
else if (ledgerID.empty () || beast::detail::iequals(ledgerID, "latest"))
else if (ledgerID.empty () || boost::beast::detail::iequals(ledgerID, "latest"))
{
loadLedger = getLastFullLedger ();
}
Expand Down
3 changes: 1 addition & 2 deletions src/ripple/app/main/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,10 @@
#include <ripple/core/Config.h>
#include <ripple/protocol/Protocol.h>
#include <ripple/beast/utility/PropertyStream.h>
#include <boost/asio.hpp>
#include <memory>
#include <mutex>

namespace boost { namespace asio { class io_service; } }

namespace ripple {

namespace unl { class Manager; }
Expand Down
2 changes: 1 addition & 1 deletion src/ripple/app/misc/NetworkOPs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
#include <ripple/beast/core/SystemStats.h>
#include <ripple/beast/utility/rngfill.h>
#include <ripple/basics/make_lock.h>
#include <beast/core/detail/base64.hpp>
#include <boost/beast/core/detail/base64.hpp>
#include <boost/asio/steady_timer.hpp>

namespace ripple {
Expand Down
1 change: 1 addition & 0 deletions src/ripple/app/misc/NetworkOPs.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <ripple/ledger/ReadView.h>
#include <ripple/net/InfoSub.h>
#include <ripple/protocol/STValidation.h>
#include <boost/asio.hpp>
#include <memory>
#include <deque>
#include <tuple>
Expand Down
6 changes: 3 additions & 3 deletions src/ripple/app/misc/detail/Work.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@
#ifndef RIPPLE_APP_MISC_DETAIL_WORK_H_INCLUDED
#define RIPPLE_APP_MISC_DETAIL_WORK_H_INCLUDED

#include <beast/http/message.hpp>
#include <beast/http/string_body.hpp>
#include <boost/beast/http/message.hpp>
#include <boost/beast/http/string_body.hpp>

namespace ripple {

namespace detail {

using response_type =
beast::http::response<beast::http::string_body>;
boost::beast::http::response<boost::beast::http::string_body>;

class Work
{
Expand Down
20 changes: 10 additions & 10 deletions src/ripple/app/misc/detail/WorkBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@

#include <ripple/app/misc/detail/Work.h>
#include <ripple/protocol/BuildInfo.h>
#include <beast/core/multi_buffer.hpp>
#include <beast/http/empty_body.hpp>
#include <beast/http/read.hpp>
#include <beast/http/write.hpp>
#include <boost/beast/core/multi_buffer.hpp>
#include <boost/beast/http/empty_body.hpp>
#include <boost/beast/http/read.hpp>
#include <boost/beast/http/write.hpp>
#include <boost/asio.hpp>

namespace ripple {
Expand All @@ -48,7 +48,7 @@ class WorkBase
using resolver_type = boost::asio::ip::tcp::resolver;
using query_type = resolver_type::query;
using request_type =
beast::http::request<beast::http::empty_body>;
boost::beast::http::request<boost::beast::http::empty_body>;

std::string host_;
std::string path_;
Expand All @@ -60,7 +60,7 @@ class WorkBase
socket_type socket_;
request_type req_;
response_type res_;
beast::multi_buffer read_buf_;
boost::beast::multi_buffer read_buf_;

public:
WorkBase(
Expand Down Expand Up @@ -177,14 +177,14 @@ template<class Impl>
void
WorkBase<Impl>::onStart()
{
req_.method(beast::http::verb::get);
req_.method(boost::beast::http::verb::get);
req_.target(path_.empty() ? "/" : path_);
req_.version = 11;
req_.version(11);
req_.set (
"Host", host_ + ":" + port_);
req_.set ("User-Agent", BuildInfo::getFullVersionString());
req_.prepare_payload();
beast::http::async_write(impl().stream(), req_,
boost::beast::http::async_write(impl().stream(), req_,
strand_.wrap (std::bind (&WorkBase::onRequest,
impl().shared_from_this(), std::placeholders::_1)));
}
Expand All @@ -196,7 +196,7 @@ WorkBase<Impl>::onRequest(error_code const& ec)
if (ec)
return fail(ec);

beast::http::async_read (impl().stream(), read_buf_, res_,
boost::beast::http::async_read (impl().stream(), read_buf_, res_,
strand_.wrap (std::bind (&WorkBase::onResponse,
impl().shared_from_this(), std::placeholders::_1)));
}
Expand Down
8 changes: 4 additions & 4 deletions src/ripple/app/misc/impl/Manifest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <ripple/json/json_reader.h>
#include <ripple/protocol/PublicKey.h>
#include <ripple/protocol/Sign.h>
#include <beast/core/detail/base64.hpp>
#include <boost/beast/core/detail/base64.hpp>
#include <boost/regex.hpp>
#include <numeric>
#include <stdexcept>
Expand Down Expand Up @@ -184,7 +184,7 @@ ValidatorToken::make_ValidatorToken(std::vector<std::string> const& tokenBlob)
for (auto const& line : tokenBlob)
tokenStr += beast::rfc2616::trim(line);

tokenStr = beast::detail::base64_decode(tokenStr);
tokenStr = boost::beast::detail::base64_decode(tokenStr);

Json::Reader r;
Json::Value token;
Expand Down Expand Up @@ -386,7 +386,7 @@ ManifestCache::load (
if (! configManifest.empty())
{
auto mo = Manifest::make_Manifest (
beast::detail::base64_decode(configManifest));
boost::beast::detail::base64_decode(configManifest));
if (! mo)
{
JLOG (j_.error()) << "Malformed validator_token in config";
Expand Down Expand Up @@ -421,7 +421,7 @@ ManifestCache::load (
revocationStr += beast::rfc2616::trim(line);

auto mo = Manifest::make_Manifest (
beast::detail::base64_decode(revocationStr));
boost::beast::detail::base64_decode(revocationStr));

if (! mo || ! mo->revoked() ||
applyManifest (std::move(*mo)) == ManifestDisposition::invalid)
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/app/misc/impl/ValidatorKeys.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <ripple/basics/Log.h>
#include <ripple/core/Config.h>
#include <ripple/core/ConfigSections.h>
#include <beast/core/detail/base64.hpp>
#include <boost/beast/core/detail/base64.hpp>

namespace ripple {
ValidatorKeys::ValidatorKeys(Config const& config, beast::Journal j)
Expand All @@ -46,7 +46,7 @@ ValidatorKeys::ValidatorKeys(Config const& config, beast::Journal j)
auto const pk = derivePublicKey(
KeyType::secp256k1, token->validationSecret);
auto const m = Manifest::make_Manifest(
beast::detail::base64_decode(token->manifest));
boost::beast::detail::base64_decode(token->manifest));

if (! m || pk != m->signingKey)
{
Expand Down
8 changes: 4 additions & 4 deletions src/ripple/app/misc/impl/ValidatorList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <ripple/basics/StringUtilities.h>
#include <ripple/json/json_reader.h>
#include <ripple/protocol/JsonFields.h>
#include <beast/core/detail/base64.hpp>
#include <boost/beast/core/detail/base64.hpp>
#include <boost/regex.hpp>

namespace ripple {
Expand Down Expand Up @@ -291,7 +291,7 @@ ValidatorList::applyList (
for (auto const& valManifest : manifests)
{
auto m = Manifest::make_Manifest (
beast::detail::base64_decode(valManifest));
boost::beast::detail::base64_decode(valManifest));

if (! m || ! keyListings_.count (m->masterKey))
{
Expand Down Expand Up @@ -321,7 +321,7 @@ ValidatorList::verify (
std::string const& blob,
std::string const& signature)
{
auto m = Manifest::make_Manifest (beast::detail::base64_decode(manifest));
auto m = Manifest::make_Manifest (boost::beast::detail::base64_decode(manifest));

if (! m || ! publisherLists_.count (m->masterKey))
return ListDisposition::untrusted;
Expand All @@ -342,7 +342,7 @@ ValidatorList::verify (
return ListDisposition::untrusted;

auto const sig = strUnHex(signature);
auto const data = beast::detail::base64_decode (blob);
auto const data = boost::beast::detail::base64_decode (blob);
if (! sig.second ||
! ripple::verify (
publisherManifests_.getSigningKey(pubKey),
Expand Down
6 changes: 3 additions & 3 deletions src/ripple/app/misc/impl/ValidatorSite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <ripple/basics/Slice.h>
#include <ripple/json/json_reader.h>
#include <ripple/protocol/JsonFields.h>
#include <beast/core/detail/base64.hpp>
#include <boost/beast/core/detail/base64.hpp>
#include <boost/regex.hpp>

namespace ripple {
Expand Down Expand Up @@ -207,7 +207,7 @@ ValidatorSite::onSiteFetch(
detail::response_type&& res,
std::size_t siteIdx)
{
if (! ec && res.result() != beast::http::status::ok)
if (! ec && res.result() != boost::beast::http::status::ok)
{
std::lock_guard <std::mutex> lock{sites_mutex_};
JLOG (j_.warn()) <<
Expand All @@ -222,7 +222,7 @@ ValidatorSite::onSiteFetch(
std::lock_guard <std::mutex> lock{sites_mutex_};
Json::Reader r;
Json::Value body;
if (r.parse(res.body.data(), body) &&
if (r.parse(res.body().data(), body) &&
body.isObject () &&
body.isMember("blob") && body["blob"].isString () &&
body.isMember("manifest") && body["manifest"].isString () &&
Expand Down
6 changes: 3 additions & 3 deletions src/ripple/basics/BasicConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <ripple/basics/contract.h>
#include <beast/unit_test/detail/const_container.hpp>
#include <beast/core/string.hpp>
#include <boost/beast/core/string.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/optional.hpp>
#include <map>
Expand All @@ -41,7 +41,7 @@ using IniFileSections = std::map<std::string, std::vector<std::string>>;
*/
class Section
: public beast::unit_test::detail::const_container <
std::map <std::string, std::string, beast::iless>>
std::map <std::string, std::string, boost::beast::iless>>
{
private:
std::string name_;
Expand Down Expand Up @@ -173,7 +173,7 @@ class Section
class BasicConfig
{
private:
std::map <std::string, Section, beast::iless> map_;
std::map <std::string, Section, boost::beast::iless> map_;

public:
/** Returns `true` if a section with the given name exists. */
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/basics/Log.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#define RIPPLE_BASICS_LOG_H_INCLUDED

#include <ripple/basics/UnorderedContainers.h>
#include <beast/core/string.hpp>
#include <boost/beast/core/string.hpp>
#include <ripple/beast/utility/Journal.h>
#include <boost/filesystem.hpp>
#include <map>
Expand Down Expand Up @@ -148,7 +148,7 @@ class Logs
std::mutex mutable mutex_;
std::map <std::string,
std::unique_ptr<beast::Journal::Sink>,
beast::iless> sinks_;
boost::beast::iless> sinks_;
beast::severities::Severity thresh_;
File file_;
bool silent_ = false;
Expand Down
4 changes: 2 additions & 2 deletions src/ripple/basics/random.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <ripple/basics/win32_workaround.h>
#include <ripple/beast/xor_shift_engine.h>
#include <beast/core/detail/type_traits.hpp>
#include <boost/beast/core/detail/type_traits.hpp>
#include <boost/thread/tss.hpp>
#include <cassert>
#include <cstddef>
Expand Down Expand Up @@ -52,7 +52,7 @@ namespace detail {
// Determines if a type can be called like an Engine
template <class Engine, class Result = typename Engine::result_type>
using is_engine =
beast::detail::is_invocable<Engine, Result()>;
boost::beast::detail::is_invocable<Engine, Result()>;
}

/** Return the default random engine.
Expand Down
Loading

0 comments on commit cc9c976

Please sign in to comment.