electrum

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

commit ff485cee62d33c5f6f95a425839026fa8872cd02
parent 859f8ccf8e5c784d9c2e307f5ff4f8cc293ee27d
Author: SomberNight <somber.night@protonmail.com>
Date:   Thu,  4 Mar 2021 16:44:13 +0100

use functools.wraps() for some wrappers

to help debugging

Diffstat:
Melectrum/interface.py | 9+++++++--
Melectrum/lnpeer.py | 3+++
Melectrum/util.py | 3+++
3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/electrum/interface.py b/electrum/interface.py @@ -35,6 +35,7 @@ from ipaddress import IPv4Network, IPv6Network, ip_address, IPv6Address, IPv4Add import itertools import logging import hashlib +import functools import aiorpcx from aiorpcx import TaskGroup @@ -375,10 +376,13 @@ class Interface(Logger): # Dump network messages (only for this interface). Set at runtime from the console. self.debug = False - asyncio.run_coroutine_threadsafe( - self.network.taskgroup.spawn(self.run()), self.network.asyncio_loop) self.taskgroup = SilentTaskGroup() + async def spawn_task(): + task = await self.network.taskgroup.spawn(self.run()) + task.set_name(f"interface::{str(server)}") + asyncio.run_coroutine_threadsafe(spawn_task(), self.network.asyncio_loop) + @property def host(self): return self.server.host @@ -476,6 +480,7 @@ class Interface(Logger): return sslc def handle_disconnect(func): + @functools.wraps(func) async def wrapper_func(self: 'Interface', *args, **kwargs): try: return await func(self, *args, **kwargs) diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py @@ -11,6 +11,7 @@ import os import time from typing import Tuple, Dict, TYPE_CHECKING, Optional, Union from datetime import datetime +import functools import aiorpcx @@ -289,6 +290,7 @@ class Peer(Logger): self.announcement_signatures[chan.channel_id].put_nowait(payload) def handle_disconnect(func): + @functools.wraps(func) async def wrapper_func(self, *args, **kwargs): try: return await func(self, *args, **kwargs) @@ -550,6 +552,7 @@ class Peer(Logger): # During the channel open flow, if we initiated, we might have used a change address # of ours in the funding tx. The funding tx is not part of the wallet history # at that point yet, but we should already consider this change address as 'used'. + @functools.wraps(func) async def wrapper(self: 'Peer', *args, **kwargs): funding_tx = kwargs['funding_tx'] # type: PartialTransaction wallet = self.lnworker.wallet diff --git a/electrum/util.py b/electrum/util.py @@ -45,6 +45,7 @@ import ipaddress from ipaddress import IPv4Address, IPv6Address import random import secrets +import functools import attr import aiohttp @@ -1086,6 +1087,7 @@ def make_dir(path, allow_symlink=True): def log_exceptions(func): """Decorator to log AND re-raise exceptions.""" assert asyncio.iscoroutinefunction(func), 'func needs to be a coroutine' + @functools.wraps(func) async def wrapper(*args, **kwargs): self = args[0] if len(args) > 0 else None try: @@ -1105,6 +1107,7 @@ def log_exceptions(func): def ignore_exceptions(func): """Decorator to silently swallow all exceptions.""" assert asyncio.iscoroutinefunction(func), 'func needs to be a coroutine' + @functools.wraps(func) async def wrapper(*args, **kwargs): try: return await func(*args, **kwargs)