From 451fd32170103921993d876d765a8755ce737a0b Mon Sep 17 00:00:00 2001 From: Gabor X Toth <*@tg-x.net> Date: Fri, 23 Sep 2016 14:26:55 +0000 Subject: [PATCH] multicast,psyc,social: remove core dependencny --- src/multicast/Makefile.am | 7 ++-- src/multicast/gnunet-service-multicast.c | 46 +++++++----------------- src/multicast/test_multicast.c | 23 +++--------- src/multicast/test_multicast_multipeer.c | 1 - src/psyc/Makefile.am | 1 - src/psyc/test_psyc.c | 32 +++++------------ src/social/Makefile.am | 3 -- src/social/gnunet-service-social.c | 19 +--------- src/social/gnunet-social.c | 22 ++---------- src/social/test_social.c | 31 ++++------------ 10 files changed, 36 insertions(+), 149 deletions(-) diff --git a/src/multicast/Makefile.am b/src/multicast/Makefile.am index 64c0bfe1d..b1f422765 100644 --- a/src/multicast/Makefile.am +++ b/src/multicast/Makefile.am @@ -45,7 +45,6 @@ gnunet_service_multicast_SOURCES = \ gnunet-service-multicast.c gnunet_service_multicast_LDADD = \ $(top_builddir)/src/util/libgnunetutil.la \ - $(top_builddir)/src/core/libgnunetcore.la \ $(top_builddir)/src/cadet/libgnunetcadet.la \ $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(GN_LIBINTL) @@ -65,13 +64,11 @@ test_multicast_SOURCES = \ test_multicast_LDADD = \ libgnunetmulticast.la \ $(top_builddir)/src/testing/libgnunettesting.la \ - $(top_builddir)/src/util/libgnunetutil.la \ - $(top_builddir)/src/core/libgnunetcore.la + $(top_builddir)/src/util/libgnunetutil.la test_multicast_multipeer_SOURCE = \ test_multicast_multipeer.c test_multicast_multipeer_LDADD = \ libgnunetmulticast.la \ $(top_builddir)/src/testbed/libgnunettestbed.la \ - $(top_builddir)/src/util/libgnunetutil.la \ - $(top_builddir)/src/core/libgnunetcore.la + $(top_builddir)/src/util/libgnunetutil.la diff --git a/src/multicast/gnunet-service-multicast.c b/src/multicast/gnunet-service-multicast.c index af530e27a..5f8b1cdb6 100644 --- a/src/multicast/gnunet-service-multicast.c +++ b/src/multicast/gnunet-service-multicast.c @@ -28,7 +28,6 @@ #include "gnunet_signatures.h" #include "gnunet_applications.h" #include "gnunet_statistics_service.h" -#include "gnunet_core_service.h" #include "gnunet_cadet_service.h" #include "gnunet_multicast_service.h" #include "multicast.h" @@ -43,12 +42,6 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; */ static struct GNUNET_SERVER_Handle *server; -/** - * Core handle. - * Only used during initialization. - */ -static struct GNUNET_CORE_Handle *core; - /** * CADET handle. */ @@ -341,11 +334,6 @@ struct ReplayRequestKey static void shutdown_task (void *cls) { - if (NULL != core) - { - GNUNET_CORE_disconnecT (core); - core = NULL; - } if (NULL != cadet) { GNUNET_CADET_disconnect (cadet); @@ -1846,12 +1834,21 @@ static const struct GNUNET_CADET_MessageHandler cadet_handlers[] = { /** - * Connected to core service. + * Service started. + * + * @param cls closure + * @param server the initialized server + * @param cfg configuration to use */ static void -core_connected_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity) +run (void *cls, + struct GNUNET_SERVER_Handle *srv, + const struct GNUNET_CONFIGURATION_Handle *c) { - this_peer = *my_identity; + cfg = c; + server = srv; + GNUNET_SERVER_connect_notify (server, &client_notify_connect, NULL); + GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer); stats = GNUNET_STATISTICS_create ("multicast", cfg); origins = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); @@ -1876,25 +1873,6 @@ core_connected_cb (void *cls, const struct GNUNET_PeerIdentity *my_identity) } -/** - * Service started. - * - * @param cls closure - * @param server the initialized server - * @param cfg configuration to use - */ -static void -run (void *cls, - struct GNUNET_SERVER_Handle *srv, - const struct GNUNET_CONFIGURATION_Handle *c) -{ - cfg = c; - server = srv; - GNUNET_SERVER_connect_notify (server, &client_notify_connect, NULL); - core = GNUNET_CORE_connecT (cfg, NULL, &core_connected_cb, NULL, NULL, NULL); -} - - /** * The main function for the multicast service. * diff --git a/src/multicast/test_multicast.c b/src/multicast/test_multicast.c index 44c62f677..1e3a4922b 100644 --- a/src/multicast/test_multicast.c +++ b/src/multicast/test_multicast.c @@ -31,7 +31,6 @@ #include "gnunet_common.h" #include "gnunet_util_lib.h" #include "gnunet_testing_lib.h" -#include "gnunet_core_service.h" #include "gnunet_multicast_service.h" #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) @@ -48,7 +47,6 @@ static struct GNUNET_SCHEDULER_Task * end_badly_task; static const struct GNUNET_CONFIGURATION_Handle *cfg; -struct GNUNET_CORE_Handle *core; struct GNUNET_PeerIdentity this_peer; struct GNUNET_MULTICAST_Origin *origin; @@ -110,11 +108,6 @@ member_join (int t); static void cleanup () { - if (NULL != core) - { - GNUNET_CORE_disconnecT (core); - core = NULL; - } if (NULL != member) { GNUNET_MULTICAST_member_part (member, NULL, NULL); @@ -705,16 +698,6 @@ origin_start () } -static void -core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) -{ - this_peer = *my_identity; - - // Test 1 starts here - origin_start (); -} - - /** * Main function of the test, run from scheduler. * @@ -737,8 +720,10 @@ run (void *cls, cfg = c; end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); - core = GNUNET_CORE_connecT (cfg, NULL, - &core_connected, NULL, NULL, NULL); + GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer); + + // Test 1 starts here + origin_start (); } diff --git a/src/multicast/test_multicast_multipeer.c b/src/multicast/test_multicast_multipeer.c index 2e8b9818d..3edf0153e 100644 --- a/src/multicast/test_multicast_multipeer.c +++ b/src/multicast/test_multicast_multipeer.c @@ -31,7 +31,6 @@ #include "gnunet_common.h" #include "gnunet_util_lib.h" #include "gnunet_testbed_service.h" -#include "gnunet_core_service.h" #include "gnunet_multicast_service.h" #define NUM_PEERS 2 diff --git a/src/psyc/Makefile.am b/src/psyc/Makefile.am index e00537e73..0016b1b3b 100644 --- a/src/psyc/Makefile.am +++ b/src/psyc/Makefile.am @@ -63,7 +63,6 @@ test_psyc_LDADD = \ libgnunetpsyc.la \ $(top_builddir)/src/psycutil/libgnunetpsycutil.la \ $(top_builddir)/src/testing/libgnunettesting.la \ - $(top_builddir)/src/core/libgnunetcore.la \ $(top_builddir)/src/util/libgnunetutil.la EXTRA_DIST = \ diff --git a/src/psyc/test_psyc.c b/src/psyc/test_psyc.c index d1846b8cc..03a1890b1 100644 --- a/src/psyc/test_psyc.c +++ b/src/psyc/test_psyc.c @@ -34,7 +34,6 @@ #include "gnunet_testing_lib.h" #include "gnunet_psyc_util_lib.h" #include "gnunet_psyc_service.h" -#include "gnunet_core_service.h" #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) @@ -45,7 +44,6 @@ static int res; static const struct GNUNET_CONFIGURATION_Handle *cfg; -static struct GNUNET_CORE_Handle *core; static struct GNUNET_PeerIdentity this_peer; /** @@ -143,11 +141,6 @@ slave_parted (void *cls) static void cleanup () { - if (NULL != core) - { - GNUNET_CORE_disconnecT (core); - core = NULL; - } if (NULL != slv) { GNUNET_PSYC_slave_part (slv, GNUNET_NO, &slave_parted, NULL); @@ -951,21 +944,6 @@ schedule_master_start (void *cls) } -static void -core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) -{ - this_peer = *my_identity; - -#if DEBUG_TEST_PSYC - master_start (); -#else - /* Allow some time for the services to initialize. */ - GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, - &schedule_master_start, NULL); -#endif - -} - /** * Main function of the test, run from scheduler. * @@ -986,13 +964,21 @@ run (void *cls, cfg = c; end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); + GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer); + channel_key = GNUNET_CRYPTO_eddsa_key_create (); slave_key = GNUNET_CRYPTO_ecdsa_key_create (); GNUNET_CRYPTO_eddsa_key_get_public (channel_key, &channel_pub_key); GNUNET_CRYPTO_ecdsa_key_get_public (slave_key, &slave_pub_key); - core = GNUNET_CORE_connecT (cfg, NULL, &core_connected, NULL, NULL, NULL); +#if DEBUG_TEST_PSYC + master_start (); +#else + /* Allow some time for the services to initialize. */ + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, + &schedule_master_start, NULL); +#endif } diff --git a/src/social/Makefile.am b/src/social/Makefile.am index fb761dcae..693a61411 100644 --- a/src/social/Makefile.am +++ b/src/social/Makefile.am @@ -41,7 +41,6 @@ gnunet_social_SOURCES = \ gnunet_social_LDADD = \ libgnunetsocial.la \ $(top_builddir)/src/psycutil/libgnunetpsycutil.la \ - $(top_builddir)/src/core/libgnunetcore.la \ $(top_builddir)/src/util/libgnunetutil.la gnunet_service_social_SOURCES = \ @@ -51,7 +50,6 @@ gnunet_service_social_LDADD = \ $(top_builddir)/src/statistics/libgnunetstatistics.la \ $(top_builddir)/src/psycutil/libgnunetpsycutil.la \ $(top_builddir)/src/psyc/libgnunetpsyc.la \ - $(top_builddir)/src/core/libgnunetcore.la \ $(top_builddir)/src/identity/libgnunetidentity.la \ $(top_builddir)/src/gns/libgnunetgns.la \ $(top_builddir)/src/namestore/libgnunetnamestore.la \ @@ -75,7 +73,6 @@ test_social_LDADD = \ $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/util/libgnunetutil.la \ $(top_builddir)/src/psycutil/libgnunetpsycutil.la \ - $(top_builddir)/src/core/libgnunetcore.la \ $(top_builddir)/src/identity/libgnunetidentity.la EXTRA_DIST = \ diff --git a/src/social/gnunet-service-social.c b/src/social/gnunet-service-social.c index 01a624e2a..681d469bc 100644 --- a/src/social/gnunet-service-social.c +++ b/src/social/gnunet-service-social.c @@ -31,7 +31,6 @@ #include "gnunet_util_lib.h" #include "gnunet_constants.h" #include "gnunet_protocols.h" -#include "gnunet_core_service.h" #include "gnunet_identity_service.h" #include "gnunet_namestore_service.h" #include "gnunet_gns_service.h" @@ -48,7 +47,6 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; /* Handles to other services */ -static struct GNUNET_CORE_Handle *core; static struct GNUNET_IDENTITY_Handle *id; static struct GNUNET_GNS_Handle *gns; static struct GNUNET_NAMESTORE_Handle *namestore; @@ -454,11 +452,6 @@ shutdown_task (void *cls) GNUNET_SERVER_notification_context_destroy (nc); nc = NULL; } - if (NULL != core) - { - GNUNET_CORE_disconnecT (core); - core = NULL; - } if (NULL != id) { GNUNET_IDENTITY_disconnect (id); @@ -3467,16 +3460,6 @@ identity_recv_ego (void *cls, struct GNUNET_IDENTITY_Ego *id_ego, } -/** - * Connected to core service. - */ -static void -core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) -{ - this_peer = *my_identity; -} - - /** * Initialize the PSYC service. * @@ -3489,6 +3472,7 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { cfg = c; + GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer); hosts = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); guests = GNUNET_CONTAINER_multihashmap_create (1, GNUNET_YES); @@ -3500,7 +3484,6 @@ run (void *cls, struct GNUNET_SERVER_Handle *server, apps_places = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); places_apps = GNUNET_CONTAINER_multihashmap_create(1, GNUNET_NO); - core = GNUNET_CORE_connecT (cfg, NULL, core_connected, NULL, NULL, NULL); id = GNUNET_IDENTITY_connect (cfg, &identity_recv_ego, NULL); gns = GNUNET_GNS_connect (cfg); namestore = GNUNET_NAMESTORE_connect (cfg); diff --git a/src/social/gnunet-social.c b/src/social/gnunet-social.c index 98a48c294..afd06028c 100644 --- a/src/social/gnunet-social.c +++ b/src/social/gnunet-social.c @@ -29,7 +29,6 @@ #include "platform.h" #include "gnunet_util_lib.h" #include "gnunet_social_service.h" -#include "gnunet_core_service.h" #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) @@ -139,7 +138,6 @@ struct GNUNET_SCHEDULER_Task *timeout_task; const struct GNUNET_CONFIGURATION_Handle *cfg; -struct GNUNET_CORE_Handle *core; struct GNUNET_PeerIdentity peer, this_peer; struct GNUNET_SOCIAL_App *app; @@ -1086,9 +1084,6 @@ app_recv_ego (void *cls, static void app_connect (void *cls) { - GNUNET_CORE_disconnecT (core); - core = NULL; - app = GNUNET_SOCIAL_app_connect (cfg, opt_app, app_recv_ego, app_recv_host, @@ -1098,20 +1093,6 @@ app_connect (void *cls) } -/* CORE */ - - -static void -core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) -{ - this_peer = *my_identity; - GNUNET_SCHEDULER_add_now (app_connect, NULL); -} - - -/* RUN */ - - /** * Main function run by the scheduler. * @@ -1125,6 +1106,7 @@ run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { cfg = c; + GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer); if (!opt_method) opt_method = "message"; @@ -1181,7 +1163,7 @@ run (void *cls, char *const *args, const char *cfgfile, } } - core = GNUNET_CORE_connecT (cfg, NULL, &core_connected, NULL, NULL, NULL); + GNUNET_SCHEDULER_add_now (app_connect, NULL); } diff --git a/src/social/test_social.c b/src/social/test_social.c index 4960b8820..0dc2a9d30 100644 --- a/src/social/test_social.c +++ b/src/social/test_social.c @@ -32,7 +32,6 @@ #include "gnunet_testing_lib.h" #include "gnunet_psyc_util_lib.h" #include "gnunet_social_service.h" -#include "gnunet_core_service.h" #include "gnunet_identity_service.h" #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 30) @@ -54,7 +53,6 @@ struct GNUNET_SCHEDULER_Task *end_badly_task; const struct GNUNET_CONFIGURATION_Handle *cfg; -struct GNUNET_CORE_Handle *core; struct GNUNET_PeerIdentity this_peer; struct GNUNET_IDENTITY_Handle *id; @@ -185,12 +183,6 @@ host_announce2 (); static void cleanup () { - if (NULL != core) - { - GNUNET_CORE_disconnecT (core); - core = NULL; - } - if (NULL != id) { GNUNET_IDENTITY_disconnect (id); @@ -406,11 +398,6 @@ app_connected (void *cls) { GNUNET_log (GNUNET_ERROR_TYPE_INFO, "Test #%u: App connected: %p\n", test, cls); - if (NULL != core) - { - GNUNET_CORE_disconnecT (core); - core = NULL; - } } @@ -1314,17 +1301,6 @@ identity_ego_cb (void *cls, struct GNUNET_IDENTITY_Ego *ego, } -static void -core_connected (void *cls, const struct GNUNET_PeerIdentity *my_identity) -{ - this_peer = *my_identity; - id = GNUNET_IDENTITY_connect (cfg, &identity_ego_cb, NULL); - - test = TEST_HOST_CREATE; - GNUNET_IDENTITY_create (id, host_name, &id_host_created, NULL); -} - - /** * Main function of the test, run from scheduler. * @@ -1346,7 +1322,12 @@ run (void *cls, end_badly_task = GNUNET_SCHEDULER_add_delayed (TIMEOUT, &end_badly, NULL); - core = GNUNET_CORE_connecT (cfg, NULL, &core_connected, NULL, NULL, NULL); + GNUNET_CRYPTO_get_peer_identity (cfg, &this_peer); + + id = GNUNET_IDENTITY_connect (cfg, &identity_ego_cb, NULL); + + test = TEST_HOST_CREATE; + GNUNET_IDENTITY_create (id, host_name, &id_host_created, NULL); } -- 2.25.1