streamers / transition / topmanager.h @ 01608efd
History | View | Annotate | Download (1.65 KB)
1 |
#ifndef TOPMAN_H
|
---|---|
2 |
#define TOPMAN_H
|
3 |
|
4 |
/** @file topmanager.h
|
5 |
*
|
6 |
* @brief transitional file: conversion to peersampler.h
|
7 |
*
|
8 |
* This file serve to convert from the old TopologyManager interface to the new PeerSampler interface in GRAPES 0.2 and above
|
9 |
* the use of this file is temporary, the new topology module will interface directly!
|
10 |
* WARNING: the blacklist is not implemented
|
11 |
*
|
12 |
*/
|
13 |
|
14 |
#include <peersampler.h> |
15 |
struct psample_context;
|
16 |
static struct psample_context *tc; |
17 |
|
18 |
inline const struct nodeID **topGetNeighbourhood(int *n) |
19 |
{ |
20 |
return psample_get_cache(tc, n);
|
21 |
} |
22 |
|
23 |
inline const void *topGetMetadata(int *metadata_size) |
24 |
{ |
25 |
return psample_get_metadata(tc, metadata_size);
|
26 |
} |
27 |
|
28 |
inline int topGrowNeighbourhood(int n) |
29 |
{ |
30 |
return psample_grow_cache(tc, n);
|
31 |
} |
32 |
|
33 |
inline int topShrinkNeighbourhood(int n) |
34 |
{ |
35 |
return psample_shrink_cache(tc, n);
|
36 |
} |
37 |
|
38 |
inline int topRemoveNeighbour(struct nodeID *neighbour) |
39 |
{ |
40 |
return psample_remove_peer(tc, neighbour);
|
41 |
} |
42 |
|
43 |
inline int topChangeMetadata(void *metadata, int metadata_size) |
44 |
{ |
45 |
return psample_change_metadata(tc, metadata, metadata_size);
|
46 |
} |
47 |
|
48 |
inline int topInit(struct nodeID *myID, void *metadata, int metadata_size, const char *config) |
49 |
{ |
50 |
tc = psample_init(myID, metadata, metadata_size, config); |
51 |
return tc ? 0 : -1; |
52 |
} |
53 |
|
54 |
inline int topAddNeighbour(struct nodeID *neighbour, void *metadata, int metadata_size) |
55 |
{ |
56 |
return psample_add_peer(tc, neighbour, metadata, metadata_size);
|
57 |
} |
58 |
|
59 |
inline int topParseData(const uint8_t *buff, int len) |
60 |
{ |
61 |
return psample_parse_data(tc, buff, len);
|
62 |
} |
63 |
|
64 |
inline int topAddToBlackList(struct nodeID *neighbour) |
65 |
{ |
66 |
return 0; |
67 |
} |
68 |
|
69 |
inline int tmanAddToBlackList(struct nodeID *neighbour) |
70 |
{ |
71 |
return 0; |
72 |
} |
73 |
|
74 |
#endif //TOPMAN_H |