mirror of
https://github.com/RetroShare/RetroShare.git
synced 2024-12-15 10:54:22 -05:00
documentation of p3GroupDistrib, p3Channels, and CacheStrapper
give a hand at http://retroshare.sourceforge.net/wiki/index.php/API_Documentation git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@3279 b45a01b8-16f6-495d-af2f-9b41ad6348cc
This commit is contained in:
parent
1787e50b94
commit
a25dbf7358
@ -65,31 +65,39 @@ typedef uint32_t RsPeerId;
|
||||
typedef std::string RsPeerId;
|
||||
|
||||
/******************************** CacheId ********************************/
|
||||
|
||||
/*!
|
||||
* Use this to identify the type of cache source, strapper,
|
||||
*/
|
||||
class CacheId
|
||||
{
|
||||
public:
|
||||
CacheId() :type(0), subid(0) { return; }
|
||||
CacheId(uint16_t a, uint16_t b) :type(a), subid(b) { return; }
|
||||
uint16_t type;
|
||||
uint16_t subid;
|
||||
uint16_t type; /// cache types, this should be set to services type
|
||||
uint16_t subid; /// should be initialised when using multicache feature of cachestrapper
|
||||
};
|
||||
|
||||
|
||||
bool operator<(const CacheId &a, const CacheId &b);
|
||||
|
||||
|
||||
/*!
|
||||
* Use for identifying physical files that have been chosen as cache data
|
||||
* note: this does not actual store the data but serves to locate on network (via hash attribute,
|
||||
* and on file via path)
|
||||
*/
|
||||
class CacheData
|
||||
{
|
||||
public:
|
||||
|
||||
RsPeerId pid;
|
||||
std::string pname; /* peer name (can be used by cachestore) */
|
||||
CacheId cid;
|
||||
std::string path;
|
||||
RsPeerId pid; /// peer id
|
||||
std::string pname; /// peer name (can be used by cachestore)
|
||||
CacheId cid; /// cache id
|
||||
std::string path; /// file system path where physical cache data is located
|
||||
std::string name;
|
||||
std::string hash;
|
||||
uint64_t size;
|
||||
time_t recvd;
|
||||
time_t recvd; /// received timestamp
|
||||
};
|
||||
|
||||
|
||||
@ -97,29 +105,37 @@ std::ostream &operator<<(std::ostream &out, const CacheData &d);
|
||||
|
||||
/***************************** CacheTransfer *****************************/
|
||||
|
||||
/**
|
||||
* Interface for FileTransfer Class to support cache
|
||||
*/
|
||||
class CacheTransfer
|
||||
{
|
||||
public:
|
||||
CacheTransfer(CacheStrapper *cs) :strapper(cs) { return; }
|
||||
virtual ~CacheTransfer() {}
|
||||
|
||||
/* upload side of things .... searches through CacheStrapper. */
|
||||
bool FindCacheFile(std::string hash, std::string &path, uint64_t &size);
|
||||
CacheTransfer(CacheStrapper *cs) :strapper(cs) { return; }
|
||||
virtual ~CacheTransfer() {}
|
||||
|
||||
/*!
|
||||
* upload side of things .... searches through CacheStrapper.
|
||||
*/
|
||||
bool FindCacheFile(std::string hash, std::string &path, uint64_t &size);
|
||||
|
||||
/* At the download side RequestCache() => overloaded RequestCacheFile()
|
||||
* the class should then call CompletedCache() or FailedCache()
|
||||
*/
|
||||
|
||||
bool RequestCache(CacheData &data, CacheStore *cbStore); /* request from CacheStore */
|
||||
/*!
|
||||
* At the download side RequestCache() => overloaded RequestCacheFile()
|
||||
* the class should then call CompletedCache() or FailedCache()
|
||||
*/
|
||||
bool RequestCache(CacheData &data, CacheStore *cbStore); /* request from CacheStore */
|
||||
|
||||
protected:
|
||||
/* to be overloaded */
|
||||
virtual bool RequestCacheFile(RsPeerId id, std::string path, std::string hash, uint64_t size);
|
||||
virtual bool CancelCacheFile(RsPeerId id, std::string path, std::string hash, uint64_t size);
|
||||
|
||||
bool CompletedCache(std::string hash); /* internal completion -> does cb */
|
||||
bool FailedCache(std::string hash); /* internal completion -> does cb */
|
||||
/*!
|
||||
* to be overloaded
|
||||
*/
|
||||
virtual bool RequestCacheFile(RsPeerId id, std::string path, std::string hash, uint64_t size);
|
||||
virtual bool CancelCacheFile(RsPeerId id, std::string path, std::string hash, uint64_t size);
|
||||
|
||||
bool CompletedCache(std::string hash); /* internal completion -> does cb */
|
||||
bool FailedCache(std::string hash); /* internal completion -> does cb */
|
||||
|
||||
private:
|
||||
|
||||
@ -135,117 +151,181 @@ bool FailedCache(std::string hash); /* internal completion
|
||||
|
||||
typedef std::map<uint16_t, CacheData> CacheSet;
|
||||
|
||||
/*!
|
||||
* Implements features needed for a service to act as a cachesource and allow pushing a of cache data from service to strapper
|
||||
* Service is able to use this class for refresh its cache (push cache data)
|
||||
* and interface to load and check cache availablility among peers (source of cache data)
|
||||
* Architecturally Cachestrapper maintains the cachesource (which is passed as a pointer handle) while the cachesource-inheriting
|
||||
* service can update cachesource as to new cache sources (cache data) created. Equivalently it enquiries through cache source for
|
||||
* new cache data from peers
|
||||
* @see p3Distrib
|
||||
*/
|
||||
class CacheSource
|
||||
{
|
||||
public:
|
||||
CacheSource(uint16_t t, bool m, CacheStrapper *cs, std::string cachedir);
|
||||
virtual ~CacheSource() {}
|
||||
|
||||
/* called to determine available cache for peer -
|
||||
* default acceptable (returns all)
|
||||
*/
|
||||
virtual bool cachesAvailable(RsPeerId pid, std::map<CacheId, CacheData> &ids);
|
||||
CacheSource(uint16_t t, bool m, CacheStrapper *cs, std::string cachedir);
|
||||
virtual ~CacheSource() {}
|
||||
|
||||
/*!
|
||||
* function called at startup to load from
|
||||
* configuration file....
|
||||
* to be overloaded by inherited class
|
||||
*/
|
||||
virtual bool loadLocalCache(const CacheData &data);
|
||||
/*!
|
||||
* called to determine available cache for peer -
|
||||
* default acceptable (returns all)
|
||||
*/
|
||||
virtual bool cachesAvailable(RsPeerId pid, std::map<CacheId, CacheData> &ids);
|
||||
|
||||
/* control Caches available */
|
||||
bool refreshCache(const CacheData &data);
|
||||
bool clearCache(CacheId id);
|
||||
/*!
|
||||
* function called at startup to load from
|
||||
* configuration file....
|
||||
* to be overloaded by inherited class
|
||||
*/
|
||||
virtual bool loadLocalCache(const CacheData &data);
|
||||
|
||||
/* get private data */
|
||||
std::string getCacheDir() { return cacheDir; }
|
||||
bool isMultiCache() { return multiCache; }
|
||||
uint16_t getCacheType() { return cacheType; }
|
||||
/* control Caches available */
|
||||
bool refreshCache(const CacheData &data);
|
||||
bool clearCache(CacheId id);
|
||||
|
||||
/* display */
|
||||
void listCaches(std::ostream &out);
|
||||
/* get private data */
|
||||
std::string getCacheDir() { return cacheDir; }
|
||||
bool isMultiCache() { return multiCache; }
|
||||
uint16_t getCacheType() { return cacheType; }
|
||||
|
||||
/* search */
|
||||
bool findCache(std::string hash, CacheData &data) const;
|
||||
/* display */
|
||||
void listCaches(std::ostream &out);
|
||||
|
||||
/* search */
|
||||
bool findCache(std::string hash, CacheData &data) const;
|
||||
|
||||
protected:
|
||||
|
||||
uint16_t cacheType; /* for checking */
|
||||
bool multiCache; /* do we care about subid's */
|
||||
CacheStrapper *mStrapper;
|
||||
uint16_t cacheType; /// for checking of cache type (usually of child class of source)
|
||||
bool multiCache; /// whether multisource is in use or not.
|
||||
CacheStrapper *mStrapper;
|
||||
|
||||
/*** MUTEX LOCKING */
|
||||
void lockData() const;
|
||||
void unlockData() const;
|
||||
/*** MUTEX LOCKING */
|
||||
void lockData() const;
|
||||
void unlockData() const;
|
||||
|
||||
CacheSet caches;
|
||||
CacheSet caches; /// all cache data local and remote stored here
|
||||
|
||||
private:
|
||||
private:
|
||||
|
||||
std::string cacheDir;
|
||||
mutable RsMutex cMutex;
|
||||
|
||||
std::string cacheDir;
|
||||
mutable RsMutex cMutex;
|
||||
};
|
||||
|
||||
|
||||
/*!
|
||||
* Base Class for data cache. eg. FileCache/Store.
|
||||
* @see p3Distrib. pqiMonitor
|
||||
*/
|
||||
class CacheStore
|
||||
{
|
||||
public:
|
||||
|
||||
CacheStore(uint16_t t, bool m, CacheStrapper *cs, CacheTransfer *cft, std::string cachedir);
|
||||
virtual ~CacheStore() {}
|
||||
/*!
|
||||
*
|
||||
* @param t set to particular rs_service id. see rsserviceids.h
|
||||
* @param m whether this is multicache service (true) or not(false)
|
||||
* @param cs cache strapper instance responsible for maintaining the cache service
|
||||
* @param cft cache transfer instance responsible for rquestiing and tranfering caches
|
||||
* @param cachedir directory used to store cache related info for cachestore client
|
||||
* @return
|
||||
*/
|
||||
CacheStore(uint16_t t, bool m, CacheStrapper *cs, CacheTransfer *cft, std::string cachedir);
|
||||
virtual ~CacheStore() {}
|
||||
|
||||
/* current stored data */
|
||||
bool getStoredCache(CacheData &data); /* use pid/cid in data */
|
||||
bool getAllStoredCaches(std::list<CacheData> &data); /* use pid/cid in data */
|
||||
/* current stored data */
|
||||
|
||||
/* input from CacheStrapper -> store can then download new data */
|
||||
void availableCache(const CacheData &data);
|
||||
/*!
|
||||
*
|
||||
* @param data returns cache data for pid/cid set in data itself
|
||||
* @return false is unsuccessful and vice versa
|
||||
*/
|
||||
bool getStoredCache(CacheData &data); /* use pid/cid in data */
|
||||
|
||||
/* called when the download is completed ... updates internal data */
|
||||
void downloadedCache(const CacheData &data);
|
||||
/*!
|
||||
*
|
||||
* @param data all cache store by cachestore is store here
|
||||
* @return false not returned, only true at the moment
|
||||
*/
|
||||
bool getAllStoredCaches(std::list<CacheData> &data); /* use pid/cid in data */
|
||||
|
||||
/* called if the download fails */
|
||||
void failedCache(const CacheData &data);
|
||||
/*!
|
||||
* input from CacheStrapper -> store can then download new data
|
||||
*/
|
||||
void availableCache(const CacheData &data);
|
||||
|
||||
/* virtual functions overloaded by cache implementor */
|
||||
virtual bool fetchCache(const CacheData &data); /* a question? */
|
||||
virtual int nameCache(CacheData &data); /* fill in the name/path */
|
||||
virtual int loadCache(const CacheData &data); /* actual load, once data available */
|
||||
/*!
|
||||
* should be called when the download is completed ... cache data is loaded
|
||||
*/
|
||||
void downloadedCache(const CacheData &data);
|
||||
|
||||
/* get private data */
|
||||
std::string getCacheDir() { return cacheDir; }
|
||||
bool isMultiCache() { return multiCache; }
|
||||
uint16_t getCacheType() { return cacheType; }
|
||||
/*!
|
||||
* called if the download fails, TODO: nothing done yet
|
||||
*/
|
||||
void failedCache(const CacheData &data);
|
||||
|
||||
/* display */
|
||||
void listCaches(std::ostream &out);
|
||||
/* virtual functions overloaded by cache implementor */
|
||||
|
||||
/*!
|
||||
* @param data cache data is stored here
|
||||
* @return false is failed (cache does not exist), otherwise true
|
||||
*/
|
||||
virtual bool fetchCache(const CacheData &data); /* a question? */
|
||||
virtual int nameCache(CacheData &data); /* fill in the name/path */
|
||||
virtual int loadCache(const CacheData &data); /* actual load, once data available */
|
||||
|
||||
/* get private data */
|
||||
|
||||
std::string getCacheDir() { return cacheDir; }
|
||||
bool isMultiCache() { return multiCache; }
|
||||
uint16_t getCacheType() { return cacheType; }
|
||||
|
||||
/*!
|
||||
* display, e.g. can pass std::out, cerr, ofstream, etc
|
||||
*/
|
||||
void listCaches(std::ostream &out);
|
||||
|
||||
protected:
|
||||
/*** MUTEX LOCKING */
|
||||
void lockData() const;
|
||||
void unlockData() const;
|
||||
|
||||
/* This function is called to store Cache Entry in the CacheStore Table.
|
||||
* it must be called from within a Mutex Lock....
|
||||
*
|
||||
* It doesn't lock itself -> to avoid race conditions
|
||||
*/
|
||||
void locked_storeCacheEntry(const CacheData &data);
|
||||
bool locked_getStoredCache(CacheData &data);
|
||||
/*!
|
||||
* ** MUTEX LOCKING
|
||||
*/
|
||||
void lockData() const;
|
||||
|
||||
private:
|
||||
/*!
|
||||
* ** MUTEX LOCKING
|
||||
*/
|
||||
void unlockData() const;
|
||||
|
||||
uint16_t cacheType; /* for checking */
|
||||
bool multiCache; /* do we care about subid's */
|
||||
/*! This function is called to store Cache Entry in the CacheStore Table.
|
||||
* it must be called from within a Mutex Lock....
|
||||
*
|
||||
* It doesn't lock itself -> to avoid race conditions
|
||||
*/
|
||||
void locked_storeCacheEntry(const CacheData &data);
|
||||
|
||||
CacheStrapper *mStrapper;
|
||||
CacheTransfer *cacheTransfer;
|
||||
/*! This function is called to store Cache Entry in the CacheStore Table.
|
||||
* it must be called from within a Mutex Lock....
|
||||
*
|
||||
* It doesn't lock itself -> to avoid race conditions
|
||||
*/
|
||||
bool locked_getStoredCache(CacheData &data);
|
||||
|
||||
std::string cacheDir;
|
||||
private:
|
||||
|
||||
mutable RsMutex cMutex;
|
||||
uint16_t cacheType; /* for checking */
|
||||
bool multiCache; /* do we care about subid's */
|
||||
|
||||
std::map<RsPeerId, CacheSet> caches;
|
||||
CacheStrapper *mStrapper;
|
||||
CacheTransfer *cacheTransfer;
|
||||
|
||||
std::string cacheDir;
|
||||
|
||||
mutable RsMutex cMutex;
|
||||
|
||||
std::map<RsPeerId, CacheSet> caches;
|
||||
|
||||
};
|
||||
|
||||
@ -254,28 +334,52 @@ bool locked_getStoredCache(CacheData &data);
|
||||
/***************************** CacheStrapper *****************************/
|
||||
|
||||
|
||||
/* Make Sure you get the Ids right! */
|
||||
/*!
|
||||
* a convenient to pass cache handles to cachestrapper to maintain the cache service
|
||||
* Make Sure you get the Ids right! see rsservicesids.h.
|
||||
* When creating a cache service this data structure is
|
||||
* source, usually the child class of store and source also serves as both handles
|
||||
* @see CacheStrapper
|
||||
*/
|
||||
class CachePair
|
||||
{
|
||||
public:
|
||||
CachePair()
|
||||
:source(NULL), store(NULL), id(0, 0) { return; }
|
||||
|
||||
CachePair(CacheSource *a, CacheStore *b, CacheId c)
|
||||
:source(a), store(b), id(c) { return; }
|
||||
/*!
|
||||
* Default constructor, all variables set to NULL
|
||||
*/
|
||||
CachePair()
|
||||
:source(NULL), store(NULL), id(0, 0) { return; }
|
||||
|
||||
CacheSource *source;
|
||||
CacheStore *store;
|
||||
CacheId id;
|
||||
/*!
|
||||
*
|
||||
* @param a cache source for service
|
||||
* @param b cache store for service
|
||||
* @param c the cache service id, c.type should be set to service id service-child class of store and source
|
||||
*/
|
||||
CachePair(CacheSource *a, CacheStore *b, CacheId c)
|
||||
:source(a), store(b), id(c) { return; }
|
||||
|
||||
CacheSource *source;
|
||||
CacheStore *store;
|
||||
CacheId id; /// should be set id type to service types of store and source service-child class, and subid for multicache use
|
||||
};
|
||||
|
||||
|
||||
bool operator<(const CachePair &a, const CachePair &b);
|
||||
|
||||
|
||||
/*!
|
||||
* CacheStrapper: maintains a set of CacheSources, and CacheStores,
|
||||
* queries and updates as new information arrives.
|
||||
*/
|
||||
class CacheStrapper: public pqiMonitor, public p3Config
|
||||
{
|
||||
public:
|
||||
|
||||
/*!
|
||||
* @param cm handle used by strapper for getting peer connection information (online peers, sslids...)
|
||||
* @return
|
||||
*/
|
||||
CacheStrapper(p3ConnectMgr *cm);
|
||||
virtual ~CacheStrapper() { return; }
|
||||
|
||||
@ -284,12 +388,30 @@ virtual void statusChange(const std::list<pqipeer> &plist);
|
||||
/************* from pqiMonitor *******************/
|
||||
|
||||
/* Feedback from CacheSources */
|
||||
|
||||
/*!
|
||||
* send data to peers online and selfe
|
||||
* @param data
|
||||
*
|
||||
*/
|
||||
void refreshCache(const CacheData &data);
|
||||
|
||||
/*!
|
||||
* forces config savelist
|
||||
* @param data
|
||||
* @see saveList()
|
||||
*/
|
||||
void refreshCacheStore(const CacheData &data);
|
||||
|
||||
/* list of Caches to send out */
|
||||
/*!
|
||||
* list of Caches to send out
|
||||
*/
|
||||
bool getCacheUpdates(std::list<std::pair<RsPeerId, CacheData> > &updates);
|
||||
|
||||
/*!
|
||||
* add to strapper's cachepair set so a related service's store and source can be maintained
|
||||
* @param pair the source and store handle for a service
|
||||
*/
|
||||
void addCachePair(CachePair pair);
|
||||
|
||||
/*** I/O (2) ***/
|
||||
@ -297,11 +419,20 @@ void recvCacheResponse(CacheData &data, time_t ts);
|
||||
void handleCacheQuery(RsPeerId id, std::map<CacheId, CacheData> &data);
|
||||
|
||||
|
||||
/* search through CacheSources. */
|
||||
/*!
|
||||
* search through CacheSources.
|
||||
* @return false if cachedate mapping to hash not found
|
||||
*/
|
||||
bool findCache(std::string hash, CacheData &data) const;
|
||||
|
||||
/* display */
|
||||
void listCaches(std::ostream &out);
|
||||
|
||||
/*!
|
||||
* does not do anything
|
||||
* @param out
|
||||
* @deprecated
|
||||
*/
|
||||
void listPeerStatus(std::ostream &out);
|
||||
|
||||
/**
|
||||
|
@ -37,7 +37,7 @@
|
||||
//! Channels is a distributed 'feed' service
|
||||
/*!
|
||||
* Implementations of rschannels interface
|
||||
* @see rsChannels for definition of implemented interface
|
||||
* @see RsChannels for definition of implemented interface
|
||||
*/
|
||||
class p3Channels: public p3GroupDistrib, public RsChannels
|
||||
{
|
||||
|
@ -1097,7 +1097,7 @@ bool p3GroupDistrib::getPublishGroupList(std::list<std::string> &grpids)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool p3GroupDistrib::getPopularGroupList(uint32_t popMin, uint32_t popMax, std::list<std::string> &grpids)
|
||||
void p3GroupDistrib::getPopularGroupList(uint32_t popMin, uint32_t popMax, std::list<std::string> &grpids)
|
||||
{
|
||||
RsStackMutex stack(distribMtx); /************* STACK MUTEX ************/
|
||||
std::map<std::string, GroupInfo>::iterator git;
|
||||
@ -1109,7 +1109,7 @@ bool p3GroupDistrib::getPopularGroupList(uint32_t popMin, uint32_t popMax, std::
|
||||
grpids.push_back(git->first);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,7 +31,7 @@
|
||||
#include "pqi/p3cfgmgr.h"
|
||||
#include "services/p3service.h"
|
||||
#include "dbase/cachestrapper.h"
|
||||
#include "serialiser/rsforumitems.h"
|
||||
#include "serialiser/rsdistribitems.h"
|
||||
|
||||
#include <openssl/ssl.h>
|
||||
#include <openssl/evp.h>
|
||||
@ -90,23 +90,29 @@ const uint32_t GROUP_KEY_DISTRIB_ADMIN = 0x0040;
|
||||
#endif
|
||||
|
||||
|
||||
//! key to be sent member or members of a groups
|
||||
//! for storing group keys to members of a group
|
||||
/*!
|
||||
* This key but be of many types, including private/public publish key, or admin prite key for group
|
||||
* @see p3GroupDistrib
|
||||
*/
|
||||
class GroupKey
|
||||
{
|
||||
public:
|
||||
|
||||
GroupKey()
|
||||
:type(0), startTS(0), endTS(0), key(NULL) { return; }
|
||||
GroupKey()
|
||||
:type(0), startTS(0), endTS(0), key(NULL) { return; }
|
||||
|
||||
uint32_t type;
|
||||
std::string keyId;
|
||||
time_t startTS, endTS;
|
||||
EVP_PKEY *key; /// public key
|
||||
uint32_t type; /// whether key is full or public
|
||||
std::string keyId;
|
||||
time_t startTS, endTS;
|
||||
EVP_PKEY *key; /// actual group key in evp format
|
||||
};
|
||||
|
||||
//! used to store group picture
|
||||
/*!
|
||||
* ensures use of png image format
|
||||
* @see p3GroupDistrib
|
||||
*/
|
||||
class GroupIcon{
|
||||
public:
|
||||
GroupIcon(): pngImageData(NULL), imageSize(0) {
|
||||
@ -121,64 +127,67 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned char* pngImageData;
|
||||
unsigned char* pngImageData; /// pointer to image data in png format
|
||||
int imageSize;
|
||||
};
|
||||
|
||||
//! aggregates various information on group activities (i.e. messages, posts, etc)
|
||||
//! used by p3groupDistrib to store mirror info found in rsDistribGroup (i.e. messages, posts, etc)
|
||||
/*!
|
||||
* The aim is to use this to keep track of group changes, so client can respond (get messages, post etc)
|
||||
* used by p3Groudistrib to store group info, also used to communicate group information
|
||||
* to p3groupdistrib inherited classes. contain
|
||||
* @see rsDistribGroup
|
||||
*/
|
||||
class GroupInfo
|
||||
{
|
||||
public:
|
||||
GroupInfo()
|
||||
:distribGroup(NULL), grpFlags(0), pop(0), lastPost(0), flags(0), grpChanged(false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::string grpId; /// the group id
|
||||
RsDistribGrp *distribGroup; /// item which contains further information on group
|
||||
GroupInfo()
|
||||
:distribGroup(NULL), grpFlags(0), pop(0), lastPost(0), flags(0), grpChanged(false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::list<std::string> sources;
|
||||
std::map<std::string, RsDistribMsg *> msgs;
|
||||
std::string grpId; /// the group id
|
||||
RsDistribGrp *distribGroup; /// item which contains further information on group
|
||||
|
||||
/***********************************/
|
||||
std::list<std::string> sources;
|
||||
std::map<std::string, RsDistribMsg *> msgs;
|
||||
|
||||
/* Copied from DistribGrp */
|
||||
std::wstring grpName;
|
||||
std::wstring grpDesc;
|
||||
std::wstring grpCategory;
|
||||
uint32_t grpFlags; /* PRIVACY & AUTHEN */
|
||||
/***********************************/
|
||||
|
||||
/* Copied from DistribGrp */
|
||||
std::wstring grpName;
|
||||
std::wstring grpDesc; /// group description
|
||||
std::wstring grpCategory;
|
||||
uint32_t grpFlags; /// PRIVACY & AUTHENTICATION
|
||||
|
||||
|
||||
uint32_t pop; /// sources.size()
|
||||
time_t lastPost; /// modded as msgs added
|
||||
uint32_t pop; /// popularity sources.size()
|
||||
time_t lastPost; /// modded as msgs added
|
||||
|
||||
/***********************************/
|
||||
/***********************************/
|
||||
|
||||
uint32_t flags; /// PUBLISH, SUBSCRIBE, ADMIN
|
||||
uint32_t flags; /// PUBLISH, SUBSCRIBE, ADMIN
|
||||
|
||||
|
||||
std::string publishKeyId; /// current active Publish Key
|
||||
std::map<std::string, GroupKey> publishKeys;
|
||||
std::string publishKeyId; /// current active Publish Key
|
||||
std::map<std::string, GroupKey> publishKeys;
|
||||
|
||||
GroupKey adminKey;
|
||||
GroupKey adminKey;
|
||||
|
||||
|
||||
GroupIcon grpIcon;
|
||||
/* NOT USED YET */
|
||||
GroupIcon grpIcon;
|
||||
/* NOT USED YET */
|
||||
|
||||
std::map<std::string, RsDistribMsg* > decrypted_msg_cache; /// stores a cache of messages that have been decrypted
|
||||
std::map<std::string, RsDistribMsg* > decrypted_msg_cache; /// stores a cache of messages that have been decrypted
|
||||
|
||||
bool publisher, allowAnon, allowUnknown;
|
||||
bool subscribed, listener;
|
||||
bool publisher, allowAnon, allowUnknown;
|
||||
bool subscribed, listener;
|
||||
|
||||
uint32_t type;
|
||||
uint32_t type;
|
||||
|
||||
/// FLAG for Client - set if changed
|
||||
bool grpChanged;
|
||||
/// FLAG for Client - set if changed
|
||||
bool grpChanged;
|
||||
};
|
||||
|
||||
|
||||
@ -193,9 +202,9 @@ class GroupCache
|
||||
{
|
||||
public:
|
||||
|
||||
std::string filename;
|
||||
time_t start, end;
|
||||
uint16_t cacheSubId; /// used to resolve complete cache id
|
||||
std::string filename;
|
||||
time_t start, end;
|
||||
uint16_t cacheSubId; /// used to resolve complete cache id
|
||||
};
|
||||
|
||||
/* Flags for locked_notifyGroupChanged() ***/
|
||||
@ -208,7 +217,7 @@ const uint32_t GRP_SUBSCRIBED = 0x0005;
|
||||
const uint32_t GRP_UNSUBSCRIBED = 0x0006;
|
||||
|
||||
|
||||
//! Class service to implement group messages
|
||||
//! Cache based service to implement group messaging
|
||||
/*!
|
||||
*
|
||||
* Group Description:
|
||||
@ -218,9 +227,8 @@ const uint32_t GRP_UNSUBSCRIBED = 0x0006;
|
||||
* Filter Lists.
|
||||
* Publish Keys.
|
||||
*
|
||||
* Publish Keys. (multiple possible)
|
||||
* Filters: blacklist or whitelist.
|
||||
* TimeStore Length ??? (could make it a minimum of this and system one)
|
||||
* Publish Keys.
|
||||
* TimeStore Length determined by inheriting class
|
||||
*
|
||||
* Everyone gets:
|
||||
* Master Public Key.
|
||||
@ -236,17 +244,16 @@ const uint32_t GRP_UNSUBSCRIBED = 0x0006;
|
||||
*
|
||||
* Group id is the public admin keys id
|
||||
*
|
||||
* Create a Signing structure for Messages in general.
|
||||
*/
|
||||
class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, public p3Service
|
||||
{
|
||||
public:
|
||||
|
||||
p3GroupDistrib(uint16_t subtype,
|
||||
CacheStrapper *cs, CacheTransfer *cft,
|
||||
std::string sourcedir, std::string storedir, std::string keyBackUpDir,
|
||||
uint32_t configId,
|
||||
uint32_t storePeriod, uint32_t pubPeriod);
|
||||
p3GroupDistrib(uint16_t subtype,
|
||||
CacheStrapper *cs, CacheTransfer *cft,
|
||||
std::string sourcedir, std::string storedir, std::string keyBackUpDir,
|
||||
uint32_t configId,
|
||||
uint32_t storePeriod, uint32_t pubPeriod);
|
||||
|
||||
|
||||
/***************************************************************************************/
|
||||
@ -255,24 +262,45 @@ class p3GroupDistrib: public CacheSource, public CacheStore, public p3Config, pu
|
||||
/* TO FINISH */
|
||||
|
||||
public:
|
||||
virtual bool loadLocalCache(const CacheData &data); /// overloaded from Cache Source
|
||||
virtual int loadCache(const CacheData &data); /// overloaded from Cache Store
|
||||
|
||||
virtual bool loadLocalCache(const CacheData &data); /// overloaded from Cache Source
|
||||
virtual int loadCache(const CacheData &data); /// overloaded from Cache Store
|
||||
|
||||
private:
|
||||
/* top level load */
|
||||
int loadAnyCache(const CacheData &data, bool local);
|
||||
|
||||
/* load cache files */
|
||||
void loadFileGroups(std::string filename, std::string src, bool local);
|
||||
void loadFileMsgs(std::string filename, uint16_t cacheSubId, std::string src, uint32_t ts, bool local);
|
||||
bool backUpKeys(const std::list<RsDistribGrpKey* > &keysToBackUp, std::string grpId);
|
||||
void locked_sharePubKey();
|
||||
/* top level load */
|
||||
int loadAnyCache(const CacheData &data, bool local);
|
||||
|
||||
/* load cache files */
|
||||
void loadFileGroups(std::string filename, std::string src, bool local);
|
||||
void loadFileMsgs(std::string filename, uint16_t cacheSubId, std::string src, uint32_t ts, bool local);
|
||||
bool backUpKeys(const std::list<RsDistribGrpKey* > &keysToBackUp, std::string grpId);
|
||||
void locked_sharePubKey();
|
||||
|
||||
protected:
|
||||
/* load cache msgs */
|
||||
void loadMsg(RsDistribSignedMsg *msg, std::string src, bool local);
|
||||
void loadGroup(RsDistribGrp *newGrp);
|
||||
void loadGroupKey(RsDistribGrpKey *newKey);
|
||||
|
||||
/* load cache msgs */
|
||||
|
||||
/*!
|
||||
* msg is loaded to its group and republished,
|
||||
* msg decrypted if grp is private
|
||||
* @param msg msg to loaded
|
||||
* @param src src of msg (peer id)
|
||||
* @param local is this a local cache msg (your msg)
|
||||
*/
|
||||
void loadMsg(RsDistribSignedMsg *msg, std::string src, bool local);
|
||||
|
||||
/*!
|
||||
* adds newgrp to grp set, GroupInfo type created and stored
|
||||
* @param newGrp grp to be added
|
||||
*/
|
||||
void loadGroup(RsDistribGrp *newGrp);
|
||||
|
||||
/*!
|
||||
* Adds new keys dependent on whether it is an admin or publish key
|
||||
* @param newKey key to be added
|
||||
*/
|
||||
void loadGroupKey(RsDistribGrpKey *newKey);
|
||||
|
||||
|
||||
/***************************************************************************************/
|
||||
@ -284,53 +312,101 @@ void loadGroupKey(RsDistribGrpKey *newKey);
|
||||
/* TO FINISH */
|
||||
|
||||
public:
|
||||
std::string createGroup(std::wstring name, std::wstring desc, uint32_t flags, unsigned char*, uint32_t imageSize);
|
||||
//std::string modGroupDescription(std::string grpId, std::string discription);
|
||||
//std::string modGroupIcon(std::string grpId, PIXMAP *icon);
|
||||
|
||||
std::string publishMsg(RsDistribMsg *msg, bool personalSign);
|
||||
/*!
|
||||
* This create a distributed grp which is sent via cache system to connected peers
|
||||
* @param name name of the group created
|
||||
* @param desc description of the group
|
||||
* @param flags privacy flag
|
||||
* @param pngImageData pointer to image data, data is copied
|
||||
* @param imageSize size of the image passed
|
||||
* @return id of the group
|
||||
*/
|
||||
std::string createGroup(std::wstring name, std::wstring desc, uint32_t flags, unsigned char *pngImageData, uint32_t imageSize);
|
||||
|
||||
bool subscribeToGroup(std::string grpId, bool subscribe);
|
||||
/*!
|
||||
* msg is packed into a signed message (and encrypted msg grp is private) and then sent via cache system to connnected peers
|
||||
* @param msg
|
||||
* @param personalSign whether to personal to sign image (this is done using gpg cert)
|
||||
* @return the msg id
|
||||
*/
|
||||
std::string publishMsg(RsDistribMsg *msg, bool personalSign);
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param grpId id of group to subscribe to
|
||||
* @param subscribe true to subscribe and vice versa
|
||||
* @return
|
||||
*/
|
||||
bool subscribeToGroup(std::string grpId, bool subscribe);
|
||||
|
||||
|
||||
/***************************************************************************************/
|
||||
/***************************************************************************************/
|
||||
/***************************************************************************************/
|
||||
/***************************************************************************************/
|
||||
|
||||
/***************************************************************************************/
|
||||
/****************************** Access Content ***************************************/
|
||||
/***************************************************************************************/
|
||||
|
||||
/***************************************************************************************/
|
||||
/****************************** Access Content ***************************************/
|
||||
/***************************************************************************************/
|
||||
public:
|
||||
|
||||
/* get Group Lists */
|
||||
bool getAllGroupList(std::list<std::string> &grpids);
|
||||
bool getSubscribedGroupList(std::list<std::string> &grpids);
|
||||
bool getPublishGroupList(std::list<std::string> &grpids);
|
||||
bool getPopularGroupList(uint32_t popMin, uint32_t popMax, std::list<std::string> &grpids);
|
||||
/*!
|
||||
* get Group Lists
|
||||
*/
|
||||
bool getAllGroupList(std::list<std::string> &grpids);
|
||||
bool getSubscribedGroupList(std::list<std::string> &grpids);
|
||||
bool getPublishGroupList(std::list<std::string> &grpids);
|
||||
|
||||
/*!
|
||||
*
|
||||
* @param popMin lower limit for a grp's populairty in grpids
|
||||
* @param popMax upper limit for a grp's popularity in grpids
|
||||
* @param grpids grpids of grps which adhere to upper and lower limit of popularity
|
||||
* @return nothing returned
|
||||
*/
|
||||
void getPopularGroupList(uint32_t popMin, uint32_t popMax, std::list<std::string> &grpids);
|
||||
|
||||
|
||||
/* get Msg Lists */
|
||||
bool getAllMsgList(std::string grpId, std::list<std::string> &msgIds);
|
||||
bool getParentMsgList(std::string grpId, std::string pId, std::list<std::string> &msgIds);
|
||||
bool getTimePeriodMsgList(std::string grpId, uint32_t timeMin,
|
||||
uint32_t timeMax, std::list<std::string> &msgIds);
|
||||
/* get Msg Lists */
|
||||
bool getAllMsgList(std::string grpId, std::list<std::string> &msgIds);
|
||||
bool getParentMsgList(std::string grpId, std::string pId, std::list<std::string> &msgIds);
|
||||
bool getTimePeriodMsgList(std::string grpId, uint32_t timeMin,
|
||||
uint32_t timeMax, std::list<std::string> &msgIds);
|
||||
|
||||
|
||||
GroupInfo *locked_getGroupInfo(std::string grpId);
|
||||
RsDistribMsg *locked_getGroupMsg(std::string grpId, std::string msgId);
|
||||
GroupInfo *locked_getGroupInfo(std::string grpId);
|
||||
RsDistribMsg *locked_getGroupMsg(std::string grpId, std::string msgId);
|
||||
|
||||
/* Filter Messages */
|
||||
/* Filter Messages */
|
||||
|
||||
/***************************************************************************************/
|
||||
/***************************** Event Feedback ******************************************/
|
||||
/***************************************************************************************/
|
||||
|
||||
protected:
|
||||
/*!
|
||||
* root version (p3Distrib::) of this function must be called
|
||||
**/
|
||||
virtual void locked_notifyGroupChanged(GroupInfo &info, uint32_t flags);
|
||||
virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, std::string id) = 0;
|
||||
virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, std::string id) = 0;
|
||||
/*!
|
||||
* root version (p3Distrib::) of this function must be called
|
||||
*/
|
||||
virtual void locked_notifyGroupChanged(GroupInfo &info, uint32_t flags);
|
||||
|
||||
/*!
|
||||
* client (inheriting class) should use this to determing behaviour of
|
||||
* their service when a duplicate msg is found
|
||||
* @param group should be called when duplicate message loaded
|
||||
* @param the duplicate message
|
||||
* @param id
|
||||
* @return successfully executed or not
|
||||
*/
|
||||
virtual bool locked_eventDuplicateMsg(GroupInfo *, RsDistribMsg *, std::string id) = 0;
|
||||
|
||||
/*!
|
||||
* Inheriting class should implement this as a response to a new msg arriving
|
||||
* @param
|
||||
* @param
|
||||
* @param id src of msg (peer id)
|
||||
* @return
|
||||
*/
|
||||
virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, std::string id) = 0;
|
||||
|
||||
/***************************************************************************************/
|
||||
/********************************* p3Config ********************************************/
|
||||
@ -339,16 +415,17 @@ virtual bool locked_eventNewMsg(GroupInfo *, RsDistribMsg *, std::string id) = 0
|
||||
|
||||
protected:
|
||||
|
||||
virtual RsSerialiser *setupSerialiser();
|
||||
virtual std::list<RsItem *> saveList(bool &cleanup);
|
||||
virtual void saveDone();
|
||||
virtual bool loadList(std::list<RsItem *> load);
|
||||
virtual RsSerialiser *setupSerialiser();
|
||||
virtual std::list<RsItem *> saveList(bool &cleanup);
|
||||
virtual void saveDone();
|
||||
virtual bool loadList(std::list<RsItem *> load);
|
||||
|
||||
/***************************************************************************************/
|
||||
/***************************************************************************************/
|
||||
|
||||
public:
|
||||
virtual int tick(); /* overloaded form pqiService */
|
||||
|
||||
virtual int tick(); /* overloaded form pqiService */
|
||||
|
||||
/***************************************************************************************/
|
||||
/**************************** Publish Content ******************************************/
|
||||
@ -356,91 +433,171 @@ virtual int tick(); /* overloaded form pqiService */
|
||||
/* TO FINISH */
|
||||
protected:
|
||||
|
||||
/* create/mod cache content */
|
||||
void locked_toPublishMsg(RsDistribSignedMsg *msg);
|
||||
void publishPendingMsgs();
|
||||
void publishDistribGroups();
|
||||
void clear_local_caches(time_t now);
|
||||
/* create/mod cache content */
|
||||
|
||||
void locked_publishPendingMsgs();
|
||||
uint16_t locked_determineCacheSubId();
|
||||
/*!
|
||||
* adds msg to pending msg map
|
||||
* @param msg a signed message by peer
|
||||
*/
|
||||
void locked_toPublishMsg(RsDistribSignedMsg *msg);
|
||||
|
||||
/**
|
||||
* @param grpId the grpId id for which backup keys should be restored
|
||||
* @return false if failed and vice versa
|
||||
*/
|
||||
virtual bool restoreGrpKeys(std::string grpId); /// restores a group keys from backup
|
||||
/*!
|
||||
* adds pending msg
|
||||
*/
|
||||
void publishPendingMsgs();
|
||||
|
||||
/**
|
||||
* @param grpId the group for which to share public keys
|
||||
* @param peers The peers to which public keys should be sent
|
||||
*/
|
||||
virtual bool sharePubKey(std::string grpId, std::list<std::string>& peers);
|
||||
/*!
|
||||
* sends created groups to cache, to be passed to cache listeners
|
||||
*/
|
||||
void publishDistribGroups();
|
||||
|
||||
/**
|
||||
* attempts to receive publication keys
|
||||
*/
|
||||
virtual void locked_receivePubKeys();
|
||||
/*!
|
||||
* removes old caches based on store period (anything that has been in local cache longer
|
||||
* than the store period is deleted
|
||||
* @param now the current time when method is called
|
||||
*/
|
||||
void clear_local_caches(time_t now);
|
||||
|
||||
/**
|
||||
* this load received pub keys, useful in the case that publish keys have been received
|
||||
* but group info hasn't
|
||||
*/
|
||||
virtual void locked_loadRecvdPubKeys();
|
||||
/*!
|
||||
* assumes RsDistribMtx is locked when call is made
|
||||
*/
|
||||
void locked_publishPendingMsgs();
|
||||
|
||||
/**
|
||||
* Allows group admin(s) to change group icon, description and name
|
||||
*@param grpId group id
|
||||
*@param gi the changes to grp name, icon, and description should be reflected here
|
||||
*/
|
||||
virtual bool locked_editGroup(std::string grpId, GroupInfo& gi);
|
||||
/*!
|
||||
* @return cache sub id
|
||||
*/
|
||||
uint16_t locked_determineCacheSubId();
|
||||
|
||||
/**
|
||||
* encrypts data using envelope encryption (taken from open ssl's evp_sealinit )
|
||||
* only full publish key holders for can encrypt data for given group
|
||||
*@param out
|
||||
*@param outlen
|
||||
*@param in
|
||||
*@param inlen
|
||||
*/
|
||||
virtual bool encrypt(void *&out, int &outlen, const void *in, int inlen, std::string grpId);
|
||||
/**
|
||||
* grp keys are backed up when a grp is created this allows user to retrieve lost keys in case config saving fails
|
||||
* @param grpId the grpId id for which backup keys should be restored
|
||||
* @return false if failed and vice versa
|
||||
*/
|
||||
virtual bool restoreGrpKeys(std::string grpId); /// restores a group keys from backup
|
||||
|
||||
/**
|
||||
* Allows user to send keys to a list of peers
|
||||
* @param grpId the group for which to share public keys
|
||||
* @param peers The peers to which public keys should be sent
|
||||
*/
|
||||
virtual bool sharePubKey(std::string grpId, std::list<std::string>& peers);
|
||||
|
||||
/**
|
||||
* Attempt to receive publication keys
|
||||
*/
|
||||
virtual void locked_receivePubKeys();
|
||||
|
||||
/**
|
||||
* This loads received pub keys
|
||||
*
|
||||
*/
|
||||
virtual void locked_loadRecvdPubKeys();
|
||||
|
||||
/**
|
||||
* Allows group admin(s) to change group icon, description and name
|
||||
*@param grpId group id
|
||||
*@param gi the changes to grp name, icon, and description should be reflected here
|
||||
*/
|
||||
virtual bool locked_editGroup(std::string grpId, GroupInfo& gi);
|
||||
|
||||
/**
|
||||
* Encrypts data using envelope encryption (taken from open ssl's evp_sealinit )
|
||||
* only full publish key holders can encrypt data for given group
|
||||
*@param out
|
||||
*@param outlen
|
||||
*@param in
|
||||
*@param inlen
|
||||
*/
|
||||
virtual bool encrypt(void *&out, int &outlen, const void *in, int inlen, std::string grpId);
|
||||
|
||||
|
||||
/**
|
||||
* decrypts data using evelope decryption (taken from open ssl's evp_sealinit )
|
||||
* only full publish key holders can decrypt data for a group
|
||||
*@param out where decrypted data is written to
|
||||
*@param outlen
|
||||
*@param in
|
||||
*@param inlen
|
||||
*/
|
||||
virtual bool decrypt(void *&out, int &outlen, const void *in, int inlen, std::string grpId);
|
||||
/**
|
||||
* Decrypts data using evelope decryption (taken from open ssl's evp_sealinit )
|
||||
* only full publish key holders can decrypt data for a group
|
||||
*@param out where decrypted data is written to
|
||||
*@param outlen
|
||||
*@param in
|
||||
*@param inlen
|
||||
*/
|
||||
virtual bool decrypt(void *&out, int &outlen, const void *in, int inlen, std::string grpId);
|
||||
|
||||
/***************************************************************************************/
|
||||
/***************************************************************************************/
|
||||
/***************************************************************************************/
|
||||
/***************************************************************************************/
|
||||
|
||||
/***************************************************************************************/
|
||||
/*************************** Overloaded Functions **************************************/
|
||||
/***************************************************************************************/
|
||||
/***************************************************************************************/
|
||||
/*************************** Overloaded Functions **************************************/
|
||||
/***************************************************************************************/
|
||||
|
||||
/* Overloaded by inherited classes to Pack/UnPack their messages */
|
||||
virtual RsSerialType *createSerialiser() = 0;
|
||||
/*!
|
||||
* Overloaded by inherited classes to Pack/UnPack their messages
|
||||
* @return inherited class's serialiser
|
||||
*/
|
||||
virtual RsSerialType *createSerialiser() = 0;
|
||||
|
||||
/* Used to Create/Load Cache Files only */
|
||||
virtual pqistore *createStore(BinInterface *bio, std::string src, uint32_t bioflags);
|
||||
/*! Used to Create/Load Cache Files only
|
||||
* @param bio binary i/o
|
||||
* @param src peer id from which write/read content originates
|
||||
* @param bioflags read write permision for bio
|
||||
* @return pointer to pqistore instance
|
||||
*/
|
||||
virtual pqistore *createStore(BinInterface *bio, std::string src, uint32_t bioflags);
|
||||
|
||||
virtual bool validateDistribGrp(RsDistribGrp *newGrp);
|
||||
virtual bool locked_checkGroupInfo(GroupInfo &info, RsDistribGrp *newGrp);
|
||||
virtual bool locked_updateGroupInfo(GroupInfo &info, RsDistribGrp *newGrp);
|
||||
virtual bool locked_checkGroupKeys(GroupInfo &info);
|
||||
virtual bool locked_updateGroupAdminKey(GroupInfo &info, RsDistribGrpKey *newKey);
|
||||
virtual bool locked_updateGroupPublishKey(GroupInfo &info, RsDistribGrpKey *newKey);
|
||||
/*!
|
||||
* checks to see if admin signature is valid
|
||||
* @param newGrp grp to validate
|
||||
* @return true if group's signature is valid
|
||||
*/
|
||||
virtual bool validateDistribGrp(RsDistribGrp *newGrp);
|
||||
virtual bool locked_checkGroupInfo(GroupInfo &info, RsDistribGrp *newGrp);
|
||||
virtual bool locked_updateGroupInfo(GroupInfo &info, RsDistribGrp *newGrp);
|
||||
virtual bool locked_checkGroupKeys(GroupInfo &info);
|
||||
|
||||
/*!
|
||||
* @param info group for which admin key will be added to
|
||||
* @param newKey admin key
|
||||
* @return true if key successfully added
|
||||
*/
|
||||
virtual bool locked_updateGroupAdminKey(GroupInfo &info, RsDistribGrpKey *newKey);
|
||||
|
||||
|
||||
virtual bool locked_validateDistribSignedMsg(GroupInfo &info, RsDistribSignedMsg *msg);
|
||||
virtual RsDistribMsg* unpackDistribSignedMsg(RsDistribSignedMsg *newMsg);
|
||||
virtual bool locked_checkDistribMsg(GroupInfo &info, RsDistribMsg *msg);
|
||||
virtual bool locked_choosePublishKey(GroupInfo &info);
|
||||
/*!
|
||||
* @param info group for which publish key will be added to
|
||||
* @param newKey publish key
|
||||
* @return true if publish key successfully added
|
||||
*/
|
||||
virtual bool locked_updateGroupPublishKey(GroupInfo &info, RsDistribGrpKey *newKey);
|
||||
|
||||
|
||||
/*!
|
||||
* uses groupinfo public key to verify signature of signed message
|
||||
* @param info groupinfo for which msg is meant for
|
||||
* @param msg
|
||||
* @return false if verfication of signature is not passed
|
||||
*/
|
||||
virtual bool locked_validateDistribSignedMsg(GroupInfo &info, RsDistribSignedMsg *msg);
|
||||
|
||||
/*!
|
||||
* Use this to retrieve packed message from a signed message
|
||||
* @param newMsg signed message
|
||||
* @return pointer to unpacked msg
|
||||
*/
|
||||
virtual RsDistribMsg* unpackDistribSignedMsg(RsDistribSignedMsg *newMsg);
|
||||
|
||||
|
||||
/*!
|
||||
* message is checked to see if it is in a valid time range
|
||||
* @param info
|
||||
* @param msg message to be checked
|
||||
* @return false if msg is outside correct time range
|
||||
*/
|
||||
virtual bool locked_checkDistribMsg(GroupInfo &info, RsDistribMsg *msg);
|
||||
|
||||
/*!
|
||||
* chooses the best publish key based on it being full and latest
|
||||
* @param info group to choose publish key
|
||||
* @return true if a publish key could be found
|
||||
*/
|
||||
virtual bool locked_choosePublishKey(GroupInfo &info);
|
||||
|
||||
|
||||
//virtual RsDistribGrp *locked_createPublicDistribGrp(GroupInfo &info);
|
||||
@ -451,9 +608,10 @@ virtual bool locked_choosePublishKey(GroupInfo &info);
|
||||
/***************************** Utility Functions ***************************************/
|
||||
/***************************************************************************************/
|
||||
/* TO FINISH */
|
||||
/* utilities */
|
||||
std::string HashRsItem(const RsItem *item);
|
||||
bool locked_updateChildTS(GroupInfo &gi, RsDistribMsg *msg);
|
||||
|
||||
/* utilities */
|
||||
std::string HashRsItem(const RsItem *item);
|
||||
bool locked_updateChildTS(GroupInfo &gi, RsDistribMsg *msg);
|
||||
|
||||
/***************************************************************************************/
|
||||
/***************************************************************************************/
|
||||
@ -463,11 +621,12 @@ bool locked_updateChildTS(GroupInfo &gi, RsDistribMsg *msg);
|
||||
/***************************************************************************************/
|
||||
public:
|
||||
|
||||
void printGroups(std::ostream &out);
|
||||
/*!
|
||||
* returns list of ids for group caches that have changed
|
||||
*/
|
||||
bool groupsChanged(std::list<std::string> &groupIds);
|
||||
void printGroups(std::ostream &out);
|
||||
|
||||
/*!
|
||||
* returns list of ids for group caches that have changed
|
||||
*/
|
||||
bool groupsChanged(std::list<std::string> &groupIds);
|
||||
|
||||
/***************************************************************************************/
|
||||
/***************************************************************************************/
|
||||
@ -478,33 +637,32 @@ bool groupsChanged(std::list<std::string> &groupIds);
|
||||
/* storage */
|
||||
protected:
|
||||
|
||||
RsMutex distribMtx; /// Protects All Data Below
|
||||
std::string mOwnId;
|
||||
RsMutex distribMtx; /// Protects all class atrributes
|
||||
std::string mOwnId; /// rs peer id
|
||||
|
||||
private:
|
||||
|
||||
std::list<GroupCache> mLocalCaches;
|
||||
std::map<std::string, GroupInfo> mGroups;
|
||||
uint32_t mStorePeriod, mPubPeriod;
|
||||
|
||||
/* Message Publishing */
|
||||
std::list<RsDistribSignedMsg *> mPendingPublish;
|
||||
time_t mLastPublishTime;
|
||||
std::map<uint32_t, uint16_t> mLocalCacheTs;
|
||||
uint16_t mMaxCacheSubId;
|
||||
|
||||
bool mGroupsChanged;
|
||||
bool mGroupsRepublish;
|
||||
|
||||
std::list<RsItem *> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */
|
||||
std::string mKeyBackUpDir;
|
||||
const std::string BACKUP_KEY_FILE;
|
||||
|
||||
std::map<std::string, RsDistribGrpKey* > mRecvdPubKeys; /// full publishing keys received from users
|
||||
std::map<std::string, std::list<std::string> > mPendingPubKeyRecipients; /// peers to receive publics key for a given grp
|
||||
time_t mLastKeyPublishTime, mLastRecvdKeyTime;
|
||||
|
||||
std::list<GroupCache> mLocalCaches;
|
||||
std::map<std::string, GroupInfo> mGroups;
|
||||
uint32_t mStorePeriod, mPubPeriod;
|
||||
|
||||
/* Message Publishing */
|
||||
std::list<RsDistribSignedMsg *> mPendingPublish;
|
||||
time_t mLastPublishTime;
|
||||
std::map<uint32_t, uint16_t> mLocalCacheTs;
|
||||
uint16_t mMaxCacheSubId;
|
||||
|
||||
bool mGroupsChanged;
|
||||
bool mGroupsRepublish;
|
||||
|
||||
std::list<RsItem *> saveCleanupList; /* TEMPORARY LIST WHEN SAVING */
|
||||
std::string mKeyBackUpDir;
|
||||
const std::string BACKUP_KEY_FILE;
|
||||
|
||||
std::map<std::string, RsDistribGrpKey* > mRecvdPubKeys; /// full publishing keys received from users
|
||||
std::map<std::string, std::list<std::string> > mPendingPubKeyRecipients; /// peers to receive publics key for a given grp
|
||||
time_t mLastKeyPublishTime, mLastRecvdKeyTime;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user