- GNUNET_CRYPTO_hmac(&s->auth_key,
- id,
- sizeof(struct GNUNET_PeerIdentity),
- &other_hash);
-
- if ( NULL == s->peer_id ) { // Or whatever is a valid way to say
- // "we have no PeerID at the moment"
- *s->peer_id = *id;
- s->peer_id_hash = other_hash;
-
- } else {
-
- if ( hash_cmp(other_hash, s->peer_id_hash) ) {
- LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Got PeerID %s; Discarding old PeerID %s\n",
- GNUNET_i2s(id), GNUNET_i2s(s->peer_id));
-
- if ( NULL != del_cb ) {
+ if ( id == s->peer_id )
+ {
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Got PeerID %s\n",
+ GNUNET_i2s(id));
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Have already PeerID %s\n",
+ GNUNET_i2s(s->peer_id));
+ }
+ else
+ {
+ GNUNET_CRYPTO_hmac(&s->auth_key,
+ id,
+ sizeof(struct GNUNET_PeerIdentity),
+ &other_hash);
+
+ if ( NULL == s->peer_id )
+ { // Or whatever is a valid way to say
+ // "we have no PeerID at the moment"
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Got PeerID %s; Simply accepting (got NULL previously).\n",
+ GNUNET_i2s(id));
+ memcpy(s->peer_id, id, sizeof(struct GNUNET_PeerIdentity));
+ //s->peer_id = id;
+ s->peer_id_hash = other_hash;
+ }
+ else if ( 0 > hash_cmp(other_hash, s->peer_id_hash) )
+ {
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Got PeerID %s\n",
+ GNUNET_i2s(id));
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Discarding old PeerID %s\n",
+ GNUNET_i2s(s->peer_id));
+
+ if ( NULL != del_cb )
+ {
+ LOG(GNUNET_ERROR_TYPE_DEBUG, "SAMPLER: Removing old PeerID %s with the delete callback.\n",
+ GNUNET_i2s(s->peer_id));