-
Notifications
You must be signed in to change notification settings - Fork 1
/
RoutingManager.h
56 lines (40 loc) · 1.16 KB
/
RoutingManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef __ROUTINGMANAGER_H
#define __ROUTINGMANAGER_H
#include <wx/wx.h>
#include <vector>
#include <map>
#include "BValue.h"
namespace RAIN
{
class PeerID;
class Message;
class RoutePath
{
public:
RoutePath(const wxString& target, const wxArrayString& path);
size_t GetPathLength() const;
void PreloadMessage(RAIN::Message *m);
static bool IsValidRoute(const wxString& target, const wxArrayString& path);
void DumpRoute();
wxString target;
private:
wxArrayString path;
};
class RoutingManager
{
public:
RoutingManager();
~RoutingManager();
void ImportBroadcast(RAIN::Message *m);
void DumpKnownRoutes();
bool HasRoute(const wxString& target);
RAIN::RoutePath * GetBestRoute(const wxString& target);
/* path discovery helpers */
static BEnc::Value * findParentNode(BEnc::Value *v, const wxString& key);
static bool nodeContainsKey(BEnc::Value *v, const wxString& key);
static wxArrayString pathFromMeToDist(BEnc::Value *p, BEnc::Value *dist, BEnc::Value *via, wxArrayString& path);
private:
std::vector<RAIN::RoutePath*> knownRoutes;
};
}
#endif//__ROUTINGMANAGER_H