diff --git a/src/ripple/app/paths/impl/DirectStep.cpp b/src/ripple/app/paths/impl/DirectStep.cpp index b96fa06e3..57738b3ad 100644 --- a/src/ripple/app/paths/impl/DirectStep.cpp +++ b/src/ripple/app/paths/impl/DirectStep.cpp @@ -595,6 +595,7 @@ TER DirectStepI::check (StrandContext const& ctx) const return temBAD_PATH; } + auto sleLine = ctx.view.read (keylet::line (src_, dst_, currency_)); { auto sleSrc = ctx.view.read (keylet::account (src_)); if (!sleSrc) @@ -605,8 +606,6 @@ TER DirectStepI::check (StrandContext const& ctx) const return terNO_ACCOUNT; } - auto sleLine = ctx.view.read (keylet::line (src_, dst_, currency_)); - if (!sleLine) { JLOG (j_.trace()) << "DirectStepI: No credit line. " << *this; @@ -643,6 +642,18 @@ TER DirectStepI::check (StrandContext const& ctx) const if (ter != tesSUCCESS) return ter; } + + if (fix1449(ctx.view.info().parentCloseTime)) + { + if (ctx.prevStep->bookStepBook()) + { + auto const noRippleSrcToDst = + ((*sleLine)[sfFlags] & + ((src_ > dst_) ? lsfHighNoRipple : lsfLowNoRipple)); + if (noRippleSrcToDst) + return terNO_RIPPLE; + } + } } { diff --git a/src/ripple/ledger/View.h b/src/ripple/ledger/View.h index 95d77dacd..d6717b5a2 100644 --- a/src/ripple/ledger/View.h +++ b/src/ripple/ledger/View.h @@ -347,6 +347,9 @@ bool amendmentRIPD1298 (NetClock::time_point const closeTime); NetClock::time_point const& amendmentRIPD1443SoTime (); bool amendmentRIPD1443 (NetClock::time_point const closeTime); +NetClock::time_point const& fix1449SoTime (); +bool fix1449 (NetClock::time_point const closeTime); + } // ripple #endif diff --git a/src/ripple/ledger/impl/View.cpp b/src/ripple/ledger/impl/View.cpp index 89aadb089..d2bd90caa 100644 --- a/src/ripple/ledger/impl/View.cpp +++ b/src/ripple/ledger/impl/View.cpp @@ -86,6 +86,20 @@ bool amendmentRIPD1443 (NetClock::time_point const closeTime) return closeTime > amendmentRIPD1443SoTime(); } +NetClock::time_point const& fix1449SoTime () +{ + using namespace std::chrono_literals; + // Thurs, Mar 30, 2017 01:00:00pm PDT + static NetClock::time_point const soTime{544219200s}; + + return soTime; +} + +bool fix1449 (NetClock::time_point const closeTime) +{ + return closeTime > fix1449SoTime(); +} + // VFALCO NOTE A copy of the other one for now /** Maximum number of entries in a directory page A change would be protocol-breaking. diff --git a/src/ripple/protocol/impl/Indexes.cpp b/src/ripple/protocol/impl/Indexes.cpp index c328395c1..2c4251e19 100644 --- a/src/ripple/protocol/impl/Indexes.cpp +++ b/src/ripple/protocol/impl/Indexes.cpp @@ -317,7 +317,7 @@ escrow (AccountID const& source, std::uint32_t seq) { sha512_half_hasher h; using beast::hash_append; - hash_append(h, spaceEscrow); + hash_append(h, std::uint16_t(spaceEscrow)); hash_append(h, source); hash_append(h, seq); return { ltESCROW, static_cast(h) }; @@ -328,7 +328,7 @@ payChan (AccountID const& source, AccountID const& dst, std::uint32_t seq) { sha512_half_hasher h; using beast::hash_append; - hash_append(h, spaceXRPUChannel); + hash_append(h, std::uint16_t(spaceXRPUChannel)); hash_append(h, source); hash_append(h, dst); hash_append(h, seq); diff --git a/src/ripple/server/impl/BasePeer.h b/src/ripple/server/impl/BasePeer.h index e7eac1ade..ba4efc607 100644 --- a/src/ripple/server/impl/BasePeer.h +++ b/src/ripple/server/impl/BasePeer.h @@ -50,7 +50,6 @@ protected: boost::asio::io_service::work work_; boost::asio::io_service::strand strand_; - error_code ec_; public: BasePeer(Port const& port, Handler& handler, @@ -61,11 +60,6 @@ public: void close() override; -protected: - template - void - fail(error_code ec, String const& what); - private: Impl& impl() @@ -87,7 +81,7 @@ BasePeer(Port const& port, Handler& handler, , remote_address_(remote_address) , sink_(journal.sink(), [] - { + { static std::atomic id{0}; return "##" + std::to_string(++id) + " "; }()) @@ -109,23 +103,6 @@ close() impl().ws_.lowest_layer().close(ec); } -template -template -void -BasePeer:: -fail(error_code ec, String const& what) -{ - assert(strand_.running_in_this_thread()); - if(! ec_ && - ec != boost::asio::error::operation_aborted) - { - ec_ = ec; - JLOG(j_.trace()) << - what << ": " << ec.message(); - impl().ws_.lowest_layer().close(ec); - } -} - } // ripple #endif diff --git a/src/ripple/server/impl/BaseWSPeer.h b/src/ripple/server/impl/BaseWSPeer.h index 24e83309f..124026e5a 100644 --- a/src/ripple/server/impl/BaseWSPeer.h +++ b/src/ripple/server/impl/BaseWSPeer.h @@ -42,15 +42,8 @@ protected: using error_code = boost::system::error_code; using endpoint_type = boost::asio::ip::tcp::endpoint; using waitable_timer = boost::asio::basic_waitable_timer ; - using BasePeer::fail; using BasePeer::strand_; - enum - { - // Max seconds without completing a message - timeoutSeconds = 30 - }; - private: friend class BasePeer; @@ -65,6 +58,7 @@ private: bool close_on_timer_ = false; bool ping_active_ = false; beast::websocket::ping_data payload_; + error_code ec_; public: template @@ -172,6 +166,10 @@ protected: void on_timer(error_code ec); + + template + void + fail(error_code ec, String const& what); }; //------------------------------------------------------------------------------ @@ -447,9 +445,10 @@ on_timer(error_code ec) return; if(! ec) { - if(! close_on_timer_ || !ping_active_) + if(! close_on_timer_ || ! ping_active_) { start_timer(); + close_on_timer_ = true; ping_active_ = true; // cryptographic is probably overkill.. beast::rngfill(payload_.begin(), @@ -460,7 +459,7 @@ on_timer(error_code ec) impl().shared_from_this(), std::placeholders::_1))); JLOG(this->j_.trace()) << - "sent pong"; + "sent ping"; return; } ec = boost::system::errc::make_error_code( @@ -469,6 +468,25 @@ on_timer(error_code ec) fail(ec, "timer"); } +template +template +void +BaseWSPeer:: +fail(error_code ec, String const& what) +{ + assert(strand_.running_in_this_thread()); + + cancel_timer(); + if(! ec_ && + ec != boost::asio::error::operation_aborted) + { + ec_ = ec; + JLOG(this->j_.trace()) << + what << ": " << ec.message(); + impl().ws_.lowest_layer().close(ec); + } +} + } // ripple #endif