X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FScore.java;h=a1d8498dfe152f90f51fefda98b6050a701c96a7;hb=6fe917116a65d7b62123226c4240d77ea2719783;hp=63da5612f36822bc72baaac32464514119a6a24c;hpb=1f873e8aeb7a8395a7a99d244fba7474a0543278;p=ldk-java diff --git a/src/main/java/org/ldk/structs/Score.java b/src/main/java/org/ldk/structs/Score.java index 63da5612..a1d8498d 100644 --- a/src/main/java/org/ldk/structs/Score.java +++ b/src/main/java/org/ldk/structs/Score.java @@ -31,17 +31,13 @@ public class Score extends CommonBase { * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the * given channel in the direction from `source` to `target`. * - * The channel's capacity (less any other MPP parts which are also being considered for use in - * the same payment) is given by `channel_capacity_msat`. It may be guessed from various - * sources or assumed from no data at all. - * - * For hints provided in the invoice, we assume the channel has sufficient capacity to accept - * the invoice's full amount, and provide a `channel_capacity_msat` of `None`. In all other - * cases it is set to `Some`, even if we're guessing at the channel value. - * - * Your code should be overflow-safe through a `channel_capacity_msat` of 21 million BTC. + * The channel's capacity (less any other MPP parts that are also being considered for use in + * the same payment) is given by `capacity_msat`. It may be determined from various sources + * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near + * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount. + * Thus, implementations should be overflow-safe. */ - long channel_penalty_msat(long short_channel_id, long send_amt_msat, Option_u64Z channel_capacity_msat, NodeId source, NodeId target); + long channel_penalty_msat(long short_channel_id, long send_amt_msat, long capacity_msat, NodeId source, NodeId target); /** * Handles updating channel penalties after failing to route through a channel. */ @@ -59,12 +55,11 @@ public class Score extends CommonBase { public static Score new_impl(ScoreInterface arg) { final LDKScoreHolder impl_holder = new LDKScoreHolder(); impl_holder.held = new Score(new bindings.LDKScore() { - @Override public long channel_penalty_msat(long short_channel_id, long send_amt_msat, long channel_capacity_msat, long source, long target) { - Option_u64Z channel_capacity_msat_hu_conv = Option_u64Z.constr_from_ptr(channel_capacity_msat); - channel_capacity_msat_hu_conv.ptrs_to.add(this); + @Override public long channel_penalty_msat(long short_channel_id, long send_amt_msat, long capacity_msat, long source, long target) { NodeId source_hu_conv = null; if (source < 0 || source > 4096) { source_hu_conv = new NodeId(null, source); } NodeId target_hu_conv = null; if (target < 0 || target > 4096) { target_hu_conv = new NodeId(null, target); } - long ret = arg.channel_penalty_msat(short_channel_id, send_amt_msat, channel_capacity_msat_hu_conv, source_hu_conv, target_hu_conv); + long ret = arg.channel_penalty_msat(short_channel_id, send_amt_msat, capacity_msat, source_hu_conv, target_hu_conv); + Reference.reachabilityFence(arg); return ret; } @Override public void payment_path_failed(long[] path, long short_channel_id) { @@ -77,6 +72,7 @@ public class Score extends CommonBase { path_conv_10_arr[k] = path_conv_10_hu_conv; } arg.payment_path_failed(path_conv_10_arr, short_channel_id); + Reference.reachabilityFence(arg); } @Override public void payment_path_successful(long[] path) { int path_conv_10_len = path.length; @@ -88,9 +84,11 @@ public class Score extends CommonBase { path_conv_10_arr[k] = path_conv_10_hu_conv; } arg.payment_path_successful(path_conv_10_arr); + Reference.reachabilityFence(arg); } @Override public byte[] write() { byte[] ret = arg.write(); + Reference.reachabilityFence(arg); return ret; } }); @@ -100,22 +98,18 @@ public class Score extends CommonBase { * Returns the fee in msats willing to be paid to avoid routing `send_amt_msat` through the * given channel in the direction from `source` to `target`. * - * The channel's capacity (less any other MPP parts which are also being considered for use in - * the same payment) is given by `channel_capacity_msat`. It may be guessed from various - * sources or assumed from no data at all. - * - * For hints provided in the invoice, we assume the channel has sufficient capacity to accept - * the invoice's full amount, and provide a `channel_capacity_msat` of `None`. In all other - * cases it is set to `Some`, even if we're guessing at the channel value. - * - * Your code should be overflow-safe through a `channel_capacity_msat` of 21 million BTC. + * The channel's capacity (less any other MPP parts that are also being considered for use in + * the same payment) is given by `capacity_msat`. It may be determined from various sources + * such as a chain data, network gossip, or invoice hints. For invoice hints, a capacity near + * [`u64::max_value`] is given to indicate sufficient capacity for the invoice's full amount. + * Thus, implementations should be overflow-safe. */ - public long channel_penalty_msat(long short_channel_id, long send_amt_msat, Option_u64Z channel_capacity_msat, NodeId source, NodeId target) { - long ret = bindings.Score_channel_penalty_msat(this.ptr, short_channel_id, send_amt_msat, channel_capacity_msat.ptr, source == null ? 0 : source.ptr & ~1, target == null ? 0 : target.ptr & ~1); + public long channel_penalty_msat(long short_channel_id, long send_amt_msat, long capacity_msat, NodeId source, NodeId target) { + long ret = bindings.Score_channel_penalty_msat(this.ptr, short_channel_id, send_amt_msat, capacity_msat, source == null ? 0 : source.ptr & ~1, target == null ? 0 : target.ptr & ~1); Reference.reachabilityFence(this); Reference.reachabilityFence(short_channel_id); Reference.reachabilityFence(send_amt_msat); - Reference.reachabilityFence(channel_capacity_msat); + Reference.reachabilityFence(capacity_msat); Reference.reachabilityFence(source); Reference.reachabilityFence(target); this.ptrs_to.add(source);