@@ -138,7 +138,7 @@ class ChannelRelay private(nodeParams: NodeParams,
138138 Metrics .recordPaymentRelayFailed(Tags .FailureType (cmdFail), Tags .RelayType .Channel )
139139 context.log.info(" rejecting htlc reason={}" , cmdFail.reason)
140140 reputationRecorder ! CancelRelay (originNode, r.add.endorsement, relayId)
141- safeSendAndStop(r.add.channelId, cmdFail)
141+ safeSendAndStop(r.add.channelId, cmdFail, confidence )
142142 case RelaySuccess (selectedChannelId, cmdAdd) =>
143143 context.log.info(" forwarding htlc #{} from channelId={} to channelId={}" , r.add.id, r.add.channelId, selectedChannelId)
144144 register ! Register .Forward (forwardFailureAdapter, selectedChannelId, cmdAdd)
@@ -154,38 +154,39 @@ class ChannelRelay private(nodeParams: NodeParams,
154154 val cmdFail = CMD_FAIL_HTLC (o.add.id, Right (UnknownNextPeer ()), commit = true )
155155 Metrics .recordPaymentRelayFailed(Tags .FailureType (cmdFail), Tags .RelayType .Channel )
156156 reputationRecorder ! CancelRelay (originNode, r.add.endorsement, relayId)
157- safeSendAndStop(o.add.channelId, cmdFail)
157+ safeSendAndStop(o.add.channelId, cmdFail, confidence, Some (channelId) )
158158
159159 case WrappedAddResponse (addFailed@ RES_ADD_FAILED (CMD_ADD_HTLC (_, _, _, _, _, _, _, _ : Origin .ChannelRelayedHot , _), _, _)) =>
160160 context.log.info(" attempt failed with reason={}" , addFailed.t.getClass.getSimpleName)
161161 context.self ! WrappedConfidence (confidence)
162162 relay(previousFailures :+ PreviouslyTried (selectedChannelId, addFailed))
163163
164- case WrappedAddResponse (_ : RES_SUCCESS [_]) =>
164+ case WrappedAddResponse (r : RES_SUCCESS [_]) =>
165165 context.log.debug(" sent htlc to the downstream channel" )
166- waitForAddSettled(confidence)
166+ waitForAddSettled(confidence, r.channelId )
167167 }
168168
169- def waitForAddSettled (confidence : Double ): Behavior [Command ] =
169+ def waitForAddSettled (confidence : Double , channelId : ByteVector32 ): Behavior [Command ] =
170170 Behaviors .receiveMessagePartial {
171171 case WrappedAddResponse (RES_ADD_SETTLED (o : Origin .ChannelRelayedHot , htlc, fulfill : HtlcResult .Fulfill )) =>
172172 context.log.debug(" relaying fulfill to upstream" )
173173 Metrics .relaySettleFulfill(confidence)
174174 val cmd = CMD_FULFILL_HTLC (o.originHtlcId, fulfill.paymentPreimage, commit = true )
175175 context.system.eventStream ! EventStream .Publish (ChannelPaymentRelayed (o.amountIn, o.amountOut, htlc.paymentHash, o.originChannelId, htlc.channelId, startedAt, TimestampMilli .now()))
176176 recordRelayDuration(isSuccess = true )
177- safeSendAndStop(o.originChannelId, cmd)
177+ safeSendAndStop(o.originChannelId, cmd, confidence, Some (channelId) )
178178
179179 case WrappedAddResponse (RES_ADD_SETTLED (o : Origin .ChannelRelayedHot , _, fail : HtlcResult .Fail )) =>
180180 context.log.debug(" relaying fail to upstream" )
181181 Metrics .relaySettleFail(confidence)
182182 Metrics .recordPaymentRelayFailed(Tags .FailureType .Remote , Tags .RelayType .Channel )
183183 val cmd = translateRelayFailure(o.originHtlcId, fail)
184184 recordRelayDuration(isSuccess = false )
185- safeSendAndStop(o.originChannelId, cmd)
185+ safeSendAndStop(o.originChannelId, cmd, confidence, Some (channelId) )
186186 }
187187
188- def safeSendAndStop (channelId : ByteVector32 , cmd : channel.HtlcSettlementCommand ): Behavior [Command ] = {
188+ def safeSendAndStop (channelId : ByteVector32 , cmd : channel.HtlcSettlementCommand , confidence : Double , outgoingChannel_opt : Option [ByteVector32 ]): Behavior [Command ] = {
189+ context.log.info(" cmd={}, startedAt={}, endedAt={}, confidence={}, originNode={}, outgoingChannel={}" , cmd.getClass.getSimpleName, startedAt, TimestampMilli .now(), confidence, originNode, outgoingChannel_opt)
189190 val toSend = cmd match {
190191 case _ : CMD_FULFILL_HTLC => cmd
191192 case _ : CMD_FAIL_HTLC | _ : CMD_FAIL_MALFORMED_HTLC => r.payload match {
0 commit comments