1
0

persist nodes in channel_db on disk

This commit is contained in:
SomberNight
2018-07-26 21:08:25 +02:00
committed by ThomasV
parent 5a05a92b3d
commit bc06ded4b9
8 changed files with 204 additions and 54 deletions

View File

@@ -23,7 +23,7 @@
import binascii
import os, sys, re, json
from collections import defaultdict, OrderedDict
from typing import NamedTuple, Union, TYPE_CHECKING, Tuple, Optional, Callable, Any
from typing import NamedTuple, Union, TYPE_CHECKING, Tuple, Optional, Callable, Any, Sequence
from datetime import datetime
import decimal
from decimal import Decimal
@@ -40,6 +40,7 @@ import json
import time
from typing import NamedTuple, Optional
import ssl
import ipaddress
import aiohttp
from aiohttp_socks import SocksConnector, SocksVer
@@ -1156,3 +1157,20 @@ def multisig_type(wallet_type):
if match:
match = [int(x) for x in match.group(1, 2)]
return match
def is_ip_address(x: Union[str, bytes]) -> bool:
if isinstance(x, bytes):
x = x.decode("utf-8")
try:
ipaddress.ip_address(x)
return True
except ValueError:
return False
def list_enabled_bits(x: int) -> Sequence[int]:
"""e.g. 77 (0b1001101) --> (0, 2, 3, 6)"""
binary = bin(x)[2:]
rev_bin = reversed(binary)
return tuple(i for i, b in enumerate(rev_bin) if b == '1')