1
0

wallet update: move fields that have string keys out of channel log

This commit is contained in:
ThomasV
2021-09-20 11:57:12 +02:00
parent 1188187431
commit 7a0904c0f4
5 changed files with 31 additions and 17 deletions

View File

@@ -563,6 +563,8 @@ class Channel(AbstractChannel):
self.onion_keys = state['onion_keys'] # type: Dict[int, bytes]
self.data_loss_protect_remote_pcp = state['data_loss_protect_remote_pcp']
self.hm = HTLCManager(log=state['log'], initial_feerate=initial_feerate)
self.fail_htlc_reasons = state["fail_htlc_reasons"]
self.unfulfilled_htlcs = state["unfulfilled_htlcs"]
self._state = ChannelState[state['state']]
self.peer_state = PeerState.DISCONNECTED
self._sweep_info = {}
@@ -912,7 +914,7 @@ class Channel(AbstractChannel):
remote_ctn = self.get_latest_ctn(REMOTE)
if onion_packet:
# TODO neither local_ctn nor remote_ctn are used anymore... no point storing them.
self.hm.log['unfulfilled_htlcs'][htlc.htlc_id] = local_ctn, remote_ctn, onion_packet.hex(), False
self.unfulfilled_htlcs[htlc.htlc_id] = local_ctn, remote_ctn, onion_packet.hex(), False
self.logger.info("receive_htlc")
return htlc
@@ -1071,10 +1073,10 @@ class Channel(AbstractChannel):
failure_message: Optional['OnionRoutingFailure']):
error_hex = error_bytes.hex() if error_bytes else None
failure_hex = failure_message.to_bytes().hex() if failure_message else None
self.hm.log['fail_htlc_reasons'][htlc_id] = (error_hex, failure_hex)
self.fail_htlc_reasons[htlc_id] = (error_hex, failure_hex)
def pop_fail_htlc_reason(self, htlc_id):
error_hex, failure_hex = self.hm.log['fail_htlc_reasons'].pop(htlc_id, (None, None))
error_hex, failure_hex = self.fail_htlc_reasons.pop(htlc_id, (None, None))
error_bytes = bytes.fromhex(error_hex) if error_hex else None
failure_message = OnionRoutingFailure.from_bytes(bytes.fromhex(failure_hex)) if failure_hex else None
return error_bytes, failure_message