electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 8389892dbd8f98d397780286af2e55f56376a7f5
parent 9ac41be1e8822acc32b60cc04dbe891c90caacd0
Author: SomberNight <somber.night@protonmail.com>
Date:   Fri,  1 May 2020 03:43:12 +0200

lnpeer: (trivial) log name for chan.state and chan.peer_state

IntEnum.__format__ just returns an int:

>>> from enum import IntEnum
>>> class Colours(IntEnum):
...   red = 1
...   blue = 2
...
>>> var = Colours.red
>>> f"{var}"
'1'
>>> f"{var!s}"
'Colours.red'
>>> f"{var!r}"
'<Colours.red: 1>'

Diffstat:
Melectrum/lnpeer.py | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py @@ -750,7 +750,7 @@ class Peer(Logger): assert ChannelState.PREOPENING < chan.get_state() < ChannelState.FORCE_CLOSING if chan.peer_state != PeerState.DISCONNECTED: self.logger.info(f'reestablish_channel was called but channel {chan.get_id_for_log()} ' - f'already in peer_state {chan.peer_state}') + f'already in peer_state {chan.peer_state!r}') return chan.peer_state = PeerState.REESTABLISHING util.trigger_callback('channel', chan) @@ -1126,7 +1126,7 @@ class Peer(Logger): amount_msat_htlc = payload["amount_msat"] onion_packet = payload["onion_routing_packet"] if chan.get_state() != ChannelState.OPEN: - raise RemoteMisbehaving(f"received update_add_htlc while chan.get_state() != OPEN. state was {chan.get_state()}") + raise RemoteMisbehaving(f"received update_add_htlc while chan.get_state() != OPEN. state was {chan.get_state()!r}") if cltv_expiry > bitcoin.NLOCKTIME_BLOCKHEIGHT_MAX: asyncio.ensure_future(self.lnworker.try_force_closing(chan.channel_id)) raise RemoteMisbehaving(f"received update_add_htlc with cltv_expiry > BLOCKHEIGHT_MAX. value was {cltv_expiry}") @@ -1164,7 +1164,7 @@ class Peer(Logger): outgoing_chan_upd_len = len(outgoing_chan_upd).to_bytes(2, byteorder="big") if not next_chan.can_send_update_add_htlc(): self.logger.info(f"cannot forward htlc. next_chan {next_chan_scid} cannot send ctx updates. " - f"chan state {next_chan.get_state()}, peer state: {next_chan.peer_state}") + f"chan state {next_chan.get_state()!r}, peer state: {next_chan.peer_state!r}") data = outgoing_chan_upd_len + outgoing_chan_upd return OnionRoutingFailureMessage(code=OnionFailureCode.TEMPORARY_CHANNEL_FAILURE, data=data) try: