Statistics
| Branch: | Revision:

grapes / src / TopologyManager / topocache.h @ 5033613a

History | View | Annotate | Download (1.67 KB)

1 60fa723d Luca Abeni
#ifndef TOPOCACHE
2
#define TOPOCACHE
3
4 11485577 Luca Abeni
struct peer_cache;
5 480921a6 Luca Abeni
struct cache_entry;
6 393aa781 Luca Abeni
typedef int (*ranking_function)(const void *target, const void *p1, const void *p2);        // FIXME!
7
8 18d83f26 Luca Abeni
struct peer_cache *cache_init(int n, int metadata_size, int max_timestamp);
9 b81d3f0f Luca
void cache_free(struct peer_cache *c);
10
void cache_update(struct peer_cache *c);
11 11485577 Luca Abeni
struct nodeID *nodeid(const struct peer_cache *c, int i);
12 fe701696 Luca
const void *get_metadata(const struct peer_cache *c, int *size);
13 90cea048 Luca
int cache_metadata_update(struct peer_cache *c, struct nodeID *p, const void *meta, int meta_size);
14 d74d9d89 Luca Abeni
int cache_add_ranked(struct peer_cache *c, struct nodeID *neighbour, const void *meta, int meta_size, ranking_function f, const void *tmeta);
15 886456d7 Luca
int cache_add(struct peer_cache *c, struct nodeID *neighbour, const void *meta, int meta_size);
16 11485577 Luca Abeni
int cache_del(struct peer_cache *c, struct nodeID *neighbour);
17 b81d3f0f Luca
18 b95a5127 Marco Biazzini
struct nodeID *rand_peer(struct peer_cache *c, void **meta, int max);
19 194ec532 Luca Abeni
struct nodeID *last_peer(struct peer_cache *c);
20
struct peer_cache *rand_cache(struct peer_cache *c, int n);
21 b81d3f0f Luca
22 11485577 Luca Abeni
struct peer_cache *entries_undump(const uint8_t *buff, int size);
23 1a101c0b Luca Abeni
int cache_header_dump(uint8_t *b, const struct peer_cache *c, int include_me);
24 28399cdc Csaba Kiraly
int entry_dump(uint8_t *b, struct peer_cache *e, int i, size_t max_write_size);
25 b81d3f0f Luca
26 661d190d Luca Abeni
struct peer_cache *merge_caches(struct peer_cache *c1, struct peer_cache *c2, int newsize, int *source);
27 973fb1fd Marco Biazzini
struct peer_cache *cache_rank (const struct peer_cache *c, ranking_function rank, const struct nodeID *target, const void *target_meta);
28 6f80ff91 Marco Biazzini
struct peer_cache *cache_union(struct peer_cache *c1, struct peer_cache *c2, int *size);
29
int cache_resize (struct peer_cache *c, int size);
30 194ec532 Luca Abeni
31
void cache_check(const struct peer_cache *c);
32 60fa723d Luca Abeni
33
#endif        /* TOPOCACHE */