From cf63b5c85915e1eca8b59c00925fbf645c1e52bd Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Sun, 9 Mar 2014 13:13:50 -0700 Subject: [PATCH] Fix logging transactions that throw --- src/ripple_data/protocol/Serializer.h | 9 +++++++++ src/ripple_overlay/impl/PeerImp.h | 13 ++++--------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/ripple_data/protocol/Serializer.h b/src/ripple_data/protocol/Serializer.h index fdcfde7c4..fb49ef840 100644 --- a/src/ripple_data/protocol/Serializer.h +++ b/src/ripple_data/protocol/Serializer.h @@ -217,6 +217,15 @@ public: return v.mData != mData; } + std::string getHex () const + { + std::stringstream h; + h << std::hex << std::setfill ('0'); + for (unsigned char const& element : mData) + h << std::setw (2) << element; + return h.str (); + } + // low-level VL length encode/decode functions static Blob encodeVL (int length); static int lengthVL (int length) diff --git a/src/ripple_overlay/impl/PeerImp.h b/src/ripple_overlay/impl/PeerImp.h index c9e62b33b..a8c013f96 100644 --- a/src/ripple_overlay/impl/PeerImp.h +++ b/src/ripple_overlay/impl/PeerImp.h @@ -1502,13 +1502,13 @@ private: void recvTransaction (protocol::TMTransaction& packet) { - Transaction::pointer tx; + + Serializer s (packet.rawtransaction ()); #ifndef TRUST_NETWORK try { #endif - Serializer s (packet.rawtransaction ()); SerializerIterator sit (s); SerializedTransaction::pointer stx = boost::make_shared (boost::ref (sit)); uint256 txID = stx->getTransactionID(); @@ -1548,13 +1548,8 @@ private: } catch (...) { - #ifdef BEAST_DEBUG - Log::out() << "Transaction from peer fails validity tests"; - Json::StyledStreamWriter w; - // VFALCO NOTE This bypasses the Log bottleneck - w.write (std::cerr, tx->getJson (0)); - #endif - return; + m_journal.warning << "Transaction invalid: " << + s.getHex(); } #endif }