Statistics
| Branch: | Revision:

grapes / src / Cache / topocache.h @ 861dac1d

History | View | Annotate | Download (2.38 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_pos(const struct peer_cache *c, const struct nodeID *neighbour);
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
struct peer_cache *rand_cache_except(struct peer_cache *c, int n, struct nodeID *except[], int len);
24

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

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

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

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

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

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

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

    
46
#endif  /* TOPOCACHE */