grapes / src / Cache / topocache.h @ 848dc803
History | View | Annotate | Download (1.83 KB)
1 |
#ifndef TOPOCACHE
|
---|---|
2 |
#define TOPOCACHE
|
3 |
|
4 |
struct peer_cache;
|
5 |
struct cache_entry;
|
6 |
typedef int (*ranking_function)(const void *target, const void *p1, const void *p2); // FIXME! |
7 |
|
8 |
struct peer_cache *cache_init(int n, int metadata_size, int max_timestamp); |
9 |
struct peer_cache *cache_copy(const struct peer_cache *c); |
10 |
void cache_free(struct peer_cache *c); |
11 |
void cache_update(struct peer_cache *c); |
12 |
void cache_delay(struct peer_cache *c, int dts); |
13 |
struct nodeID *nodeid(const struct peer_cache *c, int i); |
14 |
const void *get_metadata(const struct peer_cache *c, int *size); |
15 |
int cache_metadata_update(struct peer_cache *c, const struct nodeID *p, const void *meta, int meta_size); |
16 |
int cache_add_ranked(struct peer_cache *c, struct nodeID *neighbour, const void *meta, int meta_size, ranking_function f, const void *tmeta); |
17 |
int cache_add(struct peer_cache *c, struct nodeID *neighbour, const void *meta, int meta_size); |
18 |
int cache_del(struct peer_cache *c, const struct nodeID *neighbour); |
19 |
|
20 |
struct nodeID *rand_peer(const struct peer_cache *c, void **meta, int max); |
21 |
struct nodeID *last_peer(const struct peer_cache *c); |
22 |
struct peer_cache *rand_cache(struct peer_cache *c, int n); |
23 |
|
24 |
struct peer_cache *entries_undump(const uint8_t *buff, int size); |
25 |
int cache_header_dump(uint8_t *b, const struct peer_cache *c, int include_me); |
26 |
int entry_dump(uint8_t *b, const struct peer_cache *e, int i, size_t max_write_size); |
27 |
|
28 |
struct peer_cache *merge_caches(const struct peer_cache *c1, const struct peer_cache *c2, int newsize, int *source); |
29 |
struct peer_cache *cache_rank (const struct peer_cache *c, ranking_function rank, const struct nodeID *target, const void *target_meta); |
30 |
struct peer_cache *cache_union(const struct peer_cache *c1, const struct peer_cache *c2, int *size); |
31 |
int cache_resize (struct peer_cache *c, int size); |
32 |
|
33 |
void cache_check(const struct peer_cache *c); |
34 |
|
35 |
#endif /* TOPOCACHE */ |