Browse Source

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.
master
Adam Gibson 9 years ago
parent
commit
79cd916f58
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 3
      jmclient/jmclient/client_protocol.py
  2. 45
      jmdaemon/jmdaemon/irc.py
  3. 7
      scripts/sendpayment.py

3
jmclient/jmclient/client_protocol.py

@ -194,7 +194,8 @@ class JMTakerClientProtocol(amp.AMP):
@commands.JMOffers.responder @commands.JMOffers.responder
def on_JM_OFFERS(self, orderbook): def on_JM_OFFERS(self, orderbook):
self.orderbook = json.loads(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) retval = self.taker.initialize(self.orderbook)
#format of retval is: #format of retval is:
#True, self.cjamount, commitment, revelation, self.filtered_orderbook) #True, self.cjamount, commitment, revelation, self.filtered_orderbook)

45
jmdaemon/jmdaemon/irc.py

@ -157,8 +157,7 @@ class IRCMessageChannel(MessageChannel):
class txIRC_Client(irc.IRCClient, object): class txIRC_Client(irc.IRCClient, object):
""" """
lineRate is a class variable in the superclass used to limit lineRate is a class variable in the superclass used to limit
messages / second. heartbeat is what you'd think messages / second. heartbeat is what you'd think.
TODO check this handles throttling as necessary, should do.
""" """
lineRate = 0.5 lineRate = 0.5
heartbeatinterval = 60 heartbeatinterval = 60
@ -295,7 +294,8 @@ class txIRC_Client(irc.IRCClient, object):
wlog('unable to parse privmsg, msg: ', message) wlog('unable to parse privmsg, msg: ', message)
def action(self, user, channel, msg): def action(self, user, channel, msg):
wlog('unhandled action: ', user, channel, msg) pass
#wlog('unhandled action: ', user, channel, msg)
def alterCollidedNick(self, nickname): def alterCollidedNick(self, nickname):
""" """
@ -308,21 +308,24 @@ class txIRC_Client(irc.IRCClient, object):
return newnick return newnick
def modeChanged(self, user, channel, _set, modes, args): 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): def pong(self, user, secs):
wlog('pong: ', user, secs) pass
#wlog('pong: ', user, secs)
def userJoined(self, user, channel): def userJoined(self, user, channel):
wlog('user joined: ', user, channel) pass
#wlog('user joined: ', user, channel)
def userKicked(self, kickee, channel, kicker, message): 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: if self.wrapper.on_nick_leave:
reactor.callLater(0.0, self.wrapper.on_nick_leave, kickee, self.wrapper) reactor.callLater(0.0, self.wrapper.on_nick_leave, kickee, self.wrapper)
def userLeft(self, user, channel): def userLeft(self, user, channel):
wlog('left: ', user, channel) #wlog('left: ', user, channel)
if self.wrapper.on_nick_leave: if self.wrapper.on_nick_leave:
reactor.callLater(0.0, self.wrapper.on_nick_leave, user, self.wrapper) 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 #TODO nick change handling
def userQuit(self, user, quitMessage): def userQuit(self, user, quitMessage):
wlog('userQuit: ', user, quitMessage) #wlog('userQuit: ', user, quitMessage)
if self.wrapper.on_nick_leave: if self.wrapper.on_nick_leave:
reactor.callLater(0.0, self.wrapper.on_nick_leave, user, self.wrapper) 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) reactor.callLater(0.0, self.wrapper.on_set_topic, newTopic)
def receivedMOTD(self, motd): def receivedMOTD(self, motd):
wlog('motd: ', motd) pass
#wlog('motd: ', motd)
def created(self, when): def created(self, when):
wlog('(unhandled) created: ', when) pass
#wlog('(unhandled) created: ', when)
def yourHost(self, info): def yourHost(self, info):
wlog('(unhandled) yourhost: ', info) pass
#wlog('(unhandled) yourhost: ', info)
def isupport(self, options): def isupport(self, options):
"""Used to set the name of the IRC *network* """Used to set the name of the IRC *network*
@ -363,19 +369,24 @@ class txIRC_Client(irc.IRCClient, object):
if k == 'NETWORK': if k == 'NETWORK':
self.wrapper.hostid = v self.wrapper.hostid = v
except Exception as e: 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): 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): def luserChannels(self, channels):
wlog('(unhandled) luserChannels: ', channels) pass
#wlog('(unhandled) luserChannels: ', channels)
def bounce(self, info): def bounce(self, info):
wlog('(unhandled) bounce: ', info) pass
#wlog('(unhandled) bounce: ', info)
def left(self, channel): def left(self, channel):
wlog('(unhandled) left: ', channel) pass
#wlog('(unhandled) left: ', channel)
def noticed(self, user, channel, message): def noticed(self, user, channel, message):
wlog('(unhandled) noticed: ', user, channel, message) wlog('(unhandled) noticed: ', user, channel, message)

7
scripts/sendpayment.py

@ -193,6 +193,11 @@ def main():
return True return True
def taker_finished(res, fromtx=False, waittime=0.0, txdetails=None): 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 fromtx:
if res: if res:
txd, txid = txdetails txd, txid = txdetails
@ -206,6 +211,8 @@ def main():
else: else:
if not res: if not res:
log.info("Did not complete successfully, shutting down") 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: else:
log.info("All transactions completed correctly") log.info("All transactions completed correctly")
reactor.stop() reactor.stop()

Loading…
Cancel
Save