Revision e3dbef44 src/Cache/cloudcast_proto.c

View differences:

src/Cache/cloudcast_proto.c
21 21
#define CLOUD_VIEW_KEY "view"
22 22

  
23 23
struct topo_header cloud_header = {MSG_TYPE_TOPOLOGY, CLOUDCAST_CLOUD};
24

  
25 24
struct cloudcast_proto_context {
26 25
  struct peer_cache* myEntry;
26
  uint8_t def_cloudcache[128];
27
  int def_cloudcache_len;
27 28
  struct topo_context *topo_context;
28 29
  struct cloud_helper_context *cloud_context;
29 30
};
30 31

  
32
int cloudcast_payload_fill(struct cloudcast_proto_context *context, uint8_t *payload, int size, struct peer_cache *c, int max_peers, int include_me);
33

  
31 34
struct cloudcast_proto_context* cloudcast_proto_init(struct nodeID *s, const void *meta, int meta_size)
32 35
{
33 36
  struct cloudcast_proto_context *con;
37
  struct peer_cache *tmp;
34 38
  con = malloc(sizeof(struct cloudcast_proto_context));
35 39

  
36 40
  if (!con) {
......
53 57
  }
54 58

  
55 59
  con->myEntry = cache_init(1, meta_size, 0);
60
  tmp = cache_init(0, meta_size, 0);
61
  con->def_cloudcache_len = cloudcast_payload_fill(con, con->def_cloudcache, sizeof(con->def_cloudcache), tmp, 0, 0);
62
  fprintf(stderr, "cachelen: %d\n", con->def_cloudcache_len);
63
  cache_free(tmp);
56 64
  cache_add(con->myEntry, s, meta, meta_size);
57 65

  
58 66
  return con;
......
136 144

  
137 145
int cloudcast_query_cloud(struct cloudcast_proto_context *context)
138 146
{
139
  return get_from_cloud(context->cloud_context, CLOUD_VIEW_KEY, (uint8_t *)&cloud_header, sizeof(cloud_header), 0);
147
  return get_from_cloud_default(context->cloud_context, CLOUD_VIEW_KEY,
148
                                (uint8_t *)&cloud_header, sizeof(cloud_header),
149
                                0, context->def_cloudcache,
150
                                context->def_cloudcache_len, 0);
140 151
}
141 152

  
142 153
struct peer_cache * cloudcast_cloud_default_reply(struct peer_cache *template, struct nodeID *cloud_entry)

Also available in: Unified diff