Browse Source

Allow immediate quit of sendpayment if no offers

In case Taker.initialize() fails for any reason such as no
liquidity, stallMonitor() will not wake up for 20*maker_timeout_sec;
so, in this change, IF the client schedule has length one, we
immediately figure the on_finished_callback with failure parameters
so that the reactor is stopped without waiting.
This change does not apply for the general multi-step schedule, as
that is principally for tumbler-style algos which are intended to
aggressively keep trying in case of any failure.
master
Adam Gibson 9 years ago
parent
commit
f058a8368f
No known key found for this signature in database
GPG Key ID: B3AE09F1E9A3197A
  1. 5
      jmclient/jmclient/client_protocol.py
  2. 11
      jmclient/test/test_client_protocol.py

5
jmclient/jmclient/client_protocol.py

@ -385,6 +385,11 @@ class JMTakerClientProtocol(JMClientProtocol):
#True, self.cjamount, commitment, revelation, self.filtered_orderbook)
if not retval[0]:
jlog.info("Taker not continuing after receipt of orderbook")
if len(self.client.schedule) == 1:
#In single sendpayments, allow immediate quit.
#This could be an optional feature also for multi-entry schedules,
#but is not the functionality desired in general (tumbler).
self.client.on_finished_callback(False, True, 0.0)
return {'accepted': True}
amt, cmt, rev, foffers = retval[1:]
d = self.callRemote(commands.JMFill,

11
jmclient/test/test_client_protocol.py

@ -222,21 +222,24 @@ class TrialTestJMClientProto(unittest.TestCase):
self.client = client
self.addCleanup(self.client.transport.loseConnection)
clientfactories = []
takers = [DummyTaker(None, None, callbacks=(None, None, dummy_taker_finished)) for _ in range(len(params))]
takers = [DummyTaker(
None, ["a", "b"], callbacks=(
None, None, dummy_taker_finished)) for _ in range(len(params))]
for i, p in enumerate(params):
takers[i].set_fail_init(p[0])
takers[i].set_fail_utxos(p[1])
takers[i].testflag = True
if i != 0:
clientfactories.append(JMClientProtocolFactory(takers[i]))
clientconn = reactor.connectTCP("localhost", 27184, clientfactories[i])
clientconn = reactor.connectTCP("localhost", 27184,
clientfactories[i])
self.addCleanup(clientconn.disconnect)
else:
clientfactories.append(DummyClientProtocolFactory(takers[i]))
clientfactory = clientfactories[0]
clientconn = reactor.connectTCP("localhost", 27184, clientfactories[0])
clientconn = reactor.connectTCP("localhost", 27184,
clientfactories[0])
self.addCleanup(clientconn.disconnect)
print("Got here")
def test_waiter(self):
print("test_main()")

Loading…
Cancel
Save