mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
still working
This commit is contained in:
@@ -147,6 +147,8 @@ void Application::setup()
|
|||||||
else
|
else
|
||||||
startNewLedger();
|
startNewLedger();
|
||||||
|
|
||||||
|
mOrderBookDB.setup(theApp->getLedgerMaster().getCurrentLedger()); // TODO: We need to update this if the ledger jumps
|
||||||
|
|
||||||
//
|
//
|
||||||
// Begin validation and ip maintenance.
|
// Begin validation and ip maintenance.
|
||||||
// - Wallet maintains local information: including identity and network connection persistence information.
|
// - Wallet maintains local information: including identity and network connection persistence information.
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "ProofOfWork.h"
|
#include "ProofOfWork.h"
|
||||||
#include "LoadManager.h"
|
#include "LoadManager.h"
|
||||||
#include "TransactionQueue.h"
|
#include "TransactionQueue.h"
|
||||||
|
#include "OrderBookDB.h"
|
||||||
|
|
||||||
class RPCDoor;
|
class RPCDoor;
|
||||||
class PeerDoor;
|
class PeerDoor;
|
||||||
@@ -66,6 +67,7 @@ class Application
|
|||||||
LoadManager mLoadMgr;
|
LoadManager mLoadMgr;
|
||||||
LoadFeeTrack mFeeTrack;
|
LoadFeeTrack mFeeTrack;
|
||||||
TXQueue mTxnQueue;
|
TXQueue mTxnQueue;
|
||||||
|
OrderBookDB mOrderBookDB;
|
||||||
|
|
||||||
DatabaseCon *mRpcDB, *mTxnDB, *mLedgerDB, *mWalletDB, *mHashNodeDB, *mNetNodeDB;
|
DatabaseCon *mRpcDB, *mTxnDB, *mLedgerDB, *mWalletDB, *mHashNodeDB, *mNetNodeDB;
|
||||||
|
|
||||||
@@ -115,6 +117,7 @@ public:
|
|||||||
LoadFeeTrack& getFeeTrack() { return mFeeTrack; }
|
LoadFeeTrack& getFeeTrack() { return mFeeTrack; }
|
||||||
TXQueue& getTxnQueue() { return mTxnQueue; }
|
TXQueue& getTxnQueue() { return mTxnQueue; }
|
||||||
PeerDoor& getPeerDoor() { return *mPeerDoor; }
|
PeerDoor& getPeerDoor() { return *mPeerDoor; }
|
||||||
|
OrderBookDB& getOrderBookDB() { return mOrderBookDB; }
|
||||||
|
|
||||||
|
|
||||||
bool isNew(const uint256& s) { return mSuppressions.addSuppression(s); }
|
bool isNew(const uint256& s) { return mSuppressions.addSuppression(s); }
|
||||||
|
|||||||
@@ -1316,6 +1316,7 @@ void NetworkOPs::pubAcceptedTransaction(Ledger::ref lpCurrent, const SerializedT
|
|||||||
ispListener->send(jvObj);
|
ispListener->send(jvObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
theApp->getOrderBookDB().processTxn(stTxn, terResult, meta, jvObj);
|
||||||
|
|
||||||
pubAccountTransaction(lpCurrent, stTxn, terResult, true, meta);
|
pubAccountTransaction(lpCurrent, stTxn, terResult, true, meta);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ protected:
|
|||||||
typedef boost::unordered_map<uint160,boost::unordered_set<InfoSub*> >::iterator subInfoMapIterator;
|
typedef boost::unordered_map<uint160,boost::unordered_set<InfoSub*> >::iterator subInfoMapIterator;
|
||||||
|
|
||||||
typedef boost::unordered_map<uint160,std::pair<InfoSub*,uint32> > subSubmitMapType;
|
typedef boost::unordered_map<uint160,std::pair<InfoSub*,uint32> > subSubmitMapType;
|
||||||
|
//typedef boost::unordered_map<OrderBook::pointer,boost::unordered_set<InfoSub*> > subOrderMap;
|
||||||
|
|
||||||
typedef boost::unordered_map<std::string, RPCSub* > subRpcMapType;
|
typedef boost::unordered_map<std::string, RPCSub* > subRpcMapType;
|
||||||
|
|
||||||
@@ -104,6 +105,7 @@ protected:
|
|||||||
subInfoMapType mSubRTAccount;
|
subInfoMapType mSubRTAccount;
|
||||||
subSubmitMapType mSubmitMap; // TODO: probably dump this
|
subSubmitMapType mSubmitMap; // TODO: probably dump this
|
||||||
|
|
||||||
|
|
||||||
subRpcMapType mRpcSubMap;
|
subRpcMapType mRpcSubMap;
|
||||||
|
|
||||||
boost::unordered_set<InfoSub*> mSubLedger; // accepted ledgers
|
boost::unordered_set<InfoSub*> mSubLedger; // accepted ledgers
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
#include "SerializedLedger.h"
|
#include "SerializedLedger.h"
|
||||||
|
#include "NetworkOPs.h"
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Encapsulates the SLE for an orderbook
|
Encapsulates the SLE for an orderbook
|
||||||
*/
|
*/
|
||||||
@@ -12,6 +14,8 @@ class OrderBook
|
|||||||
uint160 mIssuerIn;
|
uint160 mIssuerIn;
|
||||||
uint160 mIssuerOut;
|
uint160 mIssuerOut;
|
||||||
|
|
||||||
|
boost::unordered_set<InfoSub*> mListeners;
|
||||||
|
|
||||||
//SerializedLedgerEntry::pointer mLedgerEntry;
|
//SerializedLedgerEntry::pointer mLedgerEntry;
|
||||||
OrderBook(SerializedLedgerEntry::pointer ledgerEntry); // For accounts in a ledger
|
OrderBook(SerializedLedgerEntry::pointer ledgerEntry); // For accounts in a ledger
|
||||||
public:
|
public:
|
||||||
@@ -30,6 +34,9 @@ public:
|
|||||||
|
|
||||||
// looks through the best offers to see how much it would cost to take the given amount
|
// looks through the best offers to see how much it would cost to take the given amount
|
||||||
STAmount& getTakePrice(STAmount& takeAmount);
|
STAmount& getTakePrice(STAmount& takeAmount);
|
||||||
|
|
||||||
|
void addSubscriber(InfoSub* sub);
|
||||||
|
void removeSubscriber(InfoSub* sub);
|
||||||
};
|
};
|
||||||
|
|
||||||
// vim:ts=4
|
// vim:ts=4
|
||||||
|
|||||||
@@ -3,8 +3,13 @@
|
|||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
|
||||||
|
|
||||||
|
OrderBookDB::OrderBookDB()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: this would be way faster if we could just look under the order dirs
|
// TODO: this would be way faster if we could just look under the order dirs
|
||||||
OrderBookDB::OrderBookDB(Ledger::pointer ledger)
|
void OrderBookDB::setup(Ledger::pointer ledger)
|
||||||
{
|
{
|
||||||
// walk through the entire ledger looking for orderbook entries
|
// walk through the entire ledger looking for orderbook entries
|
||||||
uint256 currentIndex=ledger->getFirstLedgerIndex();
|
uint256 currentIndex=ledger->getFirstLedgerIndex();
|
||||||
@@ -54,3 +59,40 @@ void OrderBookDB::getBooks(const uint160& issuerID, const uint160& currencyID, s
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
OrderBook::pointer OrderBookDB::getBook(uint160 mCurrencyIn, uint160 mCurrencyOut, uint160 mIssuerIn, uint160 mIssuerOut)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
"CreatedNode" : {
|
||||||
|
"LedgerEntryType" : "Offer",
|
||||||
|
"LedgerIndex" : "F353BF8A7DCE35EA2985596F4C8421E30EF3B9A21618566BFE0ED00B62A8A5AB",
|
||||||
|
"NewFields" : {
|
||||||
|
"Account" : "rB5TihdPbKgMrkFqrqUC3yLdE8hhv4BdeY",
|
||||||
|
"BookDirectory" : "FF26BE244767D0EA9EFD523941439009E4185E4CBB918F714C08E1BC9BF04000",
|
||||||
|
"Sequence" : 112,
|
||||||
|
"TakerGets" : "400000000",
|
||||||
|
"TakerPays" : {
|
||||||
|
"currency" : "BTC",
|
||||||
|
"issuer" : "r3kmLJN5D28dHuH8vZNUZpMC43pEHpaocV",
|
||||||
|
"value" : "1"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
|
void OrderBookDB::processTxn(const SerializedTransaction& stTxn, TER terResult,TransactionMetaSet::pointer& meta,Json::Value& jvObj)
|
||||||
|
{
|
||||||
|
// check if this is an offer or an offer cancel or a payment that consumes an offer
|
||||||
|
//check to see what the meta looks like
|
||||||
|
BOOST_FOREACH(STObject& node,meta->getNodes())
|
||||||
|
{
|
||||||
|
if(node.getFieldU16(sfLedgerEntryType)==ltOFFER)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -11,11 +11,13 @@ class OrderBookDB
|
|||||||
std::vector<OrderBook::pointer> mEmptyVector;
|
std::vector<OrderBook::pointer> mEmptyVector;
|
||||||
std::vector<OrderBook::pointer> mXRPOrders;
|
std::vector<OrderBook::pointer> mXRPOrders;
|
||||||
std::map<uint160, std::vector<OrderBook::pointer> > mIssuerMap;
|
std::map<uint160, std::vector<OrderBook::pointer> > mIssuerMap;
|
||||||
|
//std::vector<OrderBook::pointer> mAllOrderBooks;
|
||||||
|
|
||||||
std::map<uint256, bool > mKnownMap;
|
std::map<uint256, bool > mKnownMap;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OrderBookDB(Ledger::pointer ledger);
|
OrderBookDB();
|
||||||
|
void setup(Ledger::pointer ledger);
|
||||||
|
|
||||||
// return list of all orderbooks that want XRP
|
// return list of all orderbooks that want XRP
|
||||||
std::vector<OrderBook::pointer>& getXRPInBooks(){ return mXRPOrders; }
|
std::vector<OrderBook::pointer>& getXRPInBooks(){ return mXRPOrders; }
|
||||||
@@ -27,6 +29,11 @@ public:
|
|||||||
// returns the best rate we can find
|
// returns the best rate we can find
|
||||||
float getPrice(uint160& currencyIn,uint160& currencyOut);
|
float getPrice(uint160& currencyIn,uint160& currencyOut);
|
||||||
|
|
||||||
|
|
||||||
|
OrderBook::pointer getBook(uint160 mCurrencyIn, uint160 mCurrencyOut, uint160 mIssuerIn, uint160 mIssuerOut);
|
||||||
|
// see if this txn effects any orderbook
|
||||||
|
void processTxn(const SerializedTransaction& stTxn, TER terResult,TransactionMetaSet::pointer& meta,Json::Value& jvObj);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// vim:ts=4
|
// vim:ts=4
|
||||||
|
|||||||
@@ -269,7 +269,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
|||||||
else if (!speEnd.mCurrencyID)
|
else if (!speEnd.mCurrencyID)
|
||||||
{
|
{
|
||||||
// Last element is for XRP, continue with qualifying books.
|
// Last element is for XRP, continue with qualifying books.
|
||||||
BOOST_FOREACH(OrderBook::ref book, mOrderBook.getXRPInBooks())
|
BOOST_FOREACH(OrderBook::ref book, theApp->getOrderBookDB().getXRPInBooks())
|
||||||
{
|
{
|
||||||
// XXX Don't allow looping through same order books.
|
// XXX Don't allow looping through same order books.
|
||||||
|
|
||||||
@@ -357,7 +357,7 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
|||||||
// Every book that wants the source currency.
|
// Every book that wants the source currency.
|
||||||
std::vector<OrderBook::pointer> books;
|
std::vector<OrderBook::pointer> books;
|
||||||
|
|
||||||
mOrderBook.getBooks(spPath.mCurrentAccount, spPath.mCurrencyID, books);
|
theApp->getOrderBookDB().getBooks(spPath.mCurrentAccount, spPath.mCurrencyID, books);
|
||||||
|
|
||||||
BOOST_FOREACH(OrderBook::ref book,books)
|
BOOST_FOREACH(OrderBook::ref book,books)
|
||||||
{
|
{
|
||||||
@@ -499,7 +499,7 @@ void Pathfinder::addOptions(PathOption::pointer tail)
|
|||||||
{
|
{
|
||||||
if (!tail->mCurrencyID)
|
if (!tail->mCurrencyID)
|
||||||
{ // source XRP
|
{ // source XRP
|
||||||
BOOST_FOREACH(OrderBook::ref book, mOrderBook.getXRPInBooks())
|
BOOST_FOREACH(OrderBook::ref book, theApp->getOrderBookDB().getXRPInBooks())
|
||||||
{
|
{
|
||||||
PathOption::pointer pathOption(new PathOption(tail));
|
PathOption::pointer pathOption(new PathOption(tail));
|
||||||
|
|
||||||
@@ -533,7 +533,7 @@ void Pathfinder::addOptions(PathOption::pointer tail)
|
|||||||
|
|
||||||
// every offer that wants the source currency
|
// every offer that wants the source currency
|
||||||
std::vector<OrderBook::pointer> books;
|
std::vector<OrderBook::pointer> books;
|
||||||
mOrderBook.getBooks(tail->mCurrentAccount, tail->mCurrencyID, books);
|
theApp->getOrderBookDB().getBooks(tail->mCurrentAccount, tail->mCurrencyID, books);
|
||||||
|
|
||||||
BOOST_FOREACH(OrderBook::ref book,books)
|
BOOST_FOREACH(OrderBook::ref book,books)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,6 @@
|
|||||||
|
|
||||||
#include "SerializedTypes.h"
|
#include "SerializedTypes.h"
|
||||||
#include "RippleAddress.h"
|
#include "RippleAddress.h"
|
||||||
#include "OrderBookDB.h"
|
|
||||||
#include "RippleCalc.h"
|
#include "RippleCalc.h"
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
|
|
||||||
@@ -42,7 +41,7 @@ class Pathfinder
|
|||||||
uint160 mSrcIssuerID;
|
uint160 mSrcIssuerID;
|
||||||
STAmount mSrcAmount;
|
STAmount mSrcAmount;
|
||||||
|
|
||||||
OrderBookDB mOrderBook;
|
//OrderBookDB mOrderBook;
|
||||||
Ledger::pointer mLedger;
|
Ledger::pointer mLedger;
|
||||||
PathState::pointer mPsDefault;
|
PathState::pointer mPsDefault;
|
||||||
|
|
||||||
|
|||||||
@@ -56,6 +56,7 @@ public:
|
|||||||
void addRaw(Serializer&, TER, uint32 index);
|
void addRaw(Serializer&, TER, uint32 index);
|
||||||
|
|
||||||
STObject getAsObject() const;
|
STObject getAsObject() const;
|
||||||
|
STArray& getNodes(){ return(mNodes); }
|
||||||
|
|
||||||
static bool thread(STObject& node, const uint256& prevTxID, uint32 prevLgrID);
|
static bool thread(STObject& node, const uint256& prevTxID, uint32 prevLgrID);
|
||||||
};
|
};
|
||||||
|
|||||||
Submodule src/js/sjcl updated: dbdef434e7...d04d0bdccd
Reference in New Issue
Block a user