diff --git a/src/LedgerConsensus.cpp b/src/LedgerConsensus.cpp index 44d2807ff8..f7199a886b 100644 --- a/src/LedgerConsensus.cpp +++ b/src/LedgerConsensus.cpp @@ -9,6 +9,8 @@ #include "SerializedValidation.h" #include "Log.h" +#define TRUST_NETWORK + TransactionAcquire::TransactionAcquire(const uint256& hash) : PeerSet(hash, 1), mHaveRoot(false) { mMap = boost::make_shared(); @@ -525,7 +527,8 @@ bool LedgerConsensus::peerPosition(LedgerProposal::pointer newPosition) return true; } } - Log(lsINFO) << "Peer changes position"; + Log(lsINFO) << "Peer position " << newPosition->getProposeSeq() << "/" + << newPosition->getCurrentHash().GetHex(); currentPosition = newPosition; SHAMap::pointer set = getTransactionTree(newPosition->getCurrentHash(), true); if (set) @@ -595,10 +598,12 @@ void LedgerConsensus::applyTransactions(SHAMap::pointer set, Ledger::pointer led while (item) { Log(lsINFO) << "Processing candidate transaction: " << item->getTag().GetHex(); +#ifndef TRUST_NETWORK try { +#endif SerializerIterator sit(item->peekSerializer()); - SerializedTransaction::pointer txn = boost::make_shared(boost::ref(sit), 0); + SerializedTransaction::pointer txn = boost::make_shared(boost::ref(sit)); TransactionEngineResult result = engine.applyTransaction(*txn, tepNO_CHECK_FEE); if (result > 0) { @@ -616,11 +621,13 @@ void LedgerConsensus::applyTransactions(SHAMap::pointer set, Ledger::pointer led Log(lsINFO) << " hard fail"; assert(!ledger->hasTransaction(item->getTag())); } +#ifndef TRUST_NETWORK } catch (...) { Log(lsWARNING) << " Throws"; } +#endif item = set->peekNextItem(item->getTag()); } diff --git a/src/Peer.cpp b/src/Peer.cpp index 7610b6416b..df953d0448 100644 --- a/src/Peer.cpp +++ b/src/Peer.cpp @@ -580,7 +580,7 @@ void Peer::recvTransaction(newcoin::TMTransaction& packet) std::string rawTx = packet.rawtransaction(); Serializer s(std::vector(rawTx.begin(), rawTx.end())); SerializerIterator sit(s); - SerializedTransaction::pointer stx = boost::make_shared(boost::ref(sit), -1); + SerializedTransaction::pointer stx = boost::make_shared(boost::ref(sit)); tx = boost::make_shared(stx, true); if (tx->getStatus() == INVALID) throw(0); diff --git a/src/SerializedTransaction.cpp b/src/SerializedTransaction.cpp index dda530c453..9f66a25ebe 100644 --- a/src/SerializedTransaction.cpp +++ b/src/SerializedTransaction.cpp @@ -17,12 +17,14 @@ SerializedTransaction::SerializedTransaction(TransactionType type) : mType(type) mInnerTxn = STObject(mFormat->elements, "InnerTransaction"); } -SerializedTransaction::SerializedTransaction(SerializerIterator& sit, int length) +SerializedTransaction::SerializedTransaction(SerializerIterator& sit) { - if (length == -1) length = sit.getBytesLeft(); - else if (length == 0) length = sit.get32(); + int length = sit.getBytesLeft(); if ((length < TransactionMinLen) || (length > TransactionMaxLen)) + { + Log(lsERROR) << "Transaction has invalid length: " << length; throw std::runtime_error("Transaction length invalid"); + } mSignature.setValue(sit.getVL()); diff --git a/src/SerializedTransaction.h b/src/SerializedTransaction.h index 24d412b679..3e84ab3bf4 100644 --- a/src/SerializedTransaction.h +++ b/src/SerializedTransaction.h @@ -26,7 +26,7 @@ protected: SerializedTransaction* duplicate() const { return new SerializedTransaction(*this); } public: - SerializedTransaction(SerializerIterator& sit, int length); // -1=all remaining, 0=get from sit + SerializedTransaction(SerializerIterator& sit); SerializedTransaction(TransactionType type); // STObject functions diff --git a/src/Transaction.cpp b/src/Transaction.cpp index aa9427bbf6..f102710cfb 100644 --- a/src/Transaction.cpp +++ b/src/Transaction.cpp @@ -37,7 +37,7 @@ Transaction::pointer Transaction::sharedTransaction(const std::vector(boost::ref(sit), -1); + SerializedTransaction::pointer st = boost::make_shared(boost::ref(sit)); return boost::make_shared(st, bValidate); } @@ -396,7 +396,7 @@ Transaction::pointer Transaction::transactionFromSQL(const std::string& sql) Serializer s(rawTxn); SerializerIterator it(s); - SerializedTransaction::pointer txn = boost::make_shared(boost::ref(it), -1); + SerializedTransaction::pointer txn = boost::make_shared(boost::ref(it)); Transaction::pointer tr = boost::make_shared(txn, true); TransStatus st(INVALID); diff --git a/src/TransactionEngine.cpp b/src/TransactionEngine.cpp index 54efec9de5..7ec2a40857 100644 --- a/src/TransactionEngine.cpp +++ b/src/TransactionEngine.cpp @@ -241,7 +241,7 @@ TransactionEngineResult TransactionEngine::applyTransaction(const SerializedTran Serializer ser; txn.add(ser); SerializerIterator sit(ser); - SerializedTransaction s2(sit, -1); + SerializedTransaction s2(sit); if (!s2.isEquivalent(txn)) { std::cerr << "Transaction serdes mismatch" << std::endl;