mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-31 01:11:35 +00:00
ln fees: avoid resending same fee update before it has been committed to, docs
This commit is contained in:
parent
277ad65ba1
commit
308eacbdc3
2 changed files with 13 additions and 3 deletions
|
@ -1049,12 +1049,13 @@ class Peer(PrintError):
|
|||
return
|
||||
|
||||
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)
|
||||
if feerate_per_kw < chan.remote_state.feerate / 2:
|
||||
if feerate_per_kw < chan_fee / 2:
|
||||
self.print_error("FEES HAVE FALLEN")
|
||||
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")
|
||||
chan.update_fee(feerate_per_kw)
|
||||
else:
|
||||
|
|
|
@ -62,9 +62,17 @@ class FeeUpdate:
|
|||
self.progress[field] = self.height
|
||||
|
||||
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
|
||||
|
||||
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]
|
||||
|
||||
def pending_feerate(self, subject):
|
||||
|
@ -76,6 +84,7 @@ class FeeUpdate:
|
|||
return self.rate
|
||||
if subject == LOCAL and not self.chan.constraints.is_initiator:
|
||||
return self.rate
|
||||
# implicit return None
|
||||
|
||||
def to_save(self):
|
||||
return {'rate': self.rate, 'proposed': self.proposed, 'progress': self.progress}
|
||||
|
|
Loading…
Add table
Reference in a new issue