Browse Source
ln fees: avoid resending same fee update before it has been committed to, docs
regtest_lnd
Janus
6 years ago
committed by
SomberNight
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
2 changed files with
13 additions and
3 deletions
-
electrum/lnbase.py
-
electrum/lnhtlc.py
|
@ -1049,12 +1049,13 @@ class Peer(PrintError): |
|
|
return |
|
|
return |
|
|
|
|
|
|
|
|
feerate_per_kw = self.current_feerate_per_kw() |
|
|
feerate_per_kw = self.current_feerate_per_kw() |
|
|
self.print_error("current feerate", chan.remote_state.feerate) |
|
|
chan_fee = chan.pending_feerate(REMOTE) |
|
|
|
|
|
self.print_error("current pending feerate", chan_fee) |
|
|
self.print_error("new feerate", feerate_per_kw) |
|
|
self.print_error("new feerate", feerate_per_kw) |
|
|
if feerate_per_kw < chan.remote_state.feerate / 2: |
|
|
if feerate_per_kw < chan_fee / 2: |
|
|
self.print_error("FEES HAVE FALLEN") |
|
|
self.print_error("FEES HAVE FALLEN") |
|
|
chan.update_fee(feerate_per_kw) |
|
|
chan.update_fee(feerate_per_kw) |
|
|
elif feerate_per_kw > chan.remote_state.feerate * 2: |
|
|
elif feerate_per_kw > chan_fee * 2: |
|
|
self.print_error("FEES HAVE RISEN") |
|
|
self.print_error("FEES HAVE RISEN") |
|
|
chan.update_fee(feerate_per_kw) |
|
|
chan.update_fee(feerate_per_kw) |
|
|
else: |
|
|
else: |
|
|
|
@ -62,9 +62,17 @@ class FeeUpdate: |
|
|
self.progress[field] = self.height |
|
|
self.progress[field] = self.height |
|
|
|
|
|
|
|
|
def is_proposed(self): |
|
|
def is_proposed(self): |
|
|
|
|
|
""" |
|
|
|
|
|
returns True when this FeeUpdate has been proposed |
|
|
|
|
|
at or above the current commitment number of the funder |
|
|
|
|
|
""" |
|
|
return self.progress[COMMITTED] is None and self.proposed is not None and self.proposed <= self.height |
|
|
return self.progress[COMMITTED] is None and self.proposed is not None and self.proposed <= self.height |
|
|
|
|
|
|
|
|
def had(self, field): |
|
|
def had(self, field): |
|
|
|
|
|
""" |
|
|
|
|
|
returns true when the progress field given has been |
|
|
|
|
|
set at the current commitment number of the funder |
|
|
|
|
|
""" |
|
|
return self.progress[field] is not None and self.height >= self.progress[field] |
|
|
return self.progress[field] is not None and self.height >= self.progress[field] |
|
|
|
|
|
|
|
|
def pending_feerate(self, subject): |
|
|
def pending_feerate(self, subject): |
|
@ -76,6 +84,7 @@ class FeeUpdate: |
|
|
return self.rate |
|
|
return self.rate |
|
|
if subject == LOCAL and not self.chan.constraints.is_initiator: |
|
|
if subject == LOCAL and not self.chan.constraints.is_initiator: |
|
|
return self.rate |
|
|
return self.rate |
|
|
|
|
|
# implicit return None |
|
|
|
|
|
|
|
|
def to_save(self): |
|
|
def to_save(self): |
|
|
return {'rate': self.rate, 'proposed': self.proposed, 'progress': self.progress} |
|
|
return {'rate': self.rate, 'proposed': self.proposed, 'progress': self.progress} |
|
|