X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;ds=sidebyside;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FRouter.java;h=43f1aa14980bb125764ae59a8d7b607079939890;hb=6fe917116a65d7b62123226c4240d77ea2719783;hp=1bfbc31af0644e0beeb8afb709c935cd6ae97318;hpb=1854b5cebef22ace9e9e4dd191f609818df9ce08;p=ldk-java diff --git a/src/main/java/org/ldk/structs/Router.java b/src/main/java/org/ldk/structs/Router.java index 1bfbc31a..43f1aa14 100644 --- a/src/main/java/org/ldk/structs/Router.java +++ b/src/main/java/org/ldk/structs/Router.java @@ -30,16 +30,17 @@ public class Router extends CommonBase { * * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None */ - Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters params, byte[] payment_hash, ChannelDetails[] first_hops, Score scorer); + Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters route_params, byte[] payment_hash, ChannelDetails[] first_hops, Score scorer); } private static class LDKRouterHolder { Router held; } public static Router new_impl(RouterInterface arg) { final LDKRouterHolder impl_holder = new LDKRouterHolder(); impl_holder.held = new Router(new bindings.LDKRouter() { - @Override public long find_route(byte[] payer, long params, byte[] payment_hash, long[] first_hops, long scorer) { - RouteParameters params_hu_conv = null; if (params < 0 || params > 4096) { params_hu_conv = new RouteParameters(null, params); } - ChannelDetails[] first_hops_conv_16_arr = new ChannelDetails[first_hops.length]; - for (int q = 0; q < first_hops.length; q++) { + @Override public long find_route(byte[] payer, long route_params, byte[] payment_hash, long[] first_hops, long scorer) { + RouteParameters route_params_hu_conv = null; if (route_params < 0 || route_params > 4096) { route_params_hu_conv = new RouteParameters(null, route_params); } + int first_hops_conv_16_len = first_hops.length; + ChannelDetails[] first_hops_conv_16_arr = new ChannelDetails[first_hops_conv_16_len]; + for (int q = 0; q < first_hops_conv_16_len; q++) { long first_hops_conv_16 = first_hops[q]; ChannelDetails first_hops_conv_16_hu_conv = null; if (first_hops_conv_16 < 0 || first_hops_conv_16 > 4096) { first_hops_conv_16_hu_conv = new ChannelDetails(null, first_hops_conv_16); } first_hops_conv_16_hu_conv.ptrs_to.add(this); @@ -47,7 +48,8 @@ public class Router extends CommonBase { } Score ret_hu_conv = new Score(null, scorer); ret_hu_conv.ptrs_to.add(this); - Result_RouteLightningErrorZ ret = arg.find_route(payer, params_hu_conv, payment_hash, first_hops_conv_16_arr, ret_hu_conv); + Result_RouteLightningErrorZ ret = arg.find_route(payer, route_params_hu_conv, payment_hash, first_hops_conv_16_arr, ret_hu_conv); + Reference.reachabilityFence(arg); long result = ret == null ? 0 : ret.clone_ptr(); return result; } @@ -59,17 +61,17 @@ public class Router extends CommonBase { * * Note that first_hops (or a relevant inner pointer) may be NULL or all-0s to represent None */ - public Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters params, byte[] payment_hash, @Nullable ChannelDetails[] first_hops, Score scorer) { - long ret = bindings.Router_find_route(this.ptr, InternalUtils.check_arr_len(payer, 33), params == null ? 0 : params.ptr & ~1, InternalUtils.check_arr_len(payment_hash, 32), first_hops != null ? Arrays.stream(first_hops).mapToLong(first_hops_conv_16 -> first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr & ~1).toArray() : null, scorer == null ? 0 : scorer.ptr); + public Result_RouteLightningErrorZ find_route(byte[] payer, RouteParameters route_params, byte[] payment_hash, @Nullable ChannelDetails[] first_hops, Score scorer) { + long ret = bindings.Router_find_route(this.ptr, InternalUtils.check_arr_len(payer, 33), route_params == null ? 0 : route_params.ptr & ~1, InternalUtils.check_arr_len(payment_hash, 32), first_hops != null ? Arrays.stream(first_hops).mapToLong(first_hops_conv_16 -> first_hops_conv_16 == null ? 0 : first_hops_conv_16.ptr & ~1).toArray() : null, scorer == null ? 0 : scorer.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(payer); - Reference.reachabilityFence(params); + Reference.reachabilityFence(route_params); Reference.reachabilityFence(payment_hash); Reference.reachabilityFence(first_hops); Reference.reachabilityFence(scorer); if (ret >= 0 && ret <= 4096) { return null; } Result_RouteLightningErrorZ ret_hu_conv = Result_RouteLightningErrorZ.constr_from_ptr(ret); - this.ptrs_to.add(params); + this.ptrs_to.add(route_params); for (ChannelDetails first_hops_conv_16: first_hops) { this.ptrs_to.add(first_hops_conv_16); }; this.ptrs_to.add(scorer); return ret_hu_conv;