mirror of
https://github.com/aljazceru/plugins.git
synced 2025-12-21 23:24:19 +01:00
probe: Actually add a sensible return value to the probe method
It was returning `null` and we'd have to check the logs or the DB for the result. This makes it just a bit easier to see what happens. Signed-off-by: Christian Decker <decker.christian@gmail.com>
This commit is contained in:
@@ -68,6 +68,16 @@ class Probe(Base):
|
|||||||
started_at = Column(DateTime)
|
started_at = Column(DateTime)
|
||||||
finished_at = Column(DateTime)
|
finished_at = Column(DateTime)
|
||||||
|
|
||||||
|
def jsdict(self):
|
||||||
|
return {
|
||||||
|
'id': self.id,
|
||||||
|
'destination': self.destination,
|
||||||
|
'route': self.route,
|
||||||
|
'erring_channel': self.erring_channel,
|
||||||
|
'failcode': self.failcode,
|
||||||
|
'started_at': str(self.started_at),
|
||||||
|
'finished_at': str(self.finished_at),
|
||||||
|
}
|
||||||
|
|
||||||
def start_probe(plugin):
|
def start_probe(plugin):
|
||||||
t = threading.Thread(target=probe, args=[plugin])
|
t = threading.Thread(target=probe, args=[plugin])
|
||||||
@@ -77,6 +87,7 @@ def start_probe(plugin):
|
|||||||
|
|
||||||
@plugin.method('probe')
|
@plugin.method('probe')
|
||||||
def probe(plugin):
|
def probe(plugin):
|
||||||
|
res = None
|
||||||
nodes = plugin.rpc.listnodes()['nodes']
|
nodes = plugin.rpc.listnodes()['nodes']
|
||||||
dst = choice(nodes)
|
dst = choice(nodes)
|
||||||
|
|
||||||
@@ -94,8 +105,9 @@ def probe(plugin):
|
|||||||
p.payment_hash = ''.join(choice(string.hexdigits) for _ in range(64))
|
p.payment_hash = ''.join(choice(string.hexdigits) for _ in range(64))
|
||||||
except RpcError:
|
except RpcError:
|
||||||
p.failcode = -1
|
p.failcode = -1
|
||||||
|
res = p.jsdict()
|
||||||
s.commit()
|
s.commit()
|
||||||
return
|
return res
|
||||||
s.commit()
|
s.commit()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@@ -123,8 +135,10 @@ def probe(plugin):
|
|||||||
temporary_exclusions[exclusion] = expiry
|
temporary_exclusions[exclusion] = expiry
|
||||||
|
|
||||||
p.finished_at = datetime.now()
|
p.finished_at = datetime.now()
|
||||||
|
res = p.jsdict()
|
||||||
s.commit()
|
s.commit()
|
||||||
s.close()
|
s.close()
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
def clear_temporary_exclusion(plugin):
|
def clear_temporary_exclusion(plugin):
|
||||||
|
|||||||
Reference in New Issue
Block a user