X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FScore.java;h=5e7fd85fb379413cbce75803dd543dcdee402c52;hb=890e35a4387758c0447aab34166caa579bbf3a08;hp=a1d8498dfe152f90f51fefda98b6050a701c96a7;hpb=d941cc4e66ea53ce81912a04d35b164344f3a7ee;p=ldk-java diff --git a/src/main/java/org/ldk/structs/Score.java b/src/main/java/org/ldk/structs/Score.java index a1d8498d..5e7fd85f 100644 --- a/src/main/java/org/ldk/structs/Score.java +++ b/src/main/java/org/ldk/structs/Score.java @@ -37,7 +37,7 @@ public class Score extends CommonBase { * [`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, long capacity_msat, NodeId source, NodeId target); + long channel_penalty_msat(long short_channel_id, NodeId source, NodeId target, ChannelUsage usage); /** * Handles updating channel penalties after failing to route through a channel. */ @@ -46,6 +46,14 @@ public class Score extends CommonBase { * Handles updating channel penalties after successfully routing along a path. */ void payment_path_successful(RouteHop[] path); + /** + * Handles updating channel penalties after a probe over the given path failed. + */ + void probe_failed(RouteHop[] path, long short_channel_id); + /** + * Handles updating channel penalties after a probe over the given path succeeded. + */ + void probe_successful(RouteHop[] path); /** * Serialize the object into a byte array */ @@ -55,10 +63,12 @@ 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 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, capacity_msat, source_hu_conv, target_hu_conv); + @Override public long channel_penalty_msat(long short_channel_id, long source, long target, long usage) { + org.ldk.structs.NodeId source_hu_conv = null; if (source < 0 || source > 4096) { source_hu_conv = new org.ldk.structs.NodeId(null, source); } + org.ldk.structs.NodeId target_hu_conv = null; if (target < 0 || target > 4096) { target_hu_conv = new org.ldk.structs.NodeId(null, target); } + org.ldk.structs.ChannelUsage usage_hu_conv = null; if (usage < 0 || usage > 4096) { usage_hu_conv = new org.ldk.structs.ChannelUsage(null, usage); } + if (usage_hu_conv != null) { usage_hu_conv.ptrs_to.add(this); }; + long ret = arg.channel_penalty_msat(short_channel_id, source_hu_conv, target_hu_conv, usage_hu_conv); Reference.reachabilityFence(arg); return ret; } @@ -67,8 +77,8 @@ public class Score extends CommonBase { RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len]; for (int k = 0; k < path_conv_10_len; k++) { long path_conv_10 = path[k]; - RouteHop path_conv_10_hu_conv = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { path_conv_10_hu_conv = new RouteHop(null, path_conv_10); } - path_conv_10_hu_conv.ptrs_to.add(this); + org.ldk.structs.RouteHop path_conv_10_hu_conv = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { path_conv_10_hu_conv = new org.ldk.structs.RouteHop(null, path_conv_10); } + if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.add(this); }; path_conv_10_arr[k] = path_conv_10_hu_conv; } arg.payment_path_failed(path_conv_10_arr, short_channel_id); @@ -79,13 +89,37 @@ public class Score extends CommonBase { RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len]; for (int k = 0; k < path_conv_10_len; k++) { long path_conv_10 = path[k]; - RouteHop path_conv_10_hu_conv = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { path_conv_10_hu_conv = new RouteHop(null, path_conv_10); } - path_conv_10_hu_conv.ptrs_to.add(this); + org.ldk.structs.RouteHop path_conv_10_hu_conv = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { path_conv_10_hu_conv = new org.ldk.structs.RouteHop(null, path_conv_10); } + if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.add(this); }; path_conv_10_arr[k] = path_conv_10_hu_conv; } arg.payment_path_successful(path_conv_10_arr); Reference.reachabilityFence(arg); } + @Override public void probe_failed(long[] path, long short_channel_id) { + int path_conv_10_len = path.length; + RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len]; + for (int k = 0; k < path_conv_10_len; k++) { + long path_conv_10 = path[k]; + org.ldk.structs.RouteHop path_conv_10_hu_conv = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { path_conv_10_hu_conv = new org.ldk.structs.RouteHop(null, path_conv_10); } + if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.add(this); }; + path_conv_10_arr[k] = path_conv_10_hu_conv; + } + arg.probe_failed(path_conv_10_arr, short_channel_id); + Reference.reachabilityFence(arg); + } + @Override public void probe_successful(long[] path) { + int path_conv_10_len = path.length; + RouteHop[] path_conv_10_arr = new RouteHop[path_conv_10_len]; + for (int k = 0; k < path_conv_10_len; k++) { + long path_conv_10 = path[k]; + org.ldk.structs.RouteHop path_conv_10_hu_conv = null; if (path_conv_10 < 0 || path_conv_10 > 4096) { path_conv_10_hu_conv = new org.ldk.structs.RouteHop(null, path_conv_10); } + if (path_conv_10_hu_conv != null) { path_conv_10_hu_conv.ptrs_to.add(this); }; + path_conv_10_arr[k] = path_conv_10_hu_conv; + } + arg.probe_successful(path_conv_10_arr); + Reference.reachabilityFence(arg); + } @Override public byte[] write() { byte[] ret = arg.write(); Reference.reachabilityFence(arg); @@ -104,16 +138,16 @@ public class Score extends CommonBase { * [`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, 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); + public long channel_penalty_msat(long short_channel_id, NodeId source, NodeId target, ChannelUsage usage) { + long ret = bindings.Score_channel_penalty_msat(this.ptr, short_channel_id, source == null ? 0 : source.ptr, target == null ? 0 : target.ptr, usage == null ? 0 : usage.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(short_channel_id); - Reference.reachabilityFence(send_amt_msat); - Reference.reachabilityFence(capacity_msat); Reference.reachabilityFence(source); Reference.reachabilityFence(target); - this.ptrs_to.add(source); - this.ptrs_to.add(target); + Reference.reachabilityFence(usage); + if (this != null) { this.ptrs_to.add(source); }; + if (this != null) { this.ptrs_to.add(target); }; + if (this != null) { this.ptrs_to.add(usage); }; return ret; } @@ -121,19 +155,42 @@ public class Score extends CommonBase { * Handles updating channel penalties after failing to route through a channel. */ public void payment_path_failed(RouteHop[] path, long short_channel_id) { - bindings.Score_payment_path_failed(this.ptr, path != null ? Arrays.stream(path).mapToLong(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr & ~1).toArray() : null, short_channel_id); + bindings.Score_payment_path_failed(this.ptr, path != null ? Arrays.stream(path).mapToLong(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr).toArray() : null, short_channel_id); Reference.reachabilityFence(this); Reference.reachabilityFence(path); Reference.reachabilityFence(short_channel_id); + for (RouteHop path_conv_10: path) { if (this != null) { this.ptrs_to.add(path_conv_10); }; }; } /** * Handles updating channel penalties after successfully routing along a path. */ public void payment_path_successful(RouteHop[] path) { - bindings.Score_payment_path_successful(this.ptr, path != null ? Arrays.stream(path).mapToLong(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr & ~1).toArray() : null); + bindings.Score_payment_path_successful(this.ptr, path != null ? Arrays.stream(path).mapToLong(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr).toArray() : null); + Reference.reachabilityFence(this); + Reference.reachabilityFence(path); + for (RouteHop path_conv_10: path) { if (this != null) { this.ptrs_to.add(path_conv_10); }; }; + } + + /** + * Handles updating channel penalties after a probe over the given path failed. + */ + public void probe_failed(RouteHop[] path, long short_channel_id) { + bindings.Score_probe_failed(this.ptr, path != null ? Arrays.stream(path).mapToLong(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr).toArray() : null, short_channel_id); + Reference.reachabilityFence(this); + Reference.reachabilityFence(path); + Reference.reachabilityFence(short_channel_id); + for (RouteHop path_conv_10: path) { if (this != null) { this.ptrs_to.add(path_conv_10); }; }; + } + + /** + * Handles updating channel penalties after a probe over the given path succeeded. + */ + public void probe_successful(RouteHop[] path) { + bindings.Score_probe_successful(this.ptr, path != null ? Arrays.stream(path).mapToLong(path_conv_10 -> path_conv_10 == null ? 0 : path_conv_10.ptr).toArray() : null); Reference.reachabilityFence(this); Reference.reachabilityFence(path); + for (RouteHop path_conv_10: path) { if (this != null) { this.ptrs_to.add(path_conv_10); }; }; } /**