mirror of
https://github.com/RetroShare/RetroShare.git
synced 2025-08-10 23:30:14 -04:00

- specify how long we store for. - cleanup old msgs. - improve printing of history. - add timeline storage as well. - disabled by default, enable USE_HISTORY in bdnode.c There appears to be a bug related to copying bdId's around. Some of the bootstrap ids are malformed, and this crashes rs. git-svn-id: http://svn.code.sf.net/p/retroshare/code/trunk@5724 b45a01b8-16f6-495d-af2f-9b41ad6348cc
70 lines
1.3 KiB
C++
70 lines
1.3 KiB
C++
#ifndef BITDHT_HISTORY_H
|
|
#define BITDHT_HISTORY_H
|
|
|
|
#include "bitdht/bdpeer.h"
|
|
#include "bitdht/bdobj.h"
|
|
#include <map>
|
|
|
|
#define MSG_TYPE_DIRECTION_MASK 0x000f0000
|
|
|
|
#define MSG_DIRECTION_INCOMING 0x00010000
|
|
#define MSG_DIRECTION_OUTGOING 0x00020000
|
|
|
|
/**** DEBUGGING HISTORY ****/
|
|
|
|
class MsgRegister
|
|
{
|
|
public:
|
|
MsgRegister() { return; }
|
|
MsgRegister(const bdId *inId, uint32_t inMsgType, bool inIncoming)
|
|
:id(*inId), msgType(inMsgType), incoming(inIncoming) { return; }
|
|
|
|
bdId id;
|
|
uint32_t msgType;
|
|
bool incoming;
|
|
};
|
|
|
|
|
|
|
|
class bdMsgHistoryList
|
|
{
|
|
public:
|
|
void addMsg(time_t ts, uint32_t msgType, bool incoming);
|
|
int msgCount(time_t start_ts, time_t end_ts);
|
|
bool msgClear(time_t before); // 0 => clear all.
|
|
void printHistory(std::ostream &out, int mode, time_t start_ts, time_t end_ts);
|
|
|
|
bool canSend();
|
|
bool validPeer();
|
|
|
|
std::multimap<time_t, uint32_t> msgHistory;
|
|
};
|
|
|
|
|
|
|
|
class bdHistory
|
|
{
|
|
public:
|
|
bdHistory(time_t store_period);
|
|
|
|
void addMsg(const bdId *id, bdToken *transId, uint32_t msgType, bool incoming);
|
|
void printMsgs();
|
|
|
|
void cleanupOldMsgs();
|
|
void clearHistory();
|
|
|
|
bool canSend(const bdId *id);
|
|
bool validPeer(const bdId *id);
|
|
|
|
/* recent history */
|
|
//std::list<bdId> lastMsgs;
|
|
std::map<bdId, bdMsgHistoryList> mHistory;
|
|
std::multimap<time_t, MsgRegister> mMsgTimeline;
|
|
|
|
int mStorePeriod;
|
|
};
|
|
|
|
|
|
|
|
#endif
|
|
|