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 [`pong`] message to be sent to or received from a peer.
14 * [`pong`]: https://github.com/lightning/bolts/blob/master/01-messaging.md#the-ping-and-pong-messages
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class Pong extends CommonBase {
18 Pong(Object _dummy, long ptr) { super(ptr); }
19 @Override @SuppressWarnings("deprecation")
20 protected void finalize() throws Throwable {
22 if (ptr != 0) { bindings.Pong_free(ptr); }
26 * The pong packet size.
28 * This field is not sent on the wire. byteslen zeros are sent.
30 public short get_byteslen() {
31 short ret = bindings.Pong_get_byteslen(this.ptr);
32 Reference.reachabilityFence(this);
37 * The pong packet size.
39 * This field is not sent on the wire. byteslen zeros are sent.
41 public void set_byteslen(short val) {
42 bindings.Pong_set_byteslen(this.ptr, val);
43 Reference.reachabilityFence(this);
44 Reference.reachabilityFence(val);
48 * Constructs a new Pong given each field
50 public static Pong of(short byteslen_arg) {
51 long ret = bindings.Pong_new(byteslen_arg);
52 Reference.reachabilityFence(byteslen_arg);
53 if (ret >= 0 && ret <= 4096) { return null; }
54 org.ldk.structs.Pong ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Pong(null, ret); }
55 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(ret_hu_conv); };
60 long ret = bindings.Pong_clone_ptr(this.ptr);
61 Reference.reachabilityFence(this);
66 * Creates a copy of the Pong
69 long ret = bindings.Pong_clone(this.ptr);
70 Reference.reachabilityFence(this);
71 if (ret >= 0 && ret <= 4096) { return null; }
72 org.ldk.structs.Pong ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.Pong(null, ret); }
73 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); };
78 * Generates a non-cryptographic 64-bit hash of the Pong.
81 long ret = bindings.Pong_hash(this.ptr);
82 Reference.reachabilityFence(this);
86 @Override public int hashCode() {
87 return (int)this.hash();
90 * Checks if two Pongs contain equal inner contents.
91 * This ignores pointers and is_owned flags and looks at the values in fields.
92 * Two objects with NULL inner values will be considered "equal" here.
94 public boolean eq(org.ldk.structs.Pong b) {
95 boolean ret = bindings.Pong_eq(this.ptr, b.ptr);
96 Reference.reachabilityFence(this);
97 Reference.reachabilityFence(b);
98 if (this != null) { this.ptrs_to.add(b); };
102 @Override public boolean equals(Object o) {
103 if (!(o instanceof Pong)) return false;
104 return this.eq((Pong)o);
107 * Serialize the Pong object into a byte array which can be read by Pong_read
109 public byte[] write() {
110 byte[] ret = bindings.Pong_write(this.ptr);
111 Reference.reachabilityFence(this);
116 * Read a Pong from a byte array, created by Pong_write
118 public static Result_PongDecodeErrorZ read(byte[] ser) {
119 long ret = bindings.Pong_read(ser);
120 Reference.reachabilityFence(ser);
121 if (ret >= 0 && ret <= 4096) { return null; }
122 Result_PongDecodeErrorZ ret_hu_conv = Result_PongDecodeErrorZ.constr_from_ptr(ret);