mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Moved cpp code to src/cpp and js code to src/js.
This commit is contained in:
65
src/cpp/ripple/TransactionMaster.cpp
Normal file
65
src/cpp/ripple/TransactionMaster.cpp
Normal file
@@ -0,0 +1,65 @@
|
||||
|
||||
#include "TransactionMaster.h"
|
||||
|
||||
#include <boost/bind.hpp>
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
#ifndef CACHED_TRANSACTION_NUM
|
||||
#define CACHED_TRANSACTION_NUM 65536
|
||||
#endif
|
||||
|
||||
#ifndef CACHED_TRANSACTION_AGE
|
||||
#define CACHED_TRANSACTION_AGE 1800
|
||||
#endif
|
||||
|
||||
TransactionMaster::TransactionMaster() : mCache("TransactionCache", CACHED_TRANSACTION_NUM, CACHED_TRANSACTION_AGE)
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
Transaction::pointer TransactionMaster::fetch(const uint256& txnID, bool checkDisk)
|
||||
{
|
||||
Transaction::pointer txn = mCache.fetch(txnID);
|
||||
if (!checkDisk || txn) return txn;
|
||||
|
||||
txn = Transaction::load(txnID);
|
||||
if (!txn) return txn;
|
||||
|
||||
mCache.canonicalize(txnID, txn);
|
||||
|
||||
return txn;
|
||||
}
|
||||
|
||||
SerializedTransaction::pointer TransactionMaster::fetch(SHAMapItem::ref item, 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<SerializedTransaction>(boost::ref(sit));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (uCommitLedger)
|
||||
iTx->setStatus(COMMITTED, uCommitLedger);
|
||||
|
||||
txn = iTx->getSTransaction();
|
||||
}
|
||||
|
||||
return txn;
|
||||
}
|
||||
|
||||
bool TransactionMaster::canonicalize(Transaction::pointer& txn, bool may_be_new)
|
||||
{
|
||||
uint256 tid = txn->getID();
|
||||
if (!tid) return false;
|
||||
if (mCache.canonicalize(tid, txn)) return true;
|
||||
if (may_be_new)
|
||||
theApp->getAuxService().post(boost::bind(&Transaction::saveTransaction, txn));
|
||||
return false;
|
||||
}
|
||||
// vim:ts=4
|
||||
Reference in New Issue
Block a user