mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-25 05:25:55 +00:00
Tie in transaction master code.
This commit is contained in:
40
TransactionMaster.cpp
Normal file
40
TransactionMaster.cpp
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
#include "boost/bind.hpp"
|
||||
|
||||
#include "Application.h"
|
||||
#include "TransactionMaster.h"
|
||||
|
||||
#ifndef CACHED_TRANSACTION_NUM
|
||||
#define CACHED_TRANSACTION_NUM 65536
|
||||
#endif
|
||||
|
||||
#ifndef CACHED_TRANSACTION_AGE
|
||||
#define CACHED_TRANSACTION_AGE 1800
|
||||
#endif
|
||||
|
||||
TransactionMaster::TransactionMaster() : mCache(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;
|
||||
}
|
||||
|
||||
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->getIOService().post(boost::bind(&Transaction::saveTransaction, txn));
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user