61b7868119d259139c613ed8354e6738a6e09ae6
[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          * Checks if two GossipTimestampFilters contain equal inner contents.
115          * This ignores pointers and is_owned flags and looks at the values in fields.
116          * Two objects with NULL inner values will be considered "equal" here.
117          */
118         public boolean eq(org.ldk.structs.GossipTimestampFilter b) {
119                 boolean ret = bindings.GossipTimestampFilter_eq(this.ptr, b == null ? 0 : b.ptr);
120                 Reference.reachabilityFence(this);
121                 Reference.reachabilityFence(b);
122                 if (this != null) { this.ptrs_to.add(b); };
123                 return ret;
124         }
125
126         @Override public boolean equals(Object o) {
127                 if (!(o instanceof GossipTimestampFilter)) return false;
128                 return this.eq((GossipTimestampFilter)o);
129         }
130         /**
131          * Serialize the GossipTimestampFilter object into a byte array which can be read by GossipTimestampFilter_read
132          */
133         public byte[] write() {
134                 byte[] ret = bindings.GossipTimestampFilter_write(this.ptr);
135                 Reference.reachabilityFence(this);
136                 return ret;
137         }
138
139         /**
140          * Read a GossipTimestampFilter from a byte array, created by GossipTimestampFilter_write
141          */
142         public static Result_GossipTimestampFilterDecodeErrorZ read(byte[] ser) {
143                 long ret = bindings.GossipTimestampFilter_read(ser);
144                 Reference.reachabilityFence(ser);
145                 if (ret >= 0 && ret <= 4096) { return null; }
146                 Result_GossipTimestampFilterDecodeErrorZ ret_hu_conv = Result_GossipTimestampFilterDecodeErrorZ.constr_from_ptr(ret);
147                 return ret_hu_conv;
148         }
149
150 }