Browse Source

can run daemon in same process as client; added DAEMON section to cfg

master
Adam Gibson 9 years ago
parent
commit
47512a66db
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 14
      jmclient/jmclient/client_protocol.py
  2. 11
      jmclient/jmclient/configure.py
  3. 1
      jmdaemon/jmdaemon/irc.py
  4. 12
      scripts/sendpayment.py

14
jmclient/jmclient/client_protocol.py

@ -246,7 +246,19 @@ class JMTakerClientProtocolFactory(protocol.ClientFactory):
return JMTakerClientProtocol(self, self.taker) return JMTakerClientProtocol(self, self.taker)
def start_reactor(host, port, factory, ish=True): #pragma: no cover def start_reactor(host, port, factory, ish=True, daemon=False): #pragma: no cover
#(Cannot start the reactor in tests) #(Cannot start the reactor in tests)
if daemon:
try:
from jmdaemon import JMDaemonServerProtocolFactory
except ImportError:
jlog.error("Cannot start daemon without jmdaemon package; "
"either install it, and restart, or, if you want "
"to run the daemon separately, edit the DAEMON "
"section of the config. Quitting.")
return
dfactory = JMDaemonServerProtocolFactory()
reactor.listenTCP(port, dfactory)
reactor.connectTCP(host, port, factory) reactor.connectTCP(host, port, factory)
reactor.run(installSignalHandlers=ish) reactor.run(installSignalHandlers=ish)

11
jmclient/jmclient/configure.py

@ -89,6 +89,17 @@ required_options = {'BLOCKCHAIN': ['blockchain_source', 'network'],
defaultconfig = \ defaultconfig = \
""" """
[DAEMON]
#set to 1 to run the daemon service within this process;
#set to 0 if the daemon is run separately (using script joinmarketd.py)
no_daemon = 1
#port on which daemon serves; note that communication still
#occurs over this port even if no_daemon = 1
daemon_port = 27183
#currently, running the daemon on a remote host is
#*NOT* supported, so don't change this variable
daemon_host = localhost
[BLOCKCHAIN] [BLOCKCHAIN]
blockchain_source = blockr blockchain_source = blockr
#options: blockr, bitcoin-rpc, regtest #options: blockr, bitcoin-rpc, regtest

1
jmdaemon/jmdaemon/irc.py

@ -56,6 +56,7 @@ class TxIRCFactory(protocol.ClientFactory):
def clientConnectionLost(self, connector, reason): def clientConnectionLost(self, connector, reason):
log.info('IRC connection lost: ' + str(reason)) log.info('IRC connection lost: ' + str(reason))
if not self.wrapper.give_up: if not self.wrapper.give_up:
if reactor.running:
log.info('Attempting to reconnect...') log.info('Attempting to reconnect...')
reactor.callLater(self.wrapper.reconnect_interval, reactor.callLater(self.wrapper.reconnect_interval,
connector.connect()) connector.connect())

12
scripts/sendpayment.py

@ -122,12 +122,6 @@ def main():
dest='makercount', dest='makercount',
help='how many makers to coinjoin with, default random from 4 to 6', help='how many makers to coinjoin with, default random from 4 to 6',
default=random.randint(4, 6)) default=random.randint(4, 6))
parser.add_option('-p',
'--port',
type='int',
dest='daemonport',
help='port on which joinmarketd is running',
default='27183')
parser.add_option('-S', parser.add_option('-S',
'--schedule-file', '--schedule-file',
type='str', type='str',
@ -316,7 +310,11 @@ def main():
order_chooser=chooseOrdersFunc, order_chooser=chooseOrdersFunc,
callbacks=(filter_orders_callback, None, taker_finished)) callbacks=(filter_orders_callback, None, taker_finished))
clientfactory = JMTakerClientProtocolFactory(taker) clientfactory = JMTakerClientProtocolFactory(taker)
start_reactor("localhost", options.daemonport, clientfactory) nodaemon = jm_single().config.getint("DAEMON", "no_daemon")
daemon = True if nodaemon == 1 else False
start_reactor(jm_single().config.get("DAEMON", "daemon_host"),
jm_single().config.getint("DAEMON", "daemon_port"),
clientfactory, daemon=daemon)
if __name__ == "__main__": if __name__ == "__main__":
main() main()

Loading…
Cancel
Save