X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FBestBlock.java;h=f746b47d2e456a0497a45338db39022d644b8672;hb=23cf651a6855035c3fde1cf62cb86002a5731342;hp=cda09d30f09453df56f4cb2f34cb1c59471aeee9;hpb=12c3ea6f32816f379249a75863971a1c7e1089a1;p=ldk-java diff --git a/src/main/java/org/ldk/structs/BestBlock.java b/src/main/java/org/ldk/structs/BestBlock.java index cda09d30..f746b47d 100644 --- a/src/main/java/org/ldk/structs/BestBlock.java +++ b/src/main/java/org/ldk/structs/BestBlock.java @@ -4,6 +4,8 @@ import org.ldk.impl.bindings; import org.ldk.enums.*; import org.ldk.util.*; import java.util.Arrays; +import java.lang.ref.Reference; +import javax.annotation.Nullable; /** @@ -18,12 +20,20 @@ public class BestBlock extends CommonBase { if (ptr != 0) { bindings.BestBlock_free(ptr); } } + long clone_ptr() { + long ret = bindings.BestBlock_clone_ptr(this.ptr); + Reference.reachabilityFence(this); + return ret; + } + /** * Creates a copy of the BestBlock */ public BestBlock clone() { long ret = bindings.BestBlock_clone(this.ptr); - BestBlock ret_hu_conv = new BestBlock(null, ret); + Reference.reachabilityFence(this); + if (ret >= 0 && ret <= 4096) { return null; } + BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); } ret_hu_conv.ptrs_to.add(this); return ret_hu_conv; } @@ -32,9 +42,11 @@ public class BestBlock extends CommonBase { * Constructs a `BestBlock` that represents the genesis block at height 0 of the given * network. */ - public static BestBlock from_genesis(Network network) { + public static BestBlock from_genesis(org.ldk.enums.Network network) { long ret = bindings.BestBlock_from_genesis(network); - BestBlock ret_hu_conv = new BestBlock(null, ret); + Reference.reachabilityFence(network); + if (ret >= 0 && ret <= 4096) { return null; } + BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); } ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; } @@ -43,8 +55,11 @@ public class BestBlock extends CommonBase { * Returns a `BestBlock` as identified by the given block hash and height. */ public static BestBlock of(byte[] block_hash, int height) { - long ret = bindings.BestBlock_new(block_hash, height); - BestBlock ret_hu_conv = new BestBlock(null, ret); + long ret = bindings.BestBlock_new(InternalUtils.check_arr_len(block_hash, 32), height); + Reference.reachabilityFence(block_hash); + Reference.reachabilityFence(height); + if (ret >= 0 && ret <= 4096) { return null; } + BestBlock ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new BestBlock(null, ret); } ret_hu_conv.ptrs_to.add(ret_hu_conv); return ret_hu_conv; } @@ -54,6 +69,7 @@ public class BestBlock extends CommonBase { */ public byte[] block_hash() { byte[] ret = bindings.BestBlock_block_hash(this.ptr); + Reference.reachabilityFence(this); return ret; } @@ -62,6 +78,7 @@ public class BestBlock extends CommonBase { */ public int height() { int ret = bindings.BestBlock_height(this.ptr); + Reference.reachabilityFence(this); return ret; }