Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the disable in nodes policy for more accuracy in directed graph #26

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion lntopo/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ def __json__(self):
'fee_base_msat': self.fee_base_msat,
'fee_proportional_millionths': self.fee_proportional_millionths,
'htlc_maximum_msat': self.htlc_maximum_msat,
'disabled': bool(self.disable),
'chain_hash': hexlify(self.chain_hash).decode('ASCII'),
}

Expand All @@ -96,6 +97,11 @@ def direction(self):
(b,) = struct.unpack("!B", self.channel_flags)
return b & 0x01

@property
def disable(self):
(b,) = struct.unpack("!B", self.channel_flags)
return (b >> 1) & 0x01

def serialize(self):
raise ValueError()

Expand Down Expand Up @@ -286,6 +292,8 @@ def parse_address(b):
return a

# https://github.com/alexbosworth/bolt07/blob/519c94a7837e687bf7478a74779d5ea493a76a44/addresses/encode_base32.js


def to_base_32(addr):
alphabet = 'abcdefghijklmnopqrstuvwxyz234567'
byte = 8
Expand All @@ -305,9 +313,10 @@ def to_base_32(addr):

if bits > 0:
base32 += alphabet[(value << (word - bits)) & lastIndex]

return base32


def parse_node_announcement(b):
if not isinstance(b, io.BytesIO):
b = io.BytesIO(b)
Expand Down
6 changes: 4 additions & 2 deletions lntopo/timemachine.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def restore(dataset, timestamp=None, fmt='dot'):

"""
if timestamp is None:
timestamp = time.time()
timestamp = time.time()

cutoff = timestamp - 2 * 7 * 24 * 3600
channels = {}
Expand Down Expand Up @@ -84,6 +84,7 @@ def restore(dataset, timestamp=None, fmt='dot'):
if m.htlc_maximum_msat:
chan["htlc_maximum_msat"] = m.htlc_maximum_msat
chan["cltv_expiry_delta"] = m.cltv_expiry_delta
chan["disabled"] = m.disable
elif isinstance(m, NodeAnnouncement):
node_id = m.node_id.hex()

Expand Down Expand Up @@ -123,7 +124,8 @@ def restore(dataset, timestamp=None, fmt='dot'):
for scid in todelete:
del channels[scid]

nodes = [n for n in nodes.values() if n["in_degree"] > 0 or n['out_degree'] > 0]
nodes = [n for n in nodes.values() if n["in_degree"] >
0 or n['out_degree'] > 0]

if len(channels) == 0:
print(
Expand Down