7 namespace org { namespace ldk { namespace structs {
11 /** An implementation of WriteableScore */
12 public interface WriteableScoreInterface {
13 /**Serialize the object into a byte array
19 * Refers to a scorer that is accessible under lock and also writeable to disk
21 * We need this trait to be able to pass in a scorer to `lightning-background-processor` that will enable us to
22 * use the Persister to persist it.
24 public class WriteableScore : CommonBase {
25 internal bindings.LDKWriteableScore bindings_instance;
26 internal long instance_idx;
28 internal WriteableScore(object _dummy, long ptr) : base(ptr) { bindings_instance = null; }
30 if (ptr != 0) { bindings.WriteableScore_free(ptr); }
33 private class LDKWriteableScoreHolder { internal WriteableScore held; }
34 private class LDKWriteableScoreImpl : bindings.LDKWriteableScore {
35 internal LDKWriteableScoreImpl(WriteableScoreInterface arg, LDKWriteableScoreHolder impl_holder) { this.arg = arg; this.impl_holder = impl_holder; }
36 private WriteableScoreInterface arg;
37 private LDKWriteableScoreHolder impl_holder;
39 byte[] ret = arg.write();
41 long result = InternalUtils.encodeUint8Array(ret);
46 /** Creates a new instance of WriteableScore from a given implementation */
47 public static WriteableScore new_impl(WriteableScoreInterface arg, LockableScoreInterface lockableScore_impl) {
48 LDKWriteableScoreHolder impl_holder = new LDKWriteableScoreHolder();
49 LDKWriteableScoreImpl impl = new LDKWriteableScoreImpl(arg, impl_holder);
50 LockableScore lockableScore = LockableScore.new_impl(lockableScore_impl);
51 long[] ptr_idx = bindings.LDKWriteableScore_new(impl, lockableScore.instance_idx);
53 impl_holder.held = new WriteableScore(null, ptr_idx[0]);
54 impl_holder.held.instance_idx = ptr_idx[1];
55 impl_holder.held.bindings_instance = impl;
56 impl_holder.held.ptrs_to.AddLast(lockableScore);
57 return impl_holder.held;
61 * Serialize the object into a byte array
63 public byte[] write() {
64 long ret = bindings.WriteableScore_write(this.ptr);
66 if (ret >= 0 && ret <= 4096) { return null; }
67 byte[] ret_conv = InternalUtils.decodeUint8Array(ret);