Browse Source

Add notifier tool to be used with blocknotify from bitcoind

master
Con Kolivas 10 years ago
parent
commit
acf8f7c032
  1. 5
      src/Makefile.am
  2. 63
      src/notifier.c

5
src/Makefile.am

@ -7,7 +7,7 @@ lib_LTLIBRARIES = libckpool.la
libckpool_la_SOURCES = libckpool.c libckpool.h sha2.c sha2.h libckpool_la_SOURCES = libckpool.c libckpool.h sha2.c sha2.h
libckpool_la_LIBADD = @PTHREAD_LIBS@ @MATH_LIBS@ @RT_LIBS@ libckpool_la_LIBADD = @PTHREAD_LIBS@ @MATH_LIBS@ @RT_LIBS@
bin_PROGRAMS = ckpool ckpmsg bin_PROGRAMS = ckpool ckpmsg notifier
ckpool_SOURCES = ckpool.c ckpool.h generator.c generator.h bitcoin.c bitcoin.h \ ckpool_SOURCES = ckpool.c ckpool.h generator.c generator.h bitcoin.c bitcoin.h \
stratifier.c stratifier.h connector.c connector.h uthash.h \ stratifier.c stratifier.h connector.c connector.h uthash.h \
utlist.h utlist.h
@ -16,6 +16,9 @@ ckpool_LDADD = libckpool.la @JANSSON_LIBS@
ckpmsg_SOURCES = ckpmsg.c ckpmsg_SOURCES = ckpmsg.c
ckpmsg_LDADD = libckpool.la @JANSSON_LIBS@ ckpmsg_LDADD = libckpool.la @JANSSON_LIBS@
notifier_SOURCES = notifier.c
notifier_LDADD = libckpool.la @JANSSON_LIBS@
if WANT_CKDB if WANT_CKDB
bin_PROGRAMS += ckdb bin_PROGRAMS += ckdb
ckdb_SOURCES = ckdb.c klist.c ktree.c klist.h ktree.h ckdb_SOURCES = ckdb.c klist.c ktree.c klist.h ktree.h

63
src/notifier.c

@ -0,0 +1,63 @@
/*
* Copyright 2014 Con Kolivas
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 3 of the License, or (at your option)
* any later version. See COPYING for more details.
*/
#include "config.h"
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "libckpool.h"
int main(int argc, char **argv)
{
char *name = NULL, *socket_dir = NULL;
bool proxy = false;
int c, sockd;
while ((c = getopt(argc, argv, "n:s:p")) != -1) {
switch(c) {
case 'n':
name = strdup(optarg);
break;
case 's':
socket_dir = strdup(optarg);
break;
case 'p':
proxy = true;
break;
}
}
if (!socket_dir)
socket_dir = strdup("/tmp");
trail_slash(&socket_dir);
if (!name) {
if (proxy)
name = strdup("ckproxy");
else
name = strdup("ckpool");
}
realloc_strcat(&socket_dir, name);
dealloc(name);
trail_slash(&socket_dir);
realloc_strcat(&socket_dir, "stratifier");
sockd = open_unix_client(socket_dir);
if (sockd < 0) {
LOGERR("Failed to open socket: %s", socket_dir);
exit(1);
}
if (!send_unix_msg(sockd, "update")) {
LOGERR("Failed to send stratifier update msg");
exit(1);
}
LOGNOTICE("Notified stratifier of block update");
exit(0);
}
Loading…
Cancel
Save