mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
channel: is_closed
This commit is contained in:
parent
f6f5cbee72
commit
ae402303ca
2 changed files with 5 additions and 2 deletions
|
@ -207,6 +207,9 @@ class Channel(PrintError):
|
|||
def get_state(self):
|
||||
return self._state
|
||||
|
||||
def is_closed(self):
|
||||
return self.get_state() in ['CLOSED', 'FORCE_CLOSING']
|
||||
|
||||
def _check_can_pay(self, amount_msat: int) -> None:
|
||||
if self.get_state() != 'OPEN':
|
||||
raise PaymentFailure('Channel not open')
|
||||
|
|
|
@ -180,7 +180,7 @@ class LNWorker(PrintError):
|
|||
for node_id, peer in self.peers.items():
|
||||
if not peer.initialized.is_set():
|
||||
continue
|
||||
if not all([chan.get_state() in ['CLOSED'] for chan in peer.channels.values()]):
|
||||
if not all([chan.is_closed() for chan in peer.channels.values()]):
|
||||
continue
|
||||
return node_id
|
||||
|
||||
|
@ -574,7 +574,7 @@ class LNWorker(PrintError):
|
|||
|
||||
def get_balance(self):
|
||||
with self.lock:
|
||||
return Decimal(sum(chan.balance(LOCAL) if chan.get_state() not in ['CLOSED', 'FORCE_CLOSING'] else 0 for chan in self.channels.values()))/1000
|
||||
return Decimal(sum(chan.balance(LOCAL) if not chan.is_closed() else 0 for chan in self.channels.values()))/1000
|
||||
|
||||
def list_channels(self):
|
||||
with self.lock:
|
||||
|
|
Loading…
Add table
Reference in a new issue