[Java] Update auto-generated Java bindings to LDK 0.0.121
[ldk-java] / src / main / java / org / ldk / structs / GossipTimestampFilter.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import java.lang.ref.Reference;
8 import javax.annotation.Nullable;
9
10
11 /**
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.
15  * 
16  * [`gossip_timestamp_filter`]: https://github.com/lightning/bolts/blob/master/07-routing-gossip.md#the-gossip_timestamp_filter-message
17  */
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 {
23                 super.finalize();
24                 if (ptr != 0) { bindings.GossipTimestampFilter_free(ptr); }
25         }
26
27         /**
28          * The genesis hash of the blockchain for channel and node information
29          */
30         public byte[] get_chain_hash() {
31                 byte[] ret = bindings.GossipTimestampFilter_get_chain_hash(this.ptr);
32                 Reference.reachabilityFence(this);
33                 return ret;
34         }
35
36         /**
37          * The genesis hash of the blockchain for channel and node information
38          */
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);
43         }
44
45         /**
46          * The starting unix timestamp
47          */
48         public int get_first_timestamp() {
49                 int ret = bindings.GossipTimestampFilter_get_first_timestamp(this.ptr);
50                 Reference.reachabilityFence(this);
51                 return ret;
52         }
53
54         /**
55          * The starting unix timestamp
56          */
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);
61         }
62
63         /**
64          * The range of information in seconds
65          */
66         public int get_timestamp_range() {
67                 int ret = bindings.GossipTimestampFilter_get_timestamp_range(this.ptr);
68                 Reference.reachabilityFence(this);
69                 return ret;
70         }
71
72         /**
73          * The range of information in seconds
74          */
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);
79         }
80
81         /**
82          * Constructs a new GossipTimestampFilter given each field
83          */
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); };
92                 return ret_hu_conv;
93         }
94
95         long clone_ptr() {
96                 long ret = bindings.GossipTimestampFilter_clone_ptr(this.ptr);
97                 Reference.reachabilityFence(this);
98                 return ret;
99         }
100
101         /**
102          * Creates a copy of the GossipTimestampFilter
103          */
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); };
110                 return ret_hu_conv;
111         }
112
113         /**
114          * Generates a non-cryptographic 64-bit hash of the GossipTimestampFilter.
115          */
116         public long hash() {
117                 long ret = bindings.GossipTimestampFilter_hash(this.ptr);
118                 Reference.reachabilityFence(this);
119                 return ret;
120         }
121
122         @Override public int hashCode() {
123                 return (int)this.hash();
124         }
125         /**
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.
129          */
130         public boolean eq(org.ldk.structs.GossipTimestampFilter b) {
131                 boolean ret = bindings.GossipTimestampFilter_eq(this.ptr, b == null ? 0 : b.ptr);
132                 Reference.reachabilityFence(this);
133                 Reference.reachabilityFence(b);
134                 if (this != null) { this.ptrs_to.add(b); };
135                 return ret;
136         }
137
138         @Override public boolean equals(Object o) {
139                 if (!(o instanceof GossipTimestampFilter)) return false;
140                 return this.eq((GossipTimestampFilter)o);
141         }
142         /**
143          * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
144          */
145         public byte[] write() {
146                 byte[] ret = bindings.GossipTimestampFilter_write(this.ptr);
147                 Reference.reachabilityFence(this);
148                 return ret;
149         }
150
151         /**
152          * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
153          */
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);
159                 return ret_hu_conv;
160         }
161
162 }