Revision fbeb4f32

View differences:

loop-mt.c
48 48
    switch (buff[0] /* Message Type */) {
49 49
      case MSG_TYPE_TOPOLOGY:
50 50
        pthread_mutex_lock(&topology_mutex);
51
        update_peers(pset, buff, len);
51
        update_peers(pset, remote, buff, len);
52 52
        pthread_mutex_unlock(&topology_mutex);
53 53
        break;
54 54
      case MSG_TYPE_CHUNK:
......
74 74
    switch (buff[0] /* Message Type */) {
75 75
      case MSG_TYPE_TOPOLOGY:
76 76
        pthread_mutex_lock(&topology_mutex);
77
        update_peers(pset, buff, len);
77
        update_peers(pset, remote, buff, len);
78 78
        pthread_mutex_unlock(&topology_mutex);
79 79
        break;
80 80
      case MSG_TYPE_CHUNK:
......
101 101
  int gossiping_period = period * 10;
102 102

  
103 103
  pthread_mutex_lock(&topology_mutex);
104
  update_peers(pset, NULL, 0);
104
  update_peers(pset, NULL, NULL, 0);
105 105
  pthread_mutex_unlock(&topology_mutex);
106 106
  while(!done) {
107 107
    pthread_mutex_lock(&topology_mutex);
108
    update_peers(pset, NULL, 0);
108
    update_peers(pset, NULL, NULL, 0);
109 109
    pthread_mutex_unlock(&topology_mutex);
110 110
    usleep(gossiping_period);
111 111
  }
loop.c
46 46
  period.tv_usec = csize % 1000000;
47 47
  
48 48
  sigInit(s,pset);
49
  update_peers(pset, NULL, 0);
49
  update_peers(pset, NULL, NULL, 0);
50 50
  stream_init(buff_size, s);
51 51
  while (!done) {
52 52
    int len, res;
......
60 60
      len = recv_from_peer(s, &remote, buff, BUFFSIZE);
61 61
      switch (buff[0] /* Message Type */) {
62 62
        case MSG_TYPE_TOPOLOGY:
63
          update_peers(pset, buff, len);
63
          update_peers(pset, remote, buff, len);
64 64
          break;
65 65
        case MSG_TYPE_CHUNK:
66 66
          received_chunk(pset, remote, buff, len);
......
78 78
      //send_chunk(pset);
79 79
      send_offer(pset);
80 80
      if (cnt++ % 10 == 0) {
81
        update_peers(pset,NULL, 0);
81
        update_peers(pset, NULL, NULL, 0);
82 82
      }
83 83
      timeradd(&tnext, &period, &tmp);
84 84
      tnext = tmp;
......
108 108
      struct nodeID *remote;
109 109

  
110 110
      len = recv_from_peer(s, &remote, buff, BUFFSIZE);
111
      dprintf("Received message (%c) from %s\n", buff[0], node_addr(remote));
111 112
      switch (buff[0] /* Message Type */) {
112 113
        case MSG_TYPE_TOPOLOGY:
113 114
          fprintf(stderr, "Top Parse\n");
114
          update_peers(pset, buff, len);
115
          update_peers(pset, remote, buff, len);
115 116
          break;
116 117
        case MSG_TYPE_CHUNK:
117 118
          fprintf(stderr, "Some dumb peer pushed a chunk to me!\n");
......
133 134
          send_chunk(pset);
134 135
        }
135 136
        if (cnt++ % 10 == 0) {
136
            update_peers(pset, NULL, 0);
137
            update_peers(pset, NULL, NULL, 0);
137 138
        }
138 139
      }
139 140
      timeradd(&tnext, &d, &tmp);
topology.c
13 13
static struct timeval tout_bmap = {3, 0};
14 14

  
15 15
// currently it just makes the peerset grow
16
void update_peers(struct peerset *pset, const uint8_t *buff, int len)
16
void update_peers(struct peerset *pset, struct nodeID *from, const uint8_t *buff, int len)
17 17
{
18 18
  int n_ids, i;
19 19
  const struct nodeID **ids;
topology.h
1 1
#include <stdint.h>
2 2

  
3
void update_peers(struct peerset *pset, const uint8_t *buff, int len);
3
void update_peers(struct peerset *pset, struct nodeID *from, const uint8_t *buff, int len);

Also available in: Unified diff