X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FGossipTimestampFilter.java;h=8983375ef88a1fd26e6c6e3acbcbd9ab565968ab;hb=2bb592fb946e316dba9f4d1123f8ac72ff4e9bf8;hp=96787b6a4783eec29c2b722e6ec4ad30c3a8ce75;hpb=592c4f92dd3011a2f2a7988ce66ed166c3a8f58c;p=ldk-java diff --git a/src/main/java/org/ldk/structs/GossipTimestampFilter.java b/src/main/java/org/ldk/structs/GossipTimestampFilter.java index 96787b6a..8983375e 100644 --- a/src/main/java/org/ldk/structs/GossipTimestampFilter.java +++ b/src/main/java/org/ldk/structs/GossipTimestampFilter.java @@ -2,65 +2,161 @@ package org.ldk.structs; import org.ldk.impl.bindings; import org.ldk.enums.*; +import org.ldk.util.*; +import java.util.Arrays; +import java.lang.ref.Reference; +import javax.annotation.Nullable; + +/** + * A [`gossip_timestamp_filter`] message is used by a node to request + * gossip relay for messages in the requested time range when the + * `gossip_queries` feature has been negotiated. + * + * [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message + */ +@SuppressWarnings("unchecked") // We correctly assign various generic arrays public class GossipTimestampFilter extends CommonBase { GossipTimestampFilter(Object _dummy, long ptr) { super(ptr); } @Override @SuppressWarnings("deprecation") protected void finalize() throws Throwable { super.finalize(); - bindings.GossipTimestampFilter_free(ptr); + if (ptr != 0) { bindings.GossipTimestampFilter_free(ptr); } + } + + /** + * The genesis hash of the blockchain for channel and node information + */ + public byte[] get_chain_hash() { + byte[] ret = bindings.GossipTimestampFilter_get_chain_hash(this.ptr); + Reference.reachabilityFence(this); + return ret; } - public GossipTimestampFilter(GossipTimestampFilter orig) { - super(bindings.GossipTimestampFilter_clone(orig == null ? 0 : orig.ptr & ~1)); - this.ptrs_to.add(orig); + /** + * The genesis hash of the blockchain for channel and node information + */ + public void set_chain_hash(byte[] val) { + bindings.GossipTimestampFilter_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32)); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } - public byte[] get_chain_hash(GossipTimestampFilter this_ptr) { - byte[] ret = bindings.GossipTimestampFilter_get_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + /** + * The starting unix timestamp + */ + public int get_first_timestamp() { + int ret = bindings.GossipTimestampFilter_get_first_timestamp(this.ptr); + Reference.reachabilityFence(this); return ret; } - public void set_chain_hash(GossipTimestampFilter this_ptr, byte[] val) { - bindings.GossipTimestampFilter_set_chain_hash(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * The starting unix timestamp + */ + public void set_first_timestamp(int val) { + bindings.GossipTimestampFilter_set_first_timestamp(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); } - public int get_first_timestamp(GossipTimestampFilter this_ptr) { - int ret = bindings.GossipTimestampFilter_get_first_timestamp(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + /** + * The range of information in seconds + */ + public int get_timestamp_range() { + int ret = bindings.GossipTimestampFilter_get_timestamp_range(this.ptr); + Reference.reachabilityFence(this); return ret; } - public void set_first_timestamp(GossipTimestampFilter this_ptr, int val) { - bindings.GossipTimestampFilter_set_first_timestamp(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * The range of information in seconds + */ + public void set_timestamp_range(int val) { + bindings.GossipTimestampFilter_set_timestamp_range(this.ptr, val); + Reference.reachabilityFence(this); + Reference.reachabilityFence(val); + } + + /** + * Constructs a new GossipTimestampFilter given each field + */ + public static GossipTimestampFilter of(byte[] chain_hash_arg, int first_timestamp_arg, int timestamp_range_arg) { + long ret = bindings.GossipTimestampFilter_new(InternalUtils.check_arr_len(chain_hash_arg, 32), first_timestamp_arg, timestamp_range_arg); + Reference.reachabilityFence(chain_hash_arg); + Reference.reachabilityFence(first_timestamp_arg); + Reference.reachabilityFence(timestamp_range_arg); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.GossipTimestampFilter ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.GossipTimestampFilter(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); }; + return ret_hu_conv; } - public int get_timestamp_range(GossipTimestampFilter this_ptr) { - int ret = bindings.GossipTimestampFilter_get_timestamp_range(this_ptr == null ? 0 : this_ptr.ptr & ~1); - this.ptrs_to.add(this_ptr); + long clone_ptr() { + long ret = bindings.GossipTimestampFilter_clone_ptr(this.ptr); + Reference.reachabilityFence(this); return ret; } - public void set_timestamp_range(GossipTimestampFilter this_ptr, int val) { - bindings.GossipTimestampFilter_set_timestamp_range(this_ptr == null ? 0 : this_ptr.ptr & ~1, val); - this.ptrs_to.add(this_ptr); + /** + * Creates a copy of the GossipTimestampFilter + */ + public GossipTimestampFilter clone() { + long ret = bindings.GossipTimestampFilter_clone(this.ptr); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + org.ldk.structs.GossipTimestampFilter ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.GossipTimestampFilter(null, ret); } + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; + return ret_hu_conv; } - public GossipTimestampFilter(byte[] chain_hash_arg, int first_timestamp_arg, int timestamp_range_arg) { - super(bindings.GossipTimestampFilter_new(chain_hash_arg, first_timestamp_arg, timestamp_range_arg)); + /** + * Generates a non-cryptographic 64-bit hash of the GossipTimestampFilter. + */ + public long hash() { + long ret = bindings.GossipTimestampFilter_hash(this.ptr); + Reference.reachabilityFence(this); + return ret; } - public GossipTimestampFilter(byte[] ser) { - super(bindings.GossipTimestampFilter_read(ser)); + @Override public int hashCode() { + return (int)this.hash(); + } + /** + * Checks if two GossipTimestampFilters contain equal inner contents. + * This ignores pointers and is_owned flags and looks at the values in fields. + * Two objects with NULL inner values will be considered "equal" here. + */ + public boolean eq(org.ldk.structs.GossipTimestampFilter b) { + boolean ret = bindings.GossipTimestampFilter_eq(this.ptr, b == null ? 0 : b.ptr); + Reference.reachabilityFence(this); + Reference.reachabilityFence(b); + if (this != null) { this.ptrs_to.add(b); }; + return ret; } - public byte[] write(GossipTimestampFilter obj) { - byte[] ret = bindings.GossipTimestampFilter_write(obj == null ? 0 : obj.ptr & ~1); - this.ptrs_to.add(obj); + @Override public boolean equals(Object o) { + if (!(o instanceof GossipTimestampFilter)) return false; + return this.eq((GossipTimestampFilter)o); + } + /** + * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read + */ + public byte[] write() { + byte[] ret = bindings.GossipTimestampFilter_write(this.ptr); + Reference.reachabilityFence(this); return ret; } + /** + * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write + */ + public static Result_GossipTimestampFilterDecodeErrorZ read(byte[] ser) { + long ret = bindings.GossipTimestampFilter_read(ser); + Reference.reachabilityFence(ser); + if (ret >= 0 && ret <= 4096) { return null; } + Result_GossipTimestampFilterDecodeErrorZ ret_hu_conv = Result_GossipTimestampFilterDecodeErrorZ.constr_from_ptr(ret); + return ret_hu_conv; + } + }