From 79cd916f58e7ad8640b861a4848d4f4a8958a484 Mon Sep 17 00:00:00 2001 From: Adam Gibson Date: Mon, 13 Feb 2017 15:39:45 +0200 Subject: [PATCH] Clean up log spam, finish on unconfirmed for sendpayment Removed the full orderbook printout from even debug log; far too big on mainnet. Also removed low level IRC logging, such as MOTD and quit messages, this can be revisited if needed. Sendpayment script should quit as soon as the final tx in the schedule is seen on the network; no value in waiting for confirmation. --- jmclient/jmclient/client_protocol.py | 3 +- jmdaemon/jmdaemon/irc.py | 45 +++++++++++++++++----------- scripts/sendpayment.py | 7 +++++ 3 files changed, 37 insertions(+), 18 deletions(-) diff --git a/jmclient/jmclient/client_protocol.py b/jmclient/jmclient/client_protocol.py index a183d52..8aad04f 100644 --- a/jmclient/jmclient/client_protocol.py +++ b/jmclient/jmclient/client_protocol.py @@ -194,7 +194,8 @@ class JMTakerClientProtocol(amp.AMP): @commands.JMOffers.responder def on_JM_OFFERS(self, orderbook): self.orderbook = json.loads(orderbook) - jlog.info("Got the orderbook: " + str(self.orderbook)) + #Removed for now, as judged too large, even for DEBUG: + #jlog.debug("Got the orderbook: " + str(self.orderbook)) retval = self.taker.initialize(self.orderbook) #format of retval is: #True, self.cjamount, commitment, revelation, self.filtered_orderbook) diff --git a/jmdaemon/jmdaemon/irc.py b/jmdaemon/jmdaemon/irc.py index 2cbcd75..94adc49 100644 --- a/jmdaemon/jmdaemon/irc.py +++ b/jmdaemon/jmdaemon/irc.py @@ -157,8 +157,7 @@ class IRCMessageChannel(MessageChannel): class txIRC_Client(irc.IRCClient, object): """ lineRate is a class variable in the superclass used to limit - messages / second. heartbeat is what you'd think - TODO check this handles throttling as necessary, should do. + messages / second. heartbeat is what you'd think. """ lineRate = 0.5 heartbeatinterval = 60 @@ -295,7 +294,8 @@ class txIRC_Client(irc.IRCClient, object): wlog('unable to parse privmsg, msg: ', message) def action(self, user, channel, msg): - wlog('unhandled action: ', user, channel, msg) + pass + #wlog('unhandled action: ', user, channel, msg) def alterCollidedNick(self, nickname): """ @@ -308,21 +308,24 @@ class txIRC_Client(irc.IRCClient, object): return newnick def modeChanged(self, user, channel, _set, modes, args): - wlog('(unhandled) modeChanged: ', user, channel, _set, modes, args) + pass + #wlog('(unhandled) modeChanged: ', user, channel, _set, modes, args) def pong(self, user, secs): - wlog('pong: ', user, secs) + pass + #wlog('pong: ', user, secs) def userJoined(self, user, channel): - wlog('user joined: ', user, channel) + pass + #wlog('user joined: ', user, channel) def userKicked(self, kickee, channel, kicker, message): - wlog('kicked: ', kickee, channel, kicker, message) + #wlog('kicked: ', kickee, channel, kicker, message) if self.wrapper.on_nick_leave: reactor.callLater(0.0, self.wrapper.on_nick_leave, kickee, self.wrapper) def userLeft(self, user, channel): - wlog('left: ', user, channel) + #wlog('left: ', user, channel) if self.wrapper.on_nick_leave: reactor.callLater(0.0, self.wrapper.on_nick_leave, user, self.wrapper) @@ -331,7 +334,7 @@ class txIRC_Client(irc.IRCClient, object): #TODO nick change handling def userQuit(self, user, quitMessage): - wlog('userQuit: ', user, quitMessage) + #wlog('userQuit: ', user, quitMessage) if self.wrapper.on_nick_leave: reactor.callLater(0.0, self.wrapper.on_nick_leave, user, self.wrapper) @@ -341,13 +344,16 @@ class txIRC_Client(irc.IRCClient, object): reactor.callLater(0.0, self.wrapper.on_set_topic, newTopic) def receivedMOTD(self, motd): - wlog('motd: ', motd) + pass + #wlog('motd: ', motd) def created(self, when): - wlog('(unhandled) created: ', when) + pass + #wlog('(unhandled) created: ', when) def yourHost(self, info): - wlog('(unhandled) yourhost: ', info) + pass + #wlog('(unhandled) yourhost: ', info) def isupport(self, options): """Used to set the name of the IRC *network* @@ -363,19 +369,24 @@ class txIRC_Client(irc.IRCClient, object): if k == 'NETWORK': self.wrapper.hostid = v except Exception as e: - wlog('failed to parse isupport option, ignoring') + pass + #wlog('failed to parse isupport option, ignoring') def myInfo(self, servername, version, umodes, cmodes): - wlog('(unhandled) myInfo: ', servername, version, umodes, cmodes) + pass + #wlog('(unhandled) myInfo: ', servername, version, umodes, cmodes) def luserChannels(self, channels): - wlog('(unhandled) luserChannels: ', channels) + pass + #wlog('(unhandled) luserChannels: ', channels) def bounce(self, info): - wlog('(unhandled) bounce: ', info) + pass + #wlog('(unhandled) bounce: ', info) def left(self, channel): - wlog('(unhandled) left: ', channel) + pass + #wlog('(unhandled) left: ', channel) def noticed(self, user, channel, message): wlog('(unhandled) noticed: ', user, channel, message) \ No newline at end of file diff --git a/scripts/sendpayment.py b/scripts/sendpayment.py index a295e40..8c5f66d 100644 --- a/scripts/sendpayment.py +++ b/scripts/sendpayment.py @@ -193,6 +193,11 @@ def main(): return True def taker_finished(res, fromtx=False, waittime=0.0, txdetails=None): + if fromtx == "unconfirmed": + #If final entry, stop *here*, don't wait for confirmation + if taker.schedule_index + 1 == len(taker.schedule): + reactor.stop() + return if fromtx: if res: txd, txid = txdetails @@ -206,6 +211,8 @@ def main(): else: if not res: log.info("Did not complete successfully, shutting down") + #Should usually be unreachable, unless conf received out of order; + #because we should stop on 'unconfirmed' for last (see above) else: log.info("All transactions completed correctly") reactor.stop()