1
0

pass blacklist to lnrouter.find_route, so that lnrouter is stateless (see #6778)

This commit is contained in:
ThomasV
2021-01-11 15:19:50 +01:00
parent 9d7a317404
commit ad91257729
5 changed files with 36 additions and 28 deletions

View File

@@ -8,7 +8,7 @@ import json
from collections import namedtuple, defaultdict
from typing import NamedTuple, List, Tuple, Mapping, Optional, TYPE_CHECKING, Union, Dict, Set, Sequence
import re
import time
import attr
from aiorpcx import NetAddress
@@ -1313,3 +1313,17 @@ class OnionFailureCodeMetaFlag(IntFlag):
NODE = 0x2000
UPDATE = 0x1000
class ChannelBlackList:
def __init__(self):
self.blacklist = dict() # short_chan_id -> timestamp
def add(self, short_channel_id: ShortChannelID):
now = int(time.time())
self.blacklist[short_channel_id] = now
def get_current_list(self) -> Set[ShortChannelID]:
BLACKLIST_DURATION = 3600
now = int(time.time())
return set(k for k, t in self.blacklist.items() if now - t < BLACKLIST_DURATION)