Merge master (0.70.2) into develop (0.80.0-rc2)

This commit is contained in:
Nik Bougalis
2017-09-22 17:16:17 -07:00
736 changed files with 73760 additions and 30382 deletions

View File

@@ -18,40 +18,26 @@
//==============================================================================
#include <BeastConfig.h>
#include <ripple/overlay/impl/TMHello.h>
#include <ripple/overlay/impl/PeerImp.h>
#include <ripple/overlay/impl/Tuning.h>
#include <ripple/app/consensus/RCLValidations.h>
#include <ripple/app/ledger/InboundLedgers.h>
#include <ripple/app/ledger/LedgerMaster.h>
#include <ripple/consensus/LedgerTiming.h>
#include <ripple/app/ledger/InboundTransactions.h>
#include <ripple/app/misc/HashRouter.h>
#include <ripple/app/misc/LoadFeeTrack.h>
#include <ripple/app/misc/NetworkOPs.h>
#include <ripple/app/misc/Transaction.h>
#include <ripple/app/misc/Validations.h>
#include <ripple/app/misc/ValidatorList.h>
#include <ripple/app/tx/apply.h>
#include <ripple/protocol/digest.h>
#include <ripple/basics/random.h>
#include <ripple/basics/StringUtilities.h>
#include <ripple/basics/UptimeTimer.h>
#include <ripple/core/JobQueue.h>
#include <ripple/core/TimeKeeper.h>
#include <ripple/json/json_reader.h>
#include <ripple/resource/Fees.h>
#include <ripple/rpc/ServerHandler.h>
#include <ripple/overlay/Cluster.h>
#include <ripple/overlay/ClusterNode.h>
#include <ripple/protocol/BuildInfo.h>
#include <ripple/protocol/JsonFields.h>
#include <ripple/beast/core/SemanticVersion.h>
#include <ripple/beast/utility/weak_fn.h>
#include <beast/http/write.hpp>
#include <ripple/overlay/Cluster.h>
#include <ripple/protocol/digest.h>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/asio/io_service.hpp>
#include <algorithm>
#include <functional>
#include <memory>
#include <sstream>
@@ -91,7 +77,7 @@ PeerImp::PeerImp (Application& app, id_t id, endpoint_type remote_endpoint,
, fee_ (Resource::feeLightPeer)
, slot_ (slot)
, request_(std::move(request))
, headers_(request_.fields)
, headers_(request_)
{
}
@@ -225,8 +211,8 @@ PeerImp::send (Message::pointer const& m)
boost::asio::async_write (stream_, boost::asio::buffer(
send_queue_.front()->getBuffer()), strand_.wrap(std::bind(
&PeerImp::onWriteMessage, shared_from_this(),
beast::asio::placeholders::error,
beast::asio::placeholders::bytes_transferred)));
std::placeholders::_1,
std::placeholders::_2)));
}
void
@@ -248,7 +234,7 @@ PeerImp::crawl() const
auto const iter = headers_.find("Crawl");
if (iter == headers_.end())
return false;
return beast::detail::ci_equal(iter->second, "public");
return beast::detail::iequals(iter->value(), "public");
}
std::string
@@ -482,7 +468,7 @@ PeerImp::gracefulClose()
return;
setTimer();
stream_.async_shutdown(strand_.wrap(std::bind(&PeerImp::onShutdown,
shared_from_this(), beast::asio::placeholders::error)));
shared_from_this(), std::placeholders::_1)));
}
void
@@ -498,7 +484,7 @@ PeerImp::setTimer()
return;
}
timer_.async_wait(strand_.wrap(std::bind(&PeerImp::onTimer,
shared_from_this(), beast::asio::placeholders::error)));
shared_from_this(), std::placeholders::_1)));
}
// convenience for ignoring the error code
@@ -609,9 +595,9 @@ void PeerImp::doAccept()
// TODO Apply headers to connection state.
beast::write (write_buffer_, makeResponse(
beast::ostream(write_buffer_) << makeResponse(
! overlay_.peerFinder().config().peerPrivate,
request_, remote_address_, *sharedValue));
request_, remote_address_, *sharedValue);
auto const protocol = BuildInfo::make_protocol(hello_.protoversion());
JLOG(journal_.info()) << "Protocol: " << to_string(protocol);
@@ -657,17 +643,16 @@ PeerImp::makeResponse (bool crawl,
uint256 const& sharedValue)
{
http_response_type resp;
resp.status = 101;
resp.reason = "Switching Protocols";
resp.result(beast::http::status::switching_protocols);
resp.version = req.version;
resp.fields.insert("Connection", "Upgrade");
resp.fields.insert("Upgrade", "RTXP/1.2");
resp.fields.insert("Connect-AS", "Peer");
resp.fields.insert("Server", BuildInfo::getFullVersionString());
resp.fields.insert("Crawl", crawl ? "public" : "private");
resp.insert("Connection", "Upgrade");
resp.insert("Upgrade", "RTXP/1.2");
resp.insert("Connect-As", "Peer");
resp.insert("Server", BuildInfo::getFullVersionString());
resp.insert("Crawl", crawl ? "public" : "private");
protocol::TMHello hello = buildHello(sharedValue,
overlay_.setup().public_ip, remote, app_);
appendHello(resp.fields, hello);
appendHello(resp, hello);
return resp;
}
@@ -696,8 +681,8 @@ PeerImp::onWriteResponse (error_code ec, std::size_t bytes_transferred)
stream_.async_write_some (write_buffer_.data(),
strand_.wrap (std::bind (&PeerImp::onWriteResponse,
shared_from_this(), beast::asio::placeholders::error,
beast::asio::placeholders::bytes_transferred)));
shared_from_this(), std::placeholders::_1,
std::placeholders::_2)));
}
//------------------------------------------------------------------------------
@@ -771,8 +756,8 @@ PeerImp::onReadMessage (error_code ec, std::size_t bytes_transferred)
// Timeout on writes only
stream_.async_read_some (read_buffer_.prepare (Tuning::readBufferBytes),
strand_.wrap (std::bind (&PeerImp::onReadMessage,
shared_from_this(), beast::asio::placeholders::error,
beast::asio::placeholders::bytes_transferred)));
shared_from_this(), std::placeholders::_1,
std::placeholders::_2)));
}
void
@@ -801,15 +786,15 @@ PeerImp::onWriteMessage (error_code ec, std::size_t bytes_transferred)
return boost::asio::async_write (stream_, boost::asio::buffer(
send_queue_.front()->getBuffer()), strand_.wrap(std::bind(
&PeerImp::onWriteMessage, shared_from_this(),
beast::asio::placeholders::error,
beast::asio::placeholders::bytes_transferred)));
std::placeholders::_1,
std::placeholders::_2)));
}
if (gracefulClose_)
{
return stream_.async_shutdown(strand_.wrap(std::bind(
&PeerImp::onShutdown, shared_from_this(),
beast::asio::placeholders::error)));
std::placeholders::_1)));
}
}
@@ -1095,7 +1080,7 @@ PeerImp::onMessage (std::shared_ptr <protocol::TMTransaction> const& m)
flags |= SF_TRUSTED;
}
if (! app_.getOPs().getValidationPublicKey().size())
if (app_.getValidationPublicKey().empty())
{
// For now, be paranoid and have each validator
// check each transaction, regardless of source
@@ -1257,8 +1242,8 @@ PeerImp::onMessage (std::shared_ptr <protocol::TMProposeSet> const& m)
return;
}
if (app_.getOPs().getValidationPublicKey().size() &&
publicKey == app_.getOPs().getValidationPublicKey())
if (!app_.getValidationPublicKey().empty() &&
publicKey == app_.getValidationPublicKey())
{
JLOG(p_journal_.trace()) << "Proposal: self";
return;
@@ -1284,7 +1269,7 @@ PeerImp::onMessage (std::shared_ptr <protocol::TMProposeSet> const& m)
JLOG(p_journal_.trace()) <<
"Proposal: " << (isTrusted ? "trusted" : "UNTRUSTED");
auto proposal = std::make_shared<RCLCxPeerPos> (
auto proposal = RCLCxPeerPos(
publicKey, signature, suppression,
RCLCxPeerPos::Proposal{prevLedger, set.proposeseq (), proposeHash, closeTime,
app_.timeKeeper().closeTime(),calcNodeID(publicKey)});
@@ -1577,7 +1562,10 @@ PeerImp::onMessage (std::shared_ptr <protocol::TMValidation> const& m)
val->setSeen (closeTime);
}
if (! app_.getValidations().current (val))
if (! isCurrent(app_.getValidations().parms(),
app_.timeKeeper().closeTime(),
val->getSignTime(),
val->getSeenTime()))
{
JLOG(p_journal_.trace()) << "Validation: Not current";
fee_ = Resource::feeUnwantedData;
@@ -1887,7 +1875,7 @@ PeerImp::checkTransaction (int flags,
void
PeerImp::checkPropose (Job& job,
std::shared_ptr <protocol::TMProposeSet> const& packet,
RCLCxPeerPos::pointer peerPos)
RCLCxPeerPos peerPos)
{
bool isTrusted = (job.getType () == jtPROPOSAL_t);
@@ -1897,7 +1885,7 @@ PeerImp::checkPropose (Job& job,
assert (packet);
protocol::TMProposeSet& set = *packet;
if (! cluster() && !peerPos->checkSign ())
if (! cluster() && !peerPos.checkSign ())
{
JLOG(p_journal_.warn()) <<
"Proposal fails sig check";
@@ -1912,12 +1900,12 @@ PeerImp::checkPropose (Job& job,
}
else
{
if (app_.getOPs().getConsensusLCL() == peerPos->proposal().prevLedger())
if (app_.getOPs().getConsensusLCL() == peerPos.proposal().prevLedger())
{
// relay untrusted proposal
JLOG(p_journal_.trace()) <<
"relaying UNTRUSTED proposal";
overlay_.relay(set, peerPos->getSuppressionID());
overlay_.relay(set, peerPos.suppressionID());
}
else
{