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;
11 * Refers to a scorer that is accessible under lock and also writeable to disk
13 * We need this trait to be able to pass in a scorer to `lightning-background-processor` that will enable us to
14 * use the Persister to persist it.
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class WriteableScore extends CommonBase {
18 final bindings.LDKWriteableScore bindings_instance;
19 WriteableScore(Object _dummy, long ptr) { super(ptr); bindings_instance = null; }
20 private WriteableScore(bindings.LDKWriteableScore arg, bindings.LDKLockableScore LockableScore) {
21 super(bindings.LDKWriteableScore_new(arg, LockableScore));
22 this.ptrs_to.add(arg);
23 this.ptrs_to.add(LockableScore);
24 this.bindings_instance = arg;
26 @Override @SuppressWarnings("deprecation")
27 protected void finalize() throws Throwable {
28 if (ptr != 0) { bindings.WriteableScore_free(ptr); } super.finalize();
31 public static interface WriteableScoreInterface {
33 * Serialize the object into a byte array
37 private static class LDKWriteableScoreHolder { WriteableScore held; }
38 public static WriteableScore new_impl(WriteableScoreInterface arg, LockableScore.LockableScoreInterface LockableScore_impl) {
39 final LDKWriteableScoreHolder impl_holder = new LDKWriteableScoreHolder();
40 impl_holder.held = new WriteableScore(new bindings.LDKWriteableScore() {
41 @Override public byte[] write() {
42 byte[] ret = arg.write();
43 Reference.reachabilityFence(arg);
46 }, LockableScore.new_impl(LockableScore_impl).bindings_instance);
47 return impl_holder.held;
51 * Gets the underlying LockableScore.
53 public LockableScore get_lockable_score() {
54 LockableScore res = new LockableScore(null, bindings.LDKWriteableScore_get_LockableScore(this.ptr));
55 this.ptrs_to.add(res);
60 * Serialize the object into a byte array
62 public byte[] write() {
63 byte[] ret = bindings.WriteableScore_write(this.ptr);
64 Reference.reachabilityFence(this);