Statistics
| Branch: | Revision:

grapes / src / Cache / topocache.h @ cdee81c5

History | View | Annotate | Download (2.42 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
struct nodeID *nodeid(const struct peer_cache *c, int i);
13
const void *get_metadata(const struct peer_cache *c, int *size);
14
int cache_metadata_update(struct peer_cache *c, const struct nodeID *p, const void *meta, int meta_size);
15
int cache_add_ranked(struct peer_cache *c, struct nodeID *neighbour, const void *meta, int meta_size, ranking_function f, const void *tmeta);
16
int cache_add(struct peer_cache *c, struct nodeID *neighbour, const void *meta, int meta_size);
17
int cache_del(struct peer_cache *c, const struct nodeID *neighbour);
18

    
19
int cache_entries(const struct peer_cache *c);
20
int cache_pos(const struct peer_cache *c, const struct nodeID *neighbour);
21
struct nodeID *rand_peer(const struct peer_cache *c, void **meta, int max);
22
struct nodeID *last_peer(const struct peer_cache *c);
23
struct peer_cache *rand_cache(struct peer_cache *c, int n);
24
struct peer_cache *rand_cache_except(struct peer_cache *c, int n, struct nodeID *except[], int len);
25

    
26
struct peer_cache *entries_undump(const uint8_t *buff, int size);
27
int cache_header_dump(uint8_t *b, const struct peer_cache *c, int include_me);
28
int entry_dump(uint8_t *b, const struct peer_cache *e, int i, size_t max_write_size);
29

    
30
struct peer_cache *merge_caches(const struct peer_cache *c1, const struct peer_cache *c2, int newsize, int *source);
31
struct peer_cache *cache_rank (const struct peer_cache *c, ranking_function rank, const struct nodeID *target, const void *target_meta);
32
struct peer_cache *cache_union(const struct peer_cache *c1, const struct peer_cache *c2, int *size);
33
int cache_resize (struct peer_cache *c, int size);
34

    
35
int cache_max_size(const struct peer_cache *c);
36
int cache_current_size(const struct peer_cache *c);
37

    
38
int cache_fill_rand(struct peer_cache *dst, const struct peer_cache *src, int target_size);
39
int cache_fill_ordered(struct peer_cache *dst, const struct peer_cache *src, int target_size);
40

    
41
void cache_check(const struct peer_cache *c);
42

    
43
void cache_log(const struct peer_cache *c, const char *name);
44

    
45
int cache_add_cache(struct peer_cache *dst, const struct peer_cache *src);
46

    
47
#endif  /* TOPOCACHE */