X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FPositiveTimestamp.java;h=03b0cbd1a08ed8865ecec8d2e3fd59c543b2e0bb;hb=384d4ce1dd44cbd9d7d09cf6ff7818ba0c3ac29b;hp=35e09bd01716b889888401240d37849e46d98fe2;hpb=6fe917116a65d7b62123226c4240d77ea2719783;p=ldk-java diff --git a/src/main/java/org/ldk/structs/PositiveTimestamp.java b/src/main/java/org/ldk/structs/PositiveTimestamp.java index 35e09bd0..03b0cbd1 100644 --- a/src/main/java/org/ldk/structs/PositiveTimestamp.java +++ b/src/main/java/org/ldk/structs/PositiveTimestamp.java @@ -31,10 +31,10 @@ public class PositiveTimestamp extends CommonBase { * Two objects with NULL inner values will be considered "equal" here. */ public boolean eq(PositiveTimestamp b) { - boolean ret = bindings.PositiveTimestamp_eq(this.ptr, b == null ? 0 : b.ptr & ~1); + boolean ret = bindings.PositiveTimestamp_eq(this.ptr, b == null ? 0 : b.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(b); - this.ptrs_to.add(b); + if (this != null) { this.ptrs_to.add(b); }; return ret; } @@ -55,11 +55,23 @@ public class PositiveTimestamp extends CommonBase { long ret = bindings.PositiveTimestamp_clone(this.ptr); Reference.reachabilityFence(this); if (ret >= 0 && ret <= 4096) { return null; } - PositiveTimestamp ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new PositiveTimestamp(null, ret); } - ret_hu_conv.ptrs_to.add(this); + org.ldk.structs.PositiveTimestamp ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.PositiveTimestamp(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; return ret_hu_conv; } + /** + * Checks if two PositiveTimestamps contain equal inner contents. + */ + public long hash() { + long ret = bindings.PositiveTimestamp_hash(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + + @Override public int hashCode() { + return (int)this.hash(); + } /** * Creates a `PositiveTimestamp` from a Unix timestamp in the range `0..=MAX_TIMESTAMP`. *