diff --git a/src/cpp/ripple/NetworkOPs.cpp b/src/cpp/ripple/NetworkOPs.cpp index 21933a88be..3ae6f27753 100644 --- a/src/cpp/ripple/NetworkOPs.cpp +++ b/src/cpp/ripple/NetworkOPs.cpp @@ -1029,18 +1029,17 @@ void NetworkOPs::pubLedger(Ledger::ref lpAccepted) for (SHAMapItem::pointer item = txSet.peekFirstItem(); !!item; item = txSet.peekNextItem(item->getTag())) { - SerializedTransaction::pointer stTxn = theApp->getMasterTransaction().fetch(item, false, 0); - if(stTxn) - { - // XXX Need to support other results. - // XXX Need to give failures too. - TER terResult = tesSUCCESS; - - SerializerIterator it(item->peekSerializer()); + SerializerIterator it(item->peekSerializer()); - TransactionMetaSet::pointer meta = boost::make_shared(stTxn->getTransactionID(), lpAccepted->getLedgerSeq(), it.getVL()); - pubAcceptedTransaction(lpAccepted, *stTxn, terResult,meta); - } + // OPTIMIZEME: Could get transaction from txn master, but still must call getVL + Serializer txnSer(it.getVL()); + SerializerIterator txnIt(txnSer); + SerializedTransaction stTxn(txnIt); + + TransactionMetaSet::pointer meta = boost::make_shared( + stTxn.getTransactionID(), lpAccepted->getLedgerSeq(), it.getVL()); + + pubAcceptedTransaction(lpAccepted, stTxn, meta->getResultTER(), meta); } } } diff --git a/src/cpp/ripple/Serializer.h b/src/cpp/ripple/Serializer.h index 7b7b67fe25..4bb929b199 100644 --- a/src/cpp/ripple/Serializer.h +++ b/src/cpp/ripple/Serializer.h @@ -93,6 +93,7 @@ public: // totality functions const std::vector& peekData() const { return mData; } std::vector getData() const { return mData; } + std::vector& modData() { return mData; } int getCapacity() const { return mData.capacity(); } int getDataLength() const { return mData.size(); } const void* getDataPtr() const { return &mData.front(); } diff --git a/src/cpp/ripple/TransactionMaster.cpp b/src/cpp/ripple/TransactionMaster.cpp index bfa0a8b720..ed6b575d63 100644 --- a/src/cpp/ripple/TransactionMaster.cpp +++ b/src/cpp/ripple/TransactionMaster.cpp @@ -31,16 +31,29 @@ Transaction::pointer TransactionMaster::fetch(const uint256& txnID, bool checkDi return txn; } -SerializedTransaction::pointer TransactionMaster::fetch(SHAMapItem::ref item, bool checkDisk, uint32 uCommitLedger) +SerializedTransaction::pointer TransactionMaster::fetch(SHAMapItem::ref item, SHAMapTreeNode::TNType type, + bool checkDisk, uint32 uCommitLedger) { SerializedTransaction::pointer txn; Transaction::pointer iTx = theApp->getMasterTransaction().fetch(item->getTag(), false); if (!iTx) { - SerializerIterator sit(item->peekSerializer()); - txn = boost::make_shared(boost::ref(sit)); + if (type == SHAMapTreeNode::tnTRANSACTION_NM) + { + SerializerIterator sit(item->peekSerializer()); + txn = boost::make_shared(boost::ref(sit)); + } + else if (type == SHAMapTreeNode::tnTRANSACTION_MD) + { + Serializer s; + int length; + item->peekSerializer().getVL(s.modData(), 0, length); + SerializerIterator sit(s); + + txn = boost::make_shared(boost::ref(sit)); + } } else { diff --git a/src/cpp/ripple/TransactionMaster.h b/src/cpp/ripple/TransactionMaster.h index 138c05c9c0..2db5eb1701 100644 --- a/src/cpp/ripple/TransactionMaster.h +++ b/src/cpp/ripple/TransactionMaster.h @@ -16,7 +16,8 @@ public: TransactionMaster(); Transaction::pointer fetch(const uint256&, bool checkDisk); - SerializedTransaction::pointer fetch(SHAMapItem::ref item, bool checkDisk, uint32 uCommitLedger); + SerializedTransaction::pointer fetch(SHAMapItem::ref item, SHAMapTreeNode:: TNType type, + bool checkDisk, uint32 uCommitLedger); // return value: true = we had the transaction already bool canonicalize(Transaction::pointer& txn, bool maybeNew); diff --git a/src/cpp/ripple/TransactionMeta.h b/src/cpp/ripple/TransactionMeta.h index a22058089e..66f57b1cb7 100644 --- a/src/cpp/ripple/TransactionMeta.h +++ b/src/cpp/ripple/TransactionMeta.h @@ -37,6 +37,8 @@ public: const uint256& getTxID() { return mTransactionID; } uint32 getLgrSeq() { return mLedger; } + int getResult() const { return mResult; } + TER getResultTER() const { return static_cast(mResult); } bool isNodeAffected(const uint256&) const; void setAffectedNode(const uint256&, SField::ref type, uint16 nodeType); @@ -45,6 +47,7 @@ public: const STObject& peekAffectedNode(const uint256&) const; //std::vector getAffectedAccounts(); + Json::Value getJson(int p) const { return getAsObject().getJson(p); } void addRaw(Serializer&, TER);