X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fldk%2Fstructs%2FPersister.java;h=96f93b56e9115a1bb5efd3174a8beb912e3b9c05;hb=890e35a4387758c0447aab34166caa579bbf3a08;hp=059d1c7489de9676632d33452baf1ee407e7e437;hpb=2a8741cb87eb2b82381a6220a98f80f741147837;p=ldk-java diff --git a/src/main/java/org/ldk/structs/Persister.java b/src/main/java/org/ldk/structs/Persister.java index 059d1c74..96f93b56 100644 --- a/src/main/java/org/ldk/structs/Persister.java +++ b/src/main/java/org/ldk/structs/Persister.java @@ -8,7 +8,7 @@ import java.lang.ref.Reference; import javax.annotation.Nullable; /** - * Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`MultiThreadedLockableScore`] to disk. + * Trait that handles persisting a [`ChannelManager`], [`NetworkGraph`], and [`WriteableScore`] to disk. */ @SuppressWarnings("unchecked") // We correctly assign various generic arrays public class Persister extends CommonBase { @@ -34,9 +34,9 @@ public class Persister extends CommonBase { */ Result_NoneErrorZ persist_graph(NetworkGraph network_graph); /** - * Persist the given [`MultiThreadedLockableScore`] to disk, returning an error if persistence failed. + * Persist the given [`WriteableScore`] to disk, returning an error if persistence failed. */ - Result_NoneErrorZ persist_scorer(MultiThreadedLockableScore scorer); + Result_NoneErrorZ persist_scorer(WriteableScore scorer); } private static class LDKPersisterHolder { Persister held; } public static Persister new_impl(PersisterInterface arg) { @@ -57,8 +57,9 @@ public class Persister extends CommonBase { return result; } @Override public long persist_scorer(long scorer) { - org.ldk.structs.MultiThreadedLockableScore scorer_hu_conv = null; if (scorer < 0 || scorer > 4096) { scorer_hu_conv = new org.ldk.structs.MultiThreadedLockableScore(null, scorer); } - Result_NoneErrorZ ret = arg.persist_scorer(scorer_hu_conv); + WriteableScore ret_hu_conv = new WriteableScore(null, scorer); + if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.add(this); }; + Result_NoneErrorZ ret = arg.persist_scorer(ret_hu_conv); Reference.reachabilityFence(arg); long result = ret == null ? 0 : ret.clone_ptr(); return result; @@ -70,12 +71,12 @@ public class Persister extends CommonBase { * Persist the given ['ChannelManager'] to disk, returning an error if persistence failed. */ public Result_NoneErrorZ persist_manager(ChannelManager channel_manager) { - long ret = bindings.Persister_persist_manager(this.ptr, channel_manager == null ? 0 : channel_manager.ptr & ~1); + long ret = bindings.Persister_persist_manager(this.ptr, channel_manager == null ? 0 : channel_manager.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(channel_manager); if (ret >= 0 && ret <= 4096) { return null; } Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret); - this.ptrs_to.add(channel_manager); + if (this != null) { this.ptrs_to.add(channel_manager); }; return ret_hu_conv; } @@ -83,25 +84,25 @@ public class Persister extends CommonBase { * Persist the given [`NetworkGraph`] to disk, returning an error if persistence failed. */ public Result_NoneErrorZ persist_graph(NetworkGraph network_graph) { - long ret = bindings.Persister_persist_graph(this.ptr, network_graph == null ? 0 : network_graph.ptr & ~1); + long ret = bindings.Persister_persist_graph(this.ptr, network_graph == null ? 0 : network_graph.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(network_graph); if (ret >= 0 && ret <= 4096) { return null; } Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret); - this.ptrs_to.add(network_graph); + if (this != null) { this.ptrs_to.add(network_graph); }; return ret_hu_conv; } /** - * Persist the given [`MultiThreadedLockableScore`] to disk, returning an error if persistence failed. + * Persist the given [`WriteableScore`] to disk, returning an error if persistence failed. */ - public Result_NoneErrorZ persist_scorer(MultiThreadedLockableScore scorer) { - long ret = bindings.Persister_persist_scorer(this.ptr, scorer == null ? 0 : scorer.ptr & ~1); + public Result_NoneErrorZ persist_scorer(WriteableScore scorer) { + long ret = bindings.Persister_persist_scorer(this.ptr, scorer == null ? 0 : scorer.ptr); Reference.reachabilityFence(this); Reference.reachabilityFence(scorer); if (ret >= 0 && ret <= 4096) { return null; } Result_NoneErrorZ ret_hu_conv = Result_NoneErrorZ.constr_from_ptr(ret); - this.ptrs_to.add(scorer); + if (this != null) { this.ptrs_to.add(scorer); }; return ret_hu_conv; }