Remove dead TxQueue code

This commit is contained in:
David Schwartz
2014-11-10 14:04:20 -08:00
committed by Tom Ritchford
parent b7b744de94
commit d115a12cbe
12 changed files with 1 additions and 446 deletions

View File

@@ -2110,16 +2110,6 @@
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\tx\TransactionMeta.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\tx\TxQueue.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\tx\TxQueue.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\tx\TxQueueEntry.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\tx\TxQueueEntry.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\websocket\WSConnection.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
</ClCompile>

View File

@@ -3039,18 +3039,6 @@
<ClInclude Include="..\..\src\ripple\app\tx\TransactionMeta.h">
<Filter>ripple\app\tx</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\tx\TxQueue.cpp">
<Filter>ripple\app\tx</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\tx\TxQueue.h">
<Filter>ripple\app\tx</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\tx\TxQueueEntry.cpp">
<Filter>ripple\app\tx</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\tx\TxQueueEntry.h">
<Filter>ripple\app\tx</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\websocket\WSConnection.cpp">
<Filter>ripple\app\websocket</Filter>
</ClCompile>

View File

@@ -183,7 +183,6 @@ public:
std::unique_ptr <ServerHandler> serverHandler_;
std::unique_ptr <NodeStore::Database> m_nodeStore;
std::unique_ptr <SNTPClient> m_sntpClient;
std::unique_ptr <TxQueue> m_txQueue;
std::unique_ptr <Validators::Manager> m_validators;
std::unique_ptr <AmendmentTable> m_amendmentTable;
std::unique_ptr <LoadFeeTrack> mFeeTrack;
@@ -317,8 +316,6 @@ public:
, m_sntpClient (SNTPClient::New (*this))
, m_txQueue (TxQueue::New ())
, m_validators (add (Validators::Manager::New (
*this,
getConfig ().getModuleDatabasePath (),
@@ -464,11 +461,6 @@ public:
return *m_resourceManager;
}
TxQueue& getTxQueue ()
{
return *m_txQueue;
}
OrderBookDB& getOrderBookDB ()
{
return m_orderBookDB;

View File

@@ -55,7 +55,6 @@ class PathRequests;
class ProofOfWorkFactory;
class SerializedLedgerEntry;
class TransactionMaster;
class TxQueue;
class Validations;
class DatabaseCon;
@@ -117,7 +116,6 @@ public:
virtual NetworkOPs& getOPs () = 0;
virtual OrderBookDB& getOrderBookDB () = 0;
virtual TransactionMaster& getMasterTransaction () = 0;
virtual TxQueue& getTxQueue () = 0;
virtual LocalCredentials& getLocalCredentials () = 0;
virtual Resource::Manager& getResourceManager () = 0;
virtual PathRequests& getPathRequests () = 0;

View File

@@ -19,8 +19,6 @@
#include <ripple/app/book/Quality.h>
#include <ripple/app/misc/FeeVote.h>
#include <ripple/app/tx/TxQueue.h>
#include <ripple/app/tx/TxQueueEntry.h>
#include <ripple/basics/Time.h>
#include <ripple/basics/StringUtilities.h>
#include <ripple/basics/UptimeTimer.h>
@@ -195,7 +193,6 @@ public:
Transaction::ref tpTrans,
bool bAdmin, bool bLocal, bool bFailHard, bool bSubmit);
void runTransactionQueue ();
Transaction::pointer processTransactionCb (
Transaction::pointer,
bool bAdmin, bool bLocal, bool bFailHard, stCallback);
@@ -930,103 +927,6 @@ Transaction::pointer NetworkOPsImp::submitTransactionSync (
return tpTransNew;
}
void NetworkOPsImp::runTransactionQueue ()
{
TxQueueEntry::pointer txn;
for (int i = 0; i < 10; ++i)
{
getApp().getTxQueue ().getJob (txn);
if (!txn)
return;
{
auto ev = m_job_queue.getLoadEventAP (
jtTXN_PROC, "runTxnQ");
{
auto lock = getApp().masterLock();
auto dbtx = getApp().getMasterTransaction ().fetch (
txn->getID (), true);
assert (dbtx);
bool didApply;
TER r = m_ledgerMaster.doTransaction (
dbtx->getSTransaction (), tapOPEN_LEDGER | tapNO_CHECK_SIGN,
didApply);
dbtx->setResult (r);
if (isTemMalformed (r)) // malformed, cache bad
getApp().getHashRouter ().setFlag (txn->getID (), SF_BAD);
if (isTerRetry (r))
{
// transaction should be held
m_journal.debug << "QTransaction should be held: " << r;
dbtx->setStatus (HELD);
getApp().getMasterTransaction ().canonicalize (&dbtx);
m_ledgerMaster.addHeldTransaction (dbtx);
}
else if (r == tefPAST_SEQ)
{
// duplicate or conflict
m_journal.info << "QTransaction is obsolete";
dbtx->setStatus (OBSOLETE);
}
else if (r == tesSUCCESS)
{
m_journal.info
<< "QTransaction is now included in open ledger";
dbtx->setStatus (INCLUDED);
getApp().getMasterTransaction ().canonicalize (&dbtx);
}
else
{
m_journal.debug << "QStatus other than success " << r;
dbtx->setStatus (INVALID);
}
if (didApply /*|| (mMode != omFULL)*/ )
{
std::set <Peer::ShortId> peers;
if (getApp().getHashRouter ().swapSet (
txn->getID (), peers, SF_RELAYED))
{
m_journal.debug << "relaying";
protocol::TMTransaction tx;
Serializer s;
dbtx->getSTransaction ()->add (s);
tx.set_rawtransaction (
&s.getData ().front (), s.getLength ());
tx.set_status (protocol::tsCURRENT);
tx.set_receivetimestamp (getNetworkTimeNC ());
// FIXME: This should be when we received it
getApp ().overlay ().foreach (send_if_not (
std::make_shared<Message> (
tx, protocol::mtTRANSACTION),
peer_in_set(peers)));
}
else
m_journal.debug << "recently relayed";
}
txn->doCallbacks (r);
}
}
}
if (getApp().getTxQueue ().stopProcessing (txn))
{
getApp().getIOService ().post (std::bind (
&NetworkOPsImp::runTransactionQueue, this));
}
}
Transaction::pointer NetworkOPsImp::processTransactionCb (
Transaction::pointer trans,
bool bAdmin, bool bLocal, bool bFailHard, stCallback callback)

View File

@@ -145,7 +145,6 @@ public:
stCallback callback = stCallback ()) = 0;
virtual Transaction::pointer submitTransactionSync (Transaction::ref tpTrans,
bool bAdmin, bool bLocal, bool bFailHard, bool bSubmit) = 0;
virtual void runTransactionQueue () = 0;
virtual Transaction::pointer processTransactionCb (Transaction::pointer,
bool bAdmin, bool bLocal, bool bFailHard, stCallback) = 0;
virtual Transaction::pointer processTransaction (Transaction::pointer transaction,

View File

@@ -133,7 +133,7 @@ public:
pStB.step();
pStB.reset();
BOOST_FOREACH (NodeObject::Ptr const& object, batch)
for (NodeObject::Ptr const& object : batch)
{
doBind (pSt, object);

View File

@@ -1,151 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <ripple/app/tx/TxQueue.h>
#include <boost/bimap.hpp>
#include <boost/bimap/unordered_set_of.hpp>
#include <boost/bimap/list_of.hpp>
namespace ripple {
class TxQueueImp
: public TxQueue
, public beast::LeakChecked <TxQueueImp>
{
public:
TxQueueImp ()
: mRunning (false)
{
}
bool addEntryForSigCheck (TxQueueEntry::ref entry)
{
// we always dispatch a thread to check the signature
ScopedLockType sl (mLock);
if (!mTxMap.insert (valueType (entry->getID (), entry)).second)
{
if (!entry->mCallbacks.empty ())
mTxMap.left.find (entry->getID ())->second->addCallbacks (*entry);
return false;
}
return true;
}
bool addEntryForExecution (TxQueueEntry::ref entry)
{
ScopedLockType sl (mLock);
entry->mSigChecked = true;
std::pair<mapType::iterator, bool> it = mTxMap.insert (valueType (entry->getID (), entry));
if (!it.second)
{
// There was an existing entry
it.first->right->mSigChecked = true;
if (!entry->mCallbacks.empty ())
it.first->right->addCallbacks (*entry);
}
if (mRunning)
return false;
mRunning = true;
return true; // A thread needs to handle this account
}
TxQueueEntry::pointer removeEntry (uint256 const& id)
{
TxQueueEntry::pointer ret;
ScopedLockType sl (mLock);
mapType::left_map::iterator it = mTxMap.left.find (id);
if (it != mTxMap.left.end ())
{
ret = it->second;
mTxMap.left.erase (it);
}
return ret;
}
void getJob (TxQueueEntry::pointer& job)
{
ScopedLockType sl (mLock);
assert (mRunning);
if (job)
mTxMap.left.erase (job->getID ());
mapType::left_map::iterator it = mTxMap.left.begin ();
if (it == mTxMap.left.end () || !it->second->mSigChecked)
{
job.reset ();
mRunning = false;
}
else
job = it->second;
}
bool stopProcessing (TxQueueEntry::ref finishedJob)
{
// returns true if a new thread must be dispatched
ScopedLockType sl (mLock);
assert (mRunning);
mTxMap.left.erase (finishedJob->getID ());
mapType::left_map::iterator it = mTxMap.left.begin ();
if ((it != mTxMap.left.end ()) && it->second->mSigChecked)
return true;
mRunning = false;
return false;
}
private:
typedef boost::bimaps::unordered_set_of<uint256> leftType;
typedef boost::bimaps::list_of<TxQueueEntry::pointer> rightType;
typedef boost::bimap<leftType, rightType> mapType;
typedef mapType::value_type valueType;
typedef RippleMutex LockType;
typedef std::lock_guard <LockType> ScopedLockType;
LockType mLock;
mapType mTxMap;
bool mRunning;
};
//------------------------------------------------------------------------------
TxQueue* TxQueue::New ()
{
return new TxQueueImp;
}
} // ripple

View File

@@ -1,51 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef RIPPLE_TXQUEUE_H_INCLUDED
#define RIPPLE_TXQUEUE_H_INCLUDED
// VFALCO TODO merge TxQueueEntry.h into this file
#include <ripple/app/tx/TxQueueEntry.h>
namespace ripple {
class TxQueue : beast::LeakChecked <TxQueue>
{
public:
static TxQueue* New ();
virtual ~TxQueue () { }
// Return: true = must dispatch signature checker thread
virtual bool addEntryForSigCheck (TxQueueEntry::ref) = 0;
// Call only if signature is okay. Returns true if new account, must dispatch
virtual bool addEntryForExecution (TxQueueEntry::ref) = 0;
// Call if signature is bad (returns entry so you can run its callbacks)
virtual TxQueueEntry::pointer removeEntry (uint256 const& txID) = 0;
// Transaction execution interface
virtual void getJob (TxQueueEntry::pointer&) = 0;
virtual bool stopProcessing (TxQueueEntry::ref finishedJob) = 0;
};
} // ripple
#endif

View File

@@ -1,36 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#include <boost/foreach.hpp>
namespace ripple {
void TxQueueEntry::addCallbacks (const TxQueueEntry& otherEntry)
{
BOOST_FOREACH (const stCallback & callback, otherEntry.mCallbacks)
mCallbacks.push_back (callback);
}
void TxQueueEntry::doCallbacks (TER result)
{
BOOST_FOREACH (const stCallback & callback, mCallbacks)
callback (mTxn, result);
}
} // ripple

View File

@@ -1,71 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef RIPPLE_TXQUEUEENTRY_H_INCLUDED
#define RIPPLE_TXQUEUEENTRY_H_INCLUDED
namespace ripple {
// Allow transactions to be signature checked out of sequence but retired in sequence
class TxQueueEntry
{
public:
typedef std::shared_ptr<TxQueueEntry> pointer;
typedef const std::shared_ptr<TxQueueEntry>& ref;
typedef std::function<void (Transaction::pointer, TER)> stCallback; // must complete immediately
public:
TxQueueEntry (Transaction::ref tx, bool sigChecked) : mTxn (tx), mSigChecked (sigChecked)
{
}
TxQueueEntry () : mSigChecked (false)
{
}
Transaction::ref getTransaction () const
{
return mTxn;
}
bool getSigChecked () const
{
return mSigChecked;
}
uint256 const& getID () const
{
return mTxn->getID ();
}
void doCallbacks (TER);
private:
friend class TxQueueImp;
void addCallbacks (const TxQueueEntry& otherEntry);
Transaction::pointer mTxn;
bool mSigChecked;
std::list<stCallback> mCallbacks;
};
} // ripple
#endif

View File

@@ -26,9 +26,6 @@
#include <ripple/app/main/CollectorManager.cpp>
#include <ripple/app/main/NodeStoreScheduler.cpp>
#include <ripple/app/main/FatalErrorReporter.cpp>
#include <ripple/app/tx/TxQueueEntry.h>
#include <ripple/app/tx/TxQueueEntry.cpp>
#include <ripple/app/tx/TxQueue.cpp>
#include <ripple/app/websocket/WSServerHandler.cpp>
#include <ripple/app/websocket/WSConnection.cpp>
#include <ripple/app/websocket/WSDoor.cpp>