mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
lnhtlc: revert 0c4e7b856f8c96c4f0a33bf3e0d1c8fd8184bd36
This commit is contained in:
parent
5f164bcbe8
commit
a565c500f6
1 changed files with 10 additions and 2 deletions
|
@ -11,11 +11,15 @@ class HTLCManager:
|
|||
else:
|
||||
assert type(log) is dict
|
||||
log = {HTLCOwner(int(x)): y for x, y in deepcopy(log).items()}
|
||||
# log[sub]['ctn'] is the ctn for the oldest unrevoked ctx of sub
|
||||
for sub in (LOCAL, REMOTE):
|
||||
log[sub]['adds'] = {int(x): UpdateAddHtlc(*y) for x, y in log[sub]['adds'].items()}
|
||||
coerceHtlcOwner2IntMap = lambda x: {HTLCOwner(int(y)): z for y, z in x.items()}
|
||||
|
||||
# "side who offered htlc" -> action -> htlc_id -> whose ctx -> ctn
|
||||
log[sub]['locked_in'] = {int(x): coerceHtlcOwner2IntMap(y) for x, y in log[sub]['locked_in'].items()}
|
||||
log[sub]['settles'] = {int(x): coerceHtlcOwner2IntMap(y) for x, y in log[sub]['settles'].items()}
|
||||
# FIXME "fails" should be handled like "settles"
|
||||
log[sub]['fails'] = {int(x): y for x, y in log[sub]['fails'].items()}
|
||||
self.log = log
|
||||
|
||||
|
@ -159,10 +163,14 @@ class HTLCManager:
|
|||
return sent + received
|
||||
|
||||
def received_in_ctn(self, ctn):
|
||||
return [self.log[REMOTE]['adds'][htlc_id] for htlc_id, ctnheights in self.log[REMOTE]['settles'].items() if ctnheights[REMOTE] == ctn]
|
||||
return [self.log[REMOTE]['adds'][htlc_id]
|
||||
for htlc_id, ctnheights in self.log[REMOTE]['settles'].items()
|
||||
if ctnheights[LOCAL] == ctn]
|
||||
|
||||
def sent_in_ctn(self, ctn):
|
||||
return [self.log[LOCAL]['adds'][htlc_id] for htlc_id, ctnheights in self.log[LOCAL]['settles'].items() if ctnheights[LOCAL] == ctn]
|
||||
return [self.log[LOCAL]['adds'][htlc_id]
|
||||
for htlc_id, ctnheights in self.log[LOCAL]['settles'].items()
|
||||
if ctnheights[LOCAL] == ctn]
|
||||
|
||||
def send_fail(self, htlc_id):
|
||||
self.log[REMOTE]['fails'][htlc_id] = self.log[REMOTE]['ctn'] + 1
|
||||
|
|
Loading…
Add table
Reference in a new issue