Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Data/Models/ForwardingHtlcEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public class ForwardingHtlcEvent
public int? WireFailureCode { get; set; }
public int? FailureDetail { get; set; }

[MaxLength(1024)]
[MaxLength(2048)]
Comment thread
imclvr marked this conversation as resolved.
public string? FailureString { get; set; }
}

Expand Down
18 changes: 17 additions & 1 deletion src/Jobs/NodeHtlcSubscribeJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ private static bool IsNodeEligible(Node? node)
FeeMsat = CalculateNetFeeMsat(info?.IncomingAmtMsat, info?.OutgoingAmtMsat),
WireFailureCode = htlcEvent.LinkFailEvent != null ? (int)htlcEvent.LinkFailEvent.WireFailure : null,
FailureDetail = htlcEvent.LinkFailEvent != null ? (int)htlcEvent.LinkFailEvent.FailureDetail : null,
FailureString = htlcEvent.LinkFailEvent?.FailureString,
FailureString = TruncateFailureString(htlcEvent.LinkFailEvent?.FailureString),
};
}

Expand Down Expand Up @@ -399,6 +399,22 @@ internal static void ApplyFeeBreakdown(ForwardingHtlcEvent forwardingHtlcEvent,
return feeMsat.Value - grossFeeMsat.Value;
}

// FailureString is persisted to a character varying(2048) column. lnd can emit failure
// descriptions longer than that, so when the value reaches the column limit we keep the
// first 2044 characters and append an ellipsis (2044 + 3 = 2047, within the 2048 bound).
private const int FailureStringMaxLength = 2048;
private const string FailureStringEllipsis = "...";

private static string? TruncateFailureString(string? value)
{
if (value is null || value.Length < FailureStringMaxLength)
{
return value;
}

return string.Concat(value.AsSpan(0, FailureStringMaxLength - FailureStringEllipsis.Length - 1), FailureStringEllipsis);
}

internal static DateTimeOffset MapEventTimestamp(ulong timestampNs)
{
return DateTimeOffset.UnixEpoch.AddTicks(checked((long)(timestampNs / 100)));
Expand Down
Loading
Loading