X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FNetworkUpdate.java;h=438a26fa31e8593b19b188ed83bd956cf94af2ed;hb=3c60e0fd0da579be9932801c1be2b32014c944a5;hp=0a85f072062ae04faaef81449ecbf7c6bfc0da2f;hpb=9aa1eebc40df06586c7ab12f7c8eb22ebcb8b365;p=ldk-java diff --git a/src/main/java/org/ldk/structs/NetworkUpdate.java b/src/main/java/org/ldk/structs/NetworkUpdate.java index 0a85f072..438a26fa 100644 --- a/src/main/java/org/ldk/structs/NetworkUpdate.java +++ b/src/main/java/org/ldk/structs/NetworkUpdate.java @@ -12,7 +12,7 @@ import javax.annotation.Nullable; * Update to the [`NetworkGraph`] based on payment failure information conveyed via the Onion * return packet by a node along the route. See [BOLT #4] for details. * - * [BOLT #4]: https://github.com/lightningnetwork/lightning-rfc/blob/master/04-onion-routing.md + * [BOLT #4]: https://github.com/lightning/bolts/blob/master/04-onion-routing.md */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays public class NetworkUpdate extends CommonBase { @@ -27,8 +27,8 @@ public class NetworkUpdate extends CommonBase { if (raw_val.getClass() == bindings.LDKNetworkUpdate.ChannelUpdateMessage.class) { return new ChannelUpdateMessage(ptr, (bindings.LDKNetworkUpdate.ChannelUpdateMessage)raw_val); } - if (raw_val.getClass() == bindings.LDKNetworkUpdate.ChannelClosed.class) { - return new ChannelClosed(ptr, (bindings.LDKNetworkUpdate.ChannelClosed)raw_val); + if (raw_val.getClass() == bindings.LDKNetworkUpdate.ChannelFailure.class) { + return new ChannelFailure(ptr, (bindings.LDKNetworkUpdate.ChannelFailure)raw_val); } if (raw_val.getClass() == bindings.LDKNetworkUpdate.NodeFailure.class) { return new NodeFailure(ptr, (bindings.LDKNetworkUpdate.NodeFailure)raw_val); @@ -48,16 +48,16 @@ public class NetworkUpdate extends CommonBase { private ChannelUpdateMessage(long ptr, bindings.LDKNetworkUpdate.ChannelUpdateMessage obj) { super(null, ptr); long msg = obj.msg; - ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new ChannelUpdate(null, msg); } - msg_hu_conv.ptrs_to.add(this); + org.ldk.structs.ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelUpdate(null, msg); } + if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.add(this); }; this.msg = msg_hu_conv; } } /** - * An error indicating only that a channel has been closed, which should be applied via - * [`NetworkGraph::close_channel_from_update`]. + * An error indicating that a channel failed to route a payment, which should be applied via + * [`NetworkGraph::channel_failed`]. */ - public final static class ChannelClosed extends NetworkUpdate { + public final static class ChannelFailure extends NetworkUpdate { /** * The short channel id of the closed channel. */ @@ -67,15 +67,15 @@ public class NetworkUpdate extends CommonBase { * `channel_update` message is received. */ public final boolean is_permanent; - private ChannelClosed(long ptr, bindings.LDKNetworkUpdate.ChannelClosed obj) { + private ChannelFailure(long ptr, bindings.LDKNetworkUpdate.ChannelFailure obj) { super(null, ptr); this.short_channel_id = obj.short_channel_id; this.is_permanent = obj.is_permanent; } } /** - * An error indicating only that a node has failed, which should be applied via - * [`NetworkGraph::fail_node`]. + * An error indicating that a node failed to route a payment, which should be applied via + * [`NetworkGraph::node_failed`]. */ public final static class NodeFailure extends NetworkUpdate { /** @@ -107,7 +107,7 @@ public class NetworkUpdate extends CommonBase { Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.NetworkUpdate ret_hu_conv = org.ldk.structs.NetworkUpdate.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(this); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } @@ -115,24 +115,25 @@ public class NetworkUpdate extends CommonBase { * Utility method to constructs a new ChannelUpdateMessage-variant NetworkUpdate */ public static NetworkUpdate channel_update_message(ChannelUpdate msg) { - long ret = bindings.NetworkUpdate_channel_update_message(msg == null ? 0 : msg.ptr & ~1); + long ret = bindings.NetworkUpdate_channel_update_message(msg == null ? 0 : msg.ptr); Reference.reachabilityFence(msg); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.NetworkUpdate ret_hu_conv = org.ldk.structs.NetworkUpdate.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(msg); }; return ret_hu_conv; } /** - * Utility method to constructs a new ChannelClosed-variant NetworkUpdate + * Utility method to constructs a new ChannelFailure-variant NetworkUpdate */ - public static NetworkUpdate channel_closed(long short_channel_id, boolean is_permanent) { - long ret = bindings.NetworkUpdate_channel_closed(short_channel_id, is_permanent); + public static NetworkUpdate channel_failure(long short_channel_id, boolean is_permanent) { + long ret = bindings.NetworkUpdate_channel_failure(short_channel_id, is_permanent); Reference.reachabilityFence(short_channel_id); Reference.reachabilityFence(is_permanent); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.NetworkUpdate ret_hu_conv = org.ldk.structs.NetworkUpdate.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; return ret_hu_conv; } @@ -145,7 +146,7 @@ public class NetworkUpdate extends CommonBase { Reference.reachabilityFence(is_permanent); if (ret >= 0 && ret <= 4096) { return null; } org.ldk.structs.NetworkUpdate ret_hu_conv = org.ldk.structs.NetworkUpdate.constr_from_ptr(ret); - ret_hu_conv.ptrs_to.add(ret_hu_conv); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; return ret_hu_conv; }