1
0

reorganize with_lock decorator

This commit is contained in:
bitromortac
2021-03-22 08:25:26 +01:00
parent 92226b077a
commit 63308f94a0
4 changed files with 13 additions and 23 deletions

View File

@@ -3,7 +3,7 @@ from typing import Optional, Sequence, Tuple, List, Dict, TYPE_CHECKING, Set
import threading
from .lnutil import SENT, RECEIVED, LOCAL, REMOTE, HTLCOwner, UpdateAddHtlc, Direction, FeeUpdate
from .util import bh2u, bfh
from .util import bh2u, bfh, with_lock
if TYPE_CHECKING:
from .json_db import StoredDict
@@ -50,12 +50,6 @@ class HTLCManager:
self._init_maybe_active_htlc_ids()
def with_lock(func):
def func_wrapper(self, *args, **kwargs):
with self.lock:
return func(self, *args, **kwargs)
return func_wrapper
@with_lock
def ctn_latest(self, sub: HTLCOwner) -> int:
"""Return the ctn for the latest (newest that has a valid sig) ctx of sub"""