Printing RpcErrors and UpdateFailures

This commit is contained in:
feelancer21 2024-06-08 00:54:46 +02:00
parent 69d721fadd
commit ce993d4122
No known key found for this signature in database
GPG key ID: 1F7071EE8449729C
2 changed files with 25 additions and 3 deletions

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python3
import argparse
import grpc
import sys
import os
@ -135,7 +136,13 @@ def main():
)
if is_changed and not arguments.dry_run:
lnd.update_chan_policy(channel.chan_id, chp)
try:
res = lnd.update_chan_policy(channel.chan_id, chp)
for f in res.failed_updates:
print(" failure_reason: %s" % fmt.col_err(lnd.update_failure_name(f.reason)) )
print(" update_error: %s" % fmt.col_err(f.update_error) )
except grpc.RpcError as rpc_err:
print_rpc_error(rpc_err)
if is_changed or chan_status_changed or arguments.verbose:
print(" policy: %s" % fmt.col_hi(policy.name) )
@ -266,9 +273,20 @@ def update_circuitbreaker(cb: Circuitbreaker, lnd: Lnd, arguments):
# Eventually, we are updating the circuitbreaker backend.
if not arguments.dry_run:
cb.clear_limits(clear_limits)
cb.update_limits(update_limits)
try:
cb.clear_limits(clear_limits)
except grpc.RpcError as rpc_err:
print_rpc_error(rpc_err)
try:
cb.update_limits(update_limits)
except grpc.RpcError as rpc_err:
print_rpc_error(rpc_err)
def print_rpc_error(rpc_err):
if rpc_err:
print(" rpc_error_status: %s" % fmt.col_err(rpc_err.code()) )
print(" rpc_error_details: %s" % fmt.col_err(rpc_err.details()) )
def get_argument_parser():
parser = argparse.ArgumentParser()

View file

@ -268,6 +268,10 @@ class Lnd:
return None
return self.chan_info[chanid]
@staticmethod
def update_failure_name(code):
return ln.UpdateFailure.Name(code)
def update_chan_policy(self, chanid, chp: ChanParams):
chan_info = self.get_chan_info(chanid)
if not chan_info: