X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FNetworkUpdate.java;h=60d3bfd58f71f93eae85353a03e812ba7110ffee;hb=5e9de82b3a7712a41189756d9d16d946142b2ac5;hp=8dff959e53063cbd0ceff0eb959c63a38a42aaef;hpb=47341beaeecf907f422f126500baf586d54a0d41;p=ldk-java diff --git a/src/main/java/org/ldk/structs/NetworkUpdate.java b/src/main/java/org/ldk/structs/NetworkUpdate.java index 8dff959e..60d3bfd5 100644 --- a/src/main/java/org/ldk/structs/NetworkUpdate.java +++ b/src/main/java/org/ldk/structs/NetworkUpdate.java @@ -49,7 +49,7 @@ public class NetworkUpdate extends CommonBase { super(null, ptr); long msg = obj.msg; org.ldk.structs.ChannelUpdate msg_hu_conv = null; if (msg < 0 || msg > 4096) { msg_hu_conv = new org.ldk.structs.ChannelUpdate(null, msg); } - msg_hu_conv.ptrs_to.add(this); + if (msg_hu_conv != null) { msg_hu_conv.ptrs_to.add(this); }; this.msg = msg_hu_conv; } } @@ -75,7 +75,7 @@ public class NetworkUpdate extends CommonBase { } /** * An error indicating that a node failed to route a payment, which should be applied via - * [`NetworkGraph::node_failed`]. + * [`NetworkGraph::node_failed_permanent`] if permanent. */ 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,11 +115,12 @@ 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; } @@ -132,7 +133,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; } @@ -145,10 +146,25 @@ 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; } + /** + * Checks if two NetworkUpdates contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + */ + public boolean eq(NetworkUpdate b) { + boolean ret = bindings.NetworkUpdate_eq(this.ptr, b == null ? 0 : b.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(b); + return ret; + } + + @Override public boolean equals(Object o) { + if (!(o instanceof NetworkUpdate)) return false; + return this.eq((NetworkUpdate)o); + } /** * Serialize the NetworkUpdate object into a byte array which can be read by NetworkUpdate_read */