Revision 3df216c8

View differences:

Makefile
23 23
CPPFLAGS += -DDEBUG
24 24
endif
25 25

  
26
LDFLAGS = -L$(GRAPES)/som/TopologyManager -L$(GRAPES)/som/ChunkTrading -L$(GRAPES)/som/ChunkBuffer -L$(GRAPES)/som/Scheduler
27
LDLIBS = -ltrading -lcb -ltopman -lsched
26
LDFLAGS = -L$(GRAPES)/som/TopologyManager -L$(GRAPES)/som/ChunkTrading -L$(GRAPES)/som/ChunkBuffer -L$(GRAPES)/som/Scheduler -L$(GRAPES)/som/PeerSet -L$(GRAPES)/som/ChunkIDSet
27
LDLIBS = -ltrading -lcb -ltopman -lsched -lpeerset -lsignalling
28 28

  
29 29
OBJS = dumbstreamer.o streaming.o output.o net_helpers.o
30 30
ifdef THREADS
loop.c
8 8
#include <net_helper.h>
9 9
#include <topmanager.h>
10 10
#include <msg_types.h>
11
#include <peerset.h>
11 12

  
12 13
#include "streaming.h"
13 14
#include "loop.h"
......
31 32
  }
32 33
}
33 34

  
35
// currently it just makes the peerset grow
36
void update_peers(struct peerset *pset, const uint8_t *buff, int len)
37
{
38
  int n_ids;
39
  const struct nodeID **ids;
40
  topParseData(buff, len);
41
  ids = topGetNeighbourhood(&n_ids);
42
  peerset_add_peers(pset,ids,n_ids);
43
}
44

  
45

  
34 46
void loop(struct nodeID *s, int csize, int buff_size)
35 47
{
36 48
  int done = 0;
37 49
  static uint8_t buff[BUFFSIZE];
38 50
  int cnt = 0;
51
  struct peerset *pset = peerset_init(0);
39 52
  
40 53
  period.tv_sec = csize / 1000000;
41 54
  period.tv_usec = csize % 1000000;
42 55
  
43
  topParseData(NULL, 0);
56
  update_peers(pset, NULL, 0);
44 57
  stream_init(buff_size, s);
45 58
  while (!done) {
46 59
    int len, res;
......
54 67
      len = recv_from_peer(s, &remote, buff, BUFFSIZE);
55 68
      switch (buff[0] /* Message Type */) {
56 69
        case MSG_TYPE_TOPOLOGY:
57
          topParseData(buff, len);
70
          update_peers(pset, buff, len);
58 71
          break;
59 72
        case MSG_TYPE_CHUNK:
60 73
          received_chunk(buff, len);
......
71 84
      neighbours = topGetNeighbourhood(&n);
72 85
      send_chunk(neighbours, n);
73 86
      if (cnt++ % 10 == 0) {
74
        topParseData(NULL, 0);
87
        update_peers(pset,NULL, 0);
75 88
      }
76 89
      timeradd(&tnext, &period, &tmp);
77 90
      tnext = tmp;
......
84 97
  int done = 0;
85 98
  static uint8_t buff[BUFFSIZE];
86 99
  int cnt = 0;
100
  struct peerset *pset = peerset_init(0);
87 101

  
88 102
  period.tv_sec = csize  / 1000000;
89 103
  period.tv_usec = csize % 1000000;
......
102 116
      switch (buff[0] /* Message Type */) {
103 117
        case MSG_TYPE_TOPOLOGY:
104 118
          fprintf(stderr, "Top Parse\n");
105
          topParseData(buff, len);
119
          update_peers(pset, buff, len);
106 120
          break;
107 121
        case MSG_TYPE_CHUNK:
108 122
          fprintf(stderr, "Some dumb peer pushed a chunk to me!\n");
......
122 136
        send_chunk(neighbours, n);
123 137
      }
124 138
      if (cnt++ % 10 == 0) {
125
        topParseData(NULL, 0);
139
          update_peers(pset, NULL, 0);
126 140
      }
127 141
      timeradd(&tnext, &period, &tmp);
128 142
      tnext = tmp;

Also available in: Unified diff