Add some monitoring support to NetworkOPs.

This commit is contained in:
Arthur Britto
2012-06-24 20:02:55 -07:00
parent 2fc6bbb6fc
commit 1cf9156fc3
2 changed files with 127 additions and 7 deletions

View File

@@ -1,13 +1,16 @@
#ifndef __NETWORK_OPS__
#define __NETWORK_OPS__
#include "LedgerMaster.h"
#include "AccountState.h"
#include "RippleState.h"
#include "LedgerMaster.h"
#include "NicknameState.h"
#include "RippleState.h"
#include "SerializedValidation.h"
// #include <boost/asio.hpp>
#include <boost/interprocess/sync/interprocess_upgradable_mutex.hpp>
#include <boost/interprocess/sync/sharable_lock.hpp>
#include <boost/unordered_map.hpp>
#include <boost/unordered_set.hpp>
// Operations that clients may wish to perform against the network
// Master operational handler, server sequencer, network tracker
@@ -15,6 +18,12 @@
class Peer;
class LedgerConsensus;
class InfoSub
{
public:
virtual void send(const Json::Value& jvObj) = 0;
};
class NetworkOPs
{
public:
@@ -41,6 +50,12 @@ protected:
void setMode(OperatingMode);
typedef boost::unordered_map<NewcoinAddress,boost::unordered_set<InfoSub*> > subInfoMapType;
typedef boost::unordered_map<NewcoinAddress,boost::unordered_set<InfoSub*> >::iterator subInfoMapIterator;
boost::interprocess::interprocess_upgradable_mutex mMonitorLock;
subInfoMapType mSubAccountInfo;
public:
NetworkOPs(boost::asio::io_service& io_service, LedgerMaster* pLedgerMaster);
@@ -133,6 +148,23 @@ public:
// client information retrieval functions
std::vector< std::pair<uint32, uint256> >
getAffectedAccounts(const NewcoinAddress& account, uint32 minLedger, uint32 maxLedger);
//
// Monitoring: publisher side
//
void pubAccountInfo(const NewcoinAddress& naAccountID, const Json::Value& jvObj);
//
// Monitoring: subscriber side
//
// --> vnaAddress: empty = all
void subAccountInfo(InfoSub* ispListener, const std::vector<NewcoinAddress>& vnaAccountIDs);
void unsubAccountInfo(InfoSub* ispListener, const std::vector<NewcoinAddress>& vnaAccountIDs);
void subAccountChanges(InfoSub* ispListener, const uint256 uLedgerHash);
void unsubAccountChanges(InfoSub* ispListener);
};
#endif