From 01a6f7fa2652d6b5b23e10238e740b0aa39f7845 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 29 Nov 2012 14:24:13 +0000 Subject: [PATCH] -you are welcome --- src/consensus/Makefile.am | 1 + src/consensus/consensus.h | 4 +-- src/consensus/gnunet-consensus.c | 49 ++++++++++++++++++++++++++++++-- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/src/consensus/Makefile.am b/src/consensus/Makefile.am index 8d6a9aaff..10b22cc87 100644 --- a/src/consensus/Makefile.am +++ b/src/consensus/Makefile.am @@ -28,6 +28,7 @@ gnunet_consensus_SOURCES = \ gnunet-consensus.c gnunet_consensus_LDADD = \ $(top_builddir)/src/util/libgnunetutil.la \ + $(top_builddir)/src/consensus/libgnunetconsensus.la \ $(GN_LIBINTL) gnunet_service_consensus_SOURCES = \ diff --git a/src/consensus/consensus.h b/src/consensus/consensus.h index 3f1efe340..2762e8ff4 100644 --- a/src/consensus/consensus.h +++ b/src/consensus/consensus.h @@ -23,8 +23,8 @@ * @file consensus/consensus.h * @brief */ -#ifndef NSE_H -#define NSE_H +#ifndef CONSENSUS_H +#define CONSENSUS_H #include "gnunet_common.h" diff --git a/src/consensus/gnunet-consensus.c b/src/consensus/gnunet-consensus.c index b2b635059..ef067ea34 100644 --- a/src/consensus/gnunet-consensus.c +++ b/src/consensus/gnunet-consensus.c @@ -23,13 +23,58 @@ * @brief * @author Florian Dold */ +#include "platform.h" +#include "gnunet_util_lib.h" +#include "gnunet_consensus_service.h" -#include "gnunet_consensus_service.h" + + +/** + * Called when a new element was received from another peer, or an error occured. + * + * May deliver duplicate values. + * + * Elements given to a consensus operation by the local peer are NOT given + * to this callback. + * + * @param cls closure + * @param element new element, NULL on error + * @return GNUNET_OK if the valid is well-formed and should be added to the consensus, + * GNUNET_SYSERR if the element should be ignored and not be propagated + */ +static int +cb (void *cls, + struct GNUNET_CONSENSUS_Element *element) +{ + return 0; +} + + + +static void +run (void *cls, char *const *args, const char *cfgfile, + const struct GNUNET_CONFIGURATION_Handle *cfg) +{ + static struct GNUNET_PeerIdentity pid; + static struct GNUNET_HashCode sid; + + GNUNET_CONSENSUS_create (cfg, + 1, &pid, + &sid, + &cb, NULL); + +} int -main () +main (int argc, char **argv) { + static const struct GNUNET_GETOPT_CommandLineOption options[] = { + GNUNET_GETOPT_OPTION_END + }; + GNUNET_PROGRAM_run (argc, argv, "gnunet-consensus", + "help", + options, &run, NULL); return 0; } -- 2.25.1