pass blacklist to lnrouter.find_route, so that lnrouter is stateless (see #6778)
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user