lnhtlc: rename ctnheights -> ctn
This commit is contained in:
@@ -50,42 +50,35 @@ class HTLCManager:
|
|||||||
|
|
||||||
def send_ctx(self):
|
def send_ctx(self):
|
||||||
next_ctn = self.log[REMOTE]['ctn'] + 1
|
next_ctn = self.log[REMOTE]['ctn'] + 1
|
||||||
|
|
||||||
for locked_in in self.log[REMOTE]['locked_in'].values():
|
for locked_in in self.log[REMOTE]['locked_in'].values():
|
||||||
if locked_in[REMOTE] is None:
|
if locked_in[REMOTE] is None:
|
||||||
print("setting locked_in remote")
|
|
||||||
locked_in[REMOTE] = next_ctn
|
locked_in[REMOTE] = next_ctn
|
||||||
|
|
||||||
self.expect_sig[SENT] = False
|
self.expect_sig[SENT] = False
|
||||||
|
|
||||||
#return Sig(self.pending_htlcs(REMOTE), next_ctn)
|
|
||||||
|
|
||||||
def recv_ctx(self):
|
def recv_ctx(self):
|
||||||
next_ctn = self.log[LOCAL]['ctn'] + 1
|
next_ctn = self.log[LOCAL]['ctn'] + 1
|
||||||
|
|
||||||
for locked_in in self.log[LOCAL]['locked_in'].values():
|
for locked_in in self.log[LOCAL]['locked_in'].values():
|
||||||
if locked_in[LOCAL] is None:
|
if locked_in[LOCAL] is None:
|
||||||
locked_in[LOCAL] = next_ctn
|
locked_in[LOCAL] = next_ctn
|
||||||
|
|
||||||
self.expect_sig[RECEIVED] = False
|
self.expect_sig[RECEIVED] = False
|
||||||
|
|
||||||
def send_rev(self):
|
def send_rev(self):
|
||||||
self.log[LOCAL]['ctn'] += 1
|
self.log[LOCAL]['ctn'] += 1
|
||||||
for htlc_id, ctnheights in self.log[LOCAL]['settles'].items():
|
for htlc_id, ctns in self.log[LOCAL]['settles'].items():
|
||||||
if ctnheights[REMOTE] is None:
|
if ctns[REMOTE] is None:
|
||||||
ctnheights[REMOTE] = self.log[REMOTE]['ctn'] + 1
|
ctns[REMOTE] = self.log[REMOTE]['ctn'] + 1
|
||||||
|
|
||||||
def recv_rev(self):
|
def recv_rev(self):
|
||||||
self.log[REMOTE]['ctn'] += 1
|
self.log[REMOTE]['ctn'] += 1
|
||||||
did_set_htlc_height = False
|
did_set_htlc_height = False
|
||||||
for htlc_id, ctnheights in self.log[LOCAL]['locked_in'].items():
|
for htlc_id, ctns in self.log[LOCAL]['locked_in'].items():
|
||||||
if ctnheights[LOCAL] is None:
|
if ctns[LOCAL] is None:
|
||||||
did_set_htlc_height = True
|
did_set_htlc_height = True
|
||||||
assert ctnheights[REMOTE] == self.log[REMOTE]['ctn']
|
assert ctns[REMOTE] == self.log[REMOTE]['ctn']
|
||||||
ctnheights[LOCAL] = self.log[LOCAL]['ctn'] + 1
|
ctns[LOCAL] = self.log[LOCAL]['ctn'] + 1
|
||||||
for htlc_id, ctnheights in self.log[REMOTE]['settles'].items():
|
for htlc_id, ctns in self.log[REMOTE]['settles'].items():
|
||||||
if ctnheights[LOCAL] is None:
|
if ctns[LOCAL] is None:
|
||||||
ctnheights[LOCAL] = self.log[LOCAL]['ctn'] + 1
|
ctns[LOCAL] = self.log[LOCAL]['ctn'] + 1
|
||||||
return did_set_htlc_height
|
return did_set_htlc_height
|
||||||
|
|
||||||
def htlcs_by_direction(self, subject, direction, ctn=None):
|
def htlcs_by_direction(self, subject, direction, ctn=None):
|
||||||
@@ -103,11 +96,11 @@ class HTLCManager:
|
|||||||
party = LOCAL
|
party = LOCAL
|
||||||
else:
|
else:
|
||||||
party = REMOTE
|
party = REMOTE
|
||||||
for htlc_id, ctnheights in self.log[party]['locked_in'].items():
|
for htlc_id, ctns in self.log[party]['locked_in'].items():
|
||||||
htlc_height = ctnheights[subject]
|
htlc_height = ctns[subject]
|
||||||
if htlc_height is None:
|
if htlc_height is None:
|
||||||
expect_sig = self.expect_sig[RECEIVED if party != LOCAL else SENT]
|
expect_sig = self.expect_sig[RECEIVED if party != LOCAL else SENT]
|
||||||
include = not expect_sig and ctnheights[-subject] <= ctn
|
include = not expect_sig and ctns[-subject] <= ctn
|
||||||
else:
|
else:
|
||||||
include = htlc_height <= ctn
|
include = htlc_height <= ctn
|
||||||
if include:
|
if include:
|
||||||
@@ -148,8 +141,8 @@ class HTLCManager:
|
|||||||
if ctn is None:
|
if ctn is None:
|
||||||
ctn = self.log[subject]['ctn']
|
ctn = self.log[subject]['ctn']
|
||||||
d = []
|
d = []
|
||||||
for htlc_id, ctnheights in self.log[subject]['settles'].items():
|
for htlc_id, ctns in self.log[subject]['settles'].items():
|
||||||
if ctnheights[subject] <= ctn:
|
if ctns[subject] <= ctn:
|
||||||
d.append(self.log[subject]['adds'][htlc_id])
|
d.append(self.log[subject]['adds'][htlc_id])
|
||||||
return d
|
return d
|
||||||
|
|
||||||
@@ -164,13 +157,13 @@ class HTLCManager:
|
|||||||
|
|
||||||
def received_in_ctn(self, ctn):
|
def received_in_ctn(self, ctn):
|
||||||
return [self.log[REMOTE]['adds'][htlc_id]
|
return [self.log[REMOTE]['adds'][htlc_id]
|
||||||
for htlc_id, ctnheights in self.log[REMOTE]['settles'].items()
|
for htlc_id, ctns in self.log[REMOTE]['settles'].items()
|
||||||
if ctnheights[LOCAL] == ctn]
|
if ctns[LOCAL] == ctn]
|
||||||
|
|
||||||
def sent_in_ctn(self, ctn):
|
def sent_in_ctn(self, ctn):
|
||||||
return [self.log[LOCAL]['adds'][htlc_id]
|
return [self.log[LOCAL]['adds'][htlc_id]
|
||||||
for htlc_id, ctnheights in self.log[LOCAL]['settles'].items()
|
for htlc_id, ctns in self.log[LOCAL]['settles'].items()
|
||||||
if ctnheights[LOCAL] == ctn]
|
if ctns[LOCAL] == ctn]
|
||||||
|
|
||||||
def send_fail(self, htlc_id):
|
def send_fail(self, htlc_id):
|
||||||
self.log[REMOTE]['fails'][htlc_id] = self.log[REMOTE]['ctn'] + 1
|
self.log[REMOTE]['fails'][htlc_id] = self.log[REMOTE]['ctn'] + 1
|
||||||
|
|||||||
Reference in New Issue
Block a user