X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FPing.java;h=6c17f2fb90a9bf25abb4eea08afd4ecf77a70759;hb=32692e00046b7ec16b6a2e20bd54800b2b48d4c0;hp=25e970f76e9a463d7c1674560fb6ea199b739039;hpb=90f8a21c87ba652884d5b94404b9b24a18f0cefc;p=ldk-java diff --git a/src/main/java/org/ldk/structs/Ping.java b/src/main/java/org/ldk/structs/Ping.java index 25e970f7..6c17f2fb 100644 --- a/src/main/java/org/ldk/structs/Ping.java +++ b/src/main/java/org/ldk/structs/Ping.java @@ -4,7 +4,12 @@ import org.ldk.impl.bindings; import org.ldk.enums.*; import org.ldk.util.*; import java.util.Arrays; +import javax.annotation.Nullable; + +/** + * A ping message to be sent or received from a peer + */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays public class Ping extends CommonBase { Ping(Object _dummy, long ptr) { super(ptr); } @@ -14,45 +19,75 @@ public class Ping extends CommonBase { if (ptr != 0) { bindings.Ping_free(ptr); } } - public static Ping constructor_clone(Ping orig) { - long ret = bindings.Ping_clone(orig == null ? 0 : orig.ptr & ~1); - Ping ret_hu_conv = new Ping(null, ret); - ret_hu_conv.ptrs_to.add(orig); - return ret_hu_conv; - } - + /** + * The desired response length + */ public short get_ponglen() { short ret = bindings.Ping_get_ponglen(this.ptr); return ret; } + /** + * The desired response length + */ public void set_ponglen(short val) { bindings.Ping_set_ponglen(this.ptr, val); } + /** + * The ping packet size. + * This field is not sent on the wire. byteslen zeros are sent. + */ public short get_byteslen() { short ret = bindings.Ping_get_byteslen(this.ptr); return ret; } + /** + * The ping packet size. + * This field is not sent on the wire. byteslen zeros are sent. + */ public void set_byteslen(short val) { bindings.Ping_set_byteslen(this.ptr, val); } - public static Ping constructor_new(short ponglen_arg, short byteslen_arg) { + /** + * Constructs a new Ping given each field + */ + public static Ping of(short ponglen_arg, short byteslen_arg) { long ret = bindings.Ping_new(ponglen_arg, byteslen_arg); + if (ret >= 0 && ret < 1024) { return null; } Ping ret_hu_conv = new Ping(null, ret); + ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; } + /** + * Creates a copy of the Ping + */ + public Ping clone() { + long ret = bindings.Ping_clone(this.ptr); + if (ret >= 0 && ret < 1024) { return null; } + Ping ret_hu_conv = new Ping(null, ret); + ret_hu_conv.ptrs_to.add(this); + return ret_hu_conv; + } + + /** + * Serialize the Ping object into a byte array which can be read by Ping_read + */ public byte[] write() { byte[] ret = bindings.Ping_write(this.ptr); return ret; } - public static Ping constructor_read(byte[] ser) { + /** + * Read a Ping from a byte array, created by Ping_write + */ + public static Result_PingDecodeErrorZ read(byte[] ser) { long ret = bindings.Ping_read(ser); - Ping ret_hu_conv = new Ping(null, ret); + if (ret >= 0 && ret < 1024) { return null; } + Result_PingDecodeErrorZ ret_hu_conv = Result_PingDecodeErrorZ.constr_from_ptr(ret); return ret_hu_conv; }