1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
12 * A [`gossip_timestamp_filter`] message is used by a node to request
13 * gossip relay for messages in the requested time range when the
14 * `gossip_queries` feature has been negotiated.
16 * [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
18 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
19 public class GossipTimestampFilter extends CommonBase {
20 GossipTimestampFilter(Object _dummy, long ptr) { super(ptr); }
21 @Override @SuppressWarnings("deprecation")
22 protected void finalize() throws Throwable {
24 if (ptr != 0) { bindings.GossipTimestampFilter_free(ptr); }
28 * The genesis hash of the blockchain for channel and node information
30 public byte[] get_chain_hash() {
31 byte[] ret = bindings.GossipTimestampFilter_get_chain_hash(this.ptr);
32 Reference.reachabilityFence(this);
37 * The genesis hash of the blockchain for channel and node information
39 public void set_chain_hash(byte[] val) {
40 bindings.GossipTimestampFilter_set_chain_hash(this.ptr, InternalUtils.check_arr_len(val, 32));
41 Reference.reachabilityFence(this);
42 Reference.reachabilityFence(val);
46 * The starting unix timestamp
48 public int get_first_timestamp() {
49 int ret = bindings.GossipTimestampFilter_get_first_timestamp(this.ptr);
50 Reference.reachabilityFence(this);
55 * The starting unix timestamp
57 public void set_first_timestamp(int val) {
58 bindings.GossipTimestampFilter_set_first_timestamp(this.ptr, val);
59 Reference.reachabilityFence(this);
60 Reference.reachabilityFence(val);
64 * The range of information in seconds
66 public int get_timestamp_range() {
67 int ret = bindings.GossipTimestampFilter_get_timestamp_range(this.ptr);
68 Reference.reachabilityFence(this);
73 * The range of information in seconds
75 public void set_timestamp_range(int val) {
76 bindings.GossipTimestampFilter_set_timestamp_range(this.ptr, val);
77 Reference.reachabilityFence(this);
78 Reference.reachabilityFence(val);
82 * Constructs a new GossipTimestampFilter given each field
84 public static GossipTimestampFilter of(byte[] chain_hash_arg, int first_timestamp_arg, int timestamp_range_arg) {
85 long ret = bindings.GossipTimestampFilter_new(InternalUtils.check_arr_len(chain_hash_arg, 32), first_timestamp_arg, timestamp_range_arg);
86 Reference.reachabilityFence(chain_hash_arg);
87 Reference.reachabilityFence(first_timestamp_arg);
88 Reference.reachabilityFence(timestamp_range_arg);
89 if (ret >= 0 && ret <= 4096) { return null; }
90 org.ldk.structs.GossipTimestampFilter ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.GossipTimestampFilter(null, ret); }
91 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
96 long ret = bindings.GossipTimestampFilter_clone_ptr(this.ptr);
97 Reference.reachabilityFence(this);
102 * Creates a copy of the GossipTimestampFilter
104 public GossipTimestampFilter clone() {
105 long ret = bindings.GossipTimestampFilter_clone(this.ptr);
106 Reference.reachabilityFence(this);
107 if (ret >= 0 && ret <= 4096) { return null; }
108 org.ldk.structs.GossipTimestampFilter ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.GossipTimestampFilter(null, ret); }
109 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
114 * Generates a non-cryptographic 64-bit hash of the GossipTimestampFilter.
117 long ret = bindings.GossipTimestampFilter_hash(this.ptr);
118 Reference.reachabilityFence(this);
122 @Override public int hashCode() {
123 return (int)this.hash();
126 * Checks if two GossipTimestampFilters contain equal inner contents.
127 * This ignores pointers and is_owned flags and looks at the values in fields.
128 * Two objects with NULL inner values will be considered "equal" here.
130 public boolean eq(org.ldk.structs.GossipTimestampFilter b) {
131 boolean ret = bindings.GossipTimestampFilter_eq(this.ptr, b.ptr);
132 Reference.reachabilityFence(this);
133 Reference.reachabilityFence(b);
134 if (this != null) { this.ptrs_to.add(b); };
138 @Override public boolean equals(Object o) {
139 if (!(o instanceof GossipTimestampFilter)) return false;
140 return this.eq((GossipTimestampFilter)o);
143 * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
145 public byte[] write() {
146 byte[] ret = bindings.GossipTimestampFilter_write(this.ptr);
147 Reference.reachabilityFence(this);
152 * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
154 public static Result_GossipTimestampFilterDecodeErrorZ read(byte[] ser) {
155 long ret = bindings.GossipTimestampFilter_read(ser);
156 Reference.reachabilityFence(ser);
157 if (ret >= 0 && ret <= 4096) { return null; }
158 Result_GossipTimestampFilterDecodeErrorZ ret_hu_conv = Result_GossipTimestampFilterDecodeErrorZ.constr_from_ptr(ret);