From 13b33b5d4d4e6178d6e9d09b27b0dbcf60342b8e Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Thu, 9 Jul 2015 16:12:56 -0700 Subject: [PATCH] Store STTx in JTx Conflicts: src/ripple/test/jtx/impl/Env.cpp --- src/ripple/test/jtx/Env.h | 4 +- src/ripple/test/jtx/JTx.h | 69 +++++++++++++++++--------------- src/ripple/test/jtx/impl/Env.cpp | 8 ++-- 3 files changed, 42 insertions(+), 39 deletions(-) diff --git a/src/ripple/test/jtx/Env.h b/src/ripple/test/jtx/Env.h index e950eb31f..9171e3156 100644 --- a/src/ripple/test/jtx/Env.h +++ b/src/ripple/test/jtx/Env.h @@ -286,6 +286,7 @@ public: JTx jt(std::forward(jv)); invoke(jt, fN...); autofill(jt); + jt.stx = st(jt); return jt; } @@ -460,8 +461,7 @@ protected: Throws: parse_error */ - // VFALCO NOTE This should be - std::shared_ptr + std::shared_ptr st (JTx const& jt); ApplyFlags diff --git a/src/ripple/test/jtx/JTx.h b/src/ripple/test/jtx/JTx.h index b6dce761c..9cfa0aab3 100644 --- a/src/ripple/test/jtx/JTx.h +++ b/src/ripple/test/jtx/JTx.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -40,38 +41,41 @@ class Env; struct JTx { Json::Value jv; + requires_t requires; + TER ter = tesSUCCESS; bool fill_fee = true; bool fill_seq = true; bool fill_sig = true; + std::shared_ptr stx; std::function signer; - requires_t requires; - TER ter = tesSUCCESS; JTx() = default; #if defined(_MSC_VER) && _MSC_VER <= 1800 - JTx(JTx&& src) - : jv(std::move(src.jv)) - , fill_fee(std::move(src.fill_fee)) - , fill_seq(std::move(src.fill_seq)) - , fill_sig(std::move(src.fill_sig)) - , signer(std::move(src.signer)) - , requires(std::move(src.requires)) - , ter(std::move(src.ter)) - , props_(std::move(src.props_)) + JTx(JTx&& other) + : jv(std::move(other.jv)) + , requires(std::move(other.requires)) + , ter(std::move(other.ter)) + , fill_fee(std::move(other.fill_fee)) + , fill_seq(std::move(other.fill_seq)) + , fill_sig(std::move(other.fill_sig)) + , stx(std::move(other.stx)) + , signer(std::move(other.signer)) + , props_(std::move(other.props_)) { } - JTx& operator=(JTx&& src) noexcept + JTx& operator=(JTx&& other) noexcept { - jv = std::move(src.jv); - fill_fee = std::move(src.fill_fee); - fill_seq = std::move(src.fill_seq); - fill_sig = std::move(src.fill_sig); - signer = std::move(src.signer); - requires = std::move(src.requires); - ter = std::move(src.ter); - props_ = std::move(src.props_); + jv = std::move(other.jv); + requires = std::move(other.requires); + ter = std::move(other.ter); + fill_fee = std::move(other.fill_fee); + fill_seq = std::move(other.fill_seq); + fill_sig = std::move(other.fill_sig); + stx = std::move(other.stx); + signer = std::move(other.signer); + props_ = std::move(other.props_); return *this; } @@ -94,7 +98,6 @@ struct JTx return jv[key]; } -public: /** Return a property if it exists @return nullptr if the Prop does not exist @@ -164,38 +167,38 @@ private: { prop_list() = default; - prop_list(prop_list const& src) + prop_list(prop_list const& other) { - for (auto const& prop : src.list) + for (auto const& prop : other.list) list.emplace_back(prop->clone()); } - prop_list& operator=(prop_list const& src) + prop_list& operator=(prop_list const& other) { - if (this != &src) + if (this != &other) { list.clear(); - for (auto const& prop : src.list) + for (auto const& prop : other.list) list.emplace_back(prop->clone()); } return *this; } -#if defined(_MSC_VER) && _MSC_VER <= 1800 - prop_list(prop_list&& src) - : list(std::move(src.list)) + #if defined(_MSC_VER) && _MSC_VER <= 1800 + prop_list(prop_list&& other) + : list(std::move(other.list)) { } - prop_list& operator=(prop_list&& src) + prop_list& operator=(prop_list&& other) { - list = std::move(src.list); + list = std::move(other.list); return *this; } -#else + #else prop_list(prop_list&& src) = default; prop_list& operator=(prop_list&& src) = default; -#endif + #endif std::vector> list; diff --git a/src/ripple/test/jtx/impl/Env.cpp b/src/ripple/test/jtx/impl/Env.cpp index 4bfd30398..2ba0c5c55 100644 --- a/src/ripple/test/jtx/impl/Env.cpp +++ b/src/ripple/test/jtx/impl/Env.cpp @@ -253,9 +253,9 @@ Env::trust (STAmount const& amount, void Env::submit (JTx const& jt) { - auto stx = st(jt); TER ter; bool didApply; + auto const& stx = jt.stx; if (stx) { openLedger.modify( @@ -270,8 +270,8 @@ Env::submit (JTx const& jt) } else { - // Convert the exception into a TER so that - // callers can expect it using ter(temMALFORMED) + // Parsing failed or the JTx is + // otherwise missing the stx field. ter = temMALFORMED; didApply = false; } @@ -338,7 +338,7 @@ Env::autofill (JTx& jt) } } -std::shared_ptr +std::shared_ptr Env::st (JTx const& jt) { // The parse must succeed, since we