[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r34839 - gnunet/src/rps
From: |
gnunet |
Subject: |
[GNUnet-SVN] r34839 - gnunet/src/rps |
Date: |
Wed, 7 Jan 2015 18:27:15 +0100 |
Author: ch3
Date: 2015-01-07 18:27:15 +0100 (Wed, 07 Jan 2015)
New Revision: 34839
Modified:
gnunet/src/rps/gnunet-service-rps.c
Log:
got rid of touch_*()
Modified: gnunet/src/rps/gnunet-service-rps.c
===================================================================
--- gnunet/src/rps/gnunet-service-rps.c 2015-01-07 17:18:02 UTC (rev 34838)
+++ gnunet/src/rps/gnunet-service-rps.c 2015-01-07 17:27:15 UTC (rev 34839)
@@ -291,113 +291,76 @@
/**
- * Make sure the context of a given peer exists in the given peer_map.
+ * Get the context of a peer. If not existing, create.
*/
- void
-touch_peer_ctx (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct
GNUNET_PeerIdentity *peer)
+ struct peer_context *
+get_peer_ctx (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct
GNUNET_PeerIdentity *peer)
{
struct peer_context *ctx;
- if ( GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains( peer_map, peer ) )
+ if ( GNUNET_YES == GNUNET_CONTAINER_multipeermap_contains (peer_map, peer))
{
- ctx = GNUNET_CONTAINER_multipeermap_get(peer_map, peer);
+ ctx = GNUNET_CONTAINER_multipeermap_get (peer_map, peer);
}
else
{
- ctx = GNUNET_new(struct peer_context);
+ ctx = GNUNET_new (struct peer_context);
ctx->in_flags = 0;
ctx->mq = NULL;
ctx->to_channel = NULL;
ctx->from_channel = NULL;
- (void) GNUNET_CONTAINER_multipeermap_put( peer_map, peer, ctx,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
+ (void) GNUNET_CONTAINER_multipeermap_put (peer_map, peer, ctx,
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_FAST);
}
+ return ctx;
}
-/**
- * Get the context of a peer. If not existing, create.
- */
- struct peer_context *
-get_peer_ctx (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct
GNUNET_PeerIdentity *peer)
-{
- struct peer_context *ctx;
- touch_peer_ctx(peer_map, peer);
- ctx = GNUNET_CONTAINER_multipeermap_get(peer_map, peer);
- return ctx;
-}
-
/**
* Get the channel of a peer. If not existing, create.
*/
- void
-touch_channel (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct
GNUNET_PeerIdentity *peer)
+ struct GNUNET_CADET_Channel *
+get_channel (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct
GNUNET_PeerIdentity *peer)
{
struct peer_context *ctx;
ctx = get_peer_ctx (peer_map, peer);
if (NULL == ctx->to_channel)
{
- ctx->to_channel = GNUNET_CADET_channel_create(cadet_handle, NULL, peer,
- GNUNET_RPS_CADET_PORT,
-
GNUNET_CADET_OPTION_RELIABLE);
+ ctx->to_channel = GNUNET_CADET_channel_create (cadet_handle, NULL, peer,
+ GNUNET_RPS_CADET_PORT,
+
GNUNET_CADET_OPTION_RELIABLE);
// do I have to explicitly put it in the peer_map?
- GNUNET_CONTAINER_multipeermap_put(peer_map, peer, ctx,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
+ GNUNET_CONTAINER_multipeermap_put (peer_map, peer, ctx,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
}
+ return ctx->to_channel;
}
-/**
- * Get the channel of a peer. If not existing, create.
- */
- struct GNUNET_CADET_Channel *
-get_channel (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct
GNUNET_PeerIdentity *peer)
-{
- struct peer_context *ctx;
- ctx = get_peer_ctx (peer_map, peer);
- touch_channel(peer_map, peer);
- return ctx->to_channel;
-}
-
/**
- * Make sure the mq for a given peer exists.
+ * Get the message queue of a specific peer.
*
* If we already have a message queue open to this client,
* simply return it, otherways create one.
*/
- void
-touch_mq (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct
GNUNET_PeerIdentity *peer_id)
+ struct GNUNET_MQ_Handle *
+get_mq (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct
GNUNET_PeerIdentity *peer_id)
{
struct peer_context *ctx;
- ctx = get_peer_ctx(peer_map, peer_id);
+ ctx = get_peer_ctx (peer_map, peer_id);
if (NULL == ctx->mq)
{
- touch_channel(peer_map, peer_id);
- ctx->mq = GNUNET_CADET_mq_create(ctx->to_channel);
+ (void) get_channel (peer_map, peer_id);
+ ctx->mq = GNUNET_CADET_mq_create (ctx->to_channel);
//do I have to explicitly put it in the peer_map?
- GNUNET_CONTAINER_multipeermap_put(peer_map, peer_id, ctx,
-
GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
+ GNUNET_CONTAINER_multipeermap_put (peer_map, peer_id, ctx,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_REPLACE);
}
+ return ctx->mq;
}
-/**
- * Get the message queue of a specific peer.
- *
- * If we already have a message queue open to this client,
- * simply return it, otherways create one.
- */
- struct GNUNET_MQ_Handle *
-get_mq (struct GNUNET_CONTAINER_MultiPeerMap *peer_map, const struct
GNUNET_PeerIdentity *peer_id)
-{
- struct peer_context *ctx;
- ctx = get_peer_ctx(peer_map, peer_id);
- touch_mq(peer_map, peer_id);
-
- return ctx->mq;
-}
-
/***********************************************************************
* /Util functions
***********************************************************************/
@@ -797,7 +760,7 @@
insertCB (void *cls, const struct GNUNET_PeerIdentity *id)
{
// We open a channel to be notified when this peer goes down.
- touch_channel (peer_map, id);
+ (void) get_channel (peer_map, id);
}
/**
@@ -856,7 +819,7 @@
"Got %" PRIX32 ". peer %s (at %p) from CADET (gossip_list_size: %u)\n",
ipc->i, GNUNET_i2s (peer), peer, gossip_list_size);
RPS_sampler_update_list (peer);
- touch_peer_ctx (peer_map, peer); // unneeded? -> insertCB
+ (void) get_peer_ctx (peer_map, peer); // unneeded? -> insertCB
if (ipc->i < gossip_list_size)
{
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r34839 - gnunet/src/rps,
gnunet <=