Update auto-generated bindings to 0.0.103
[ldk-java] / src / main / java / org / ldk / structs / FilesystemPersister.java
1 package org.ldk.structs;
2
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
5 import org.ldk.util.*;
6 import java.util.Arrays;
7 import javax.annotation.Nullable;
8
9
10 /**
11  * FilesystemPersister persists channel data on disk, where each channel's
12  * data is stored in a file named after its funding outpoint.
13  * 
14  * Warning: this module does the best it can with calls to persist data, but it
15  * can only guarantee that the data is passed to the drive. It is up to the
16  * drive manufacturers to do the actual persistence properly, which they often
17  * don't (especially on consumer-grade hardware). Therefore, it is up to the
18  * user to validate their entire storage stack, to ensure the writes are
19  * persistent.
20  * Corollary: especially when dealing with larger amounts of money, it is best
21  * practice to have multiple channel data backups and not rely only on one
22  * FilesystemPersister.
23  */
24 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
25 public class FilesystemPersister extends CommonBase {
26         FilesystemPersister(Object _dummy, long ptr) { super(ptr); }
27         @Override @SuppressWarnings("deprecation")
28         protected void finalize() throws Throwable {
29                 super.finalize();
30                 if (ptr != 0) { bindings.FilesystemPersister_free(ptr); }
31         }
32
33         /**
34          * Initialize a new FilesystemPersister and set the path to the individual channels'
35          * files.
36          */
37         public static FilesystemPersister of(java.lang.String path_to_channel_data) {
38                 long ret = bindings.FilesystemPersister_new(path_to_channel_data);
39                 if (ret >= 0 && ret <= 4096) { return null; }
40                 FilesystemPersister ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new FilesystemPersister(null, ret); }
41                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
42                 return ret_hu_conv;
43         }
44
45         /**
46          * Get the directory which was provided when this persister was initialized.
47          */
48         public String get_data_dir() {
49                 String ret = bindings.FilesystemPersister_get_data_dir(this.ptr);
50                 return ret;
51         }
52
53         /**
54          * Read `ChannelMonitor`s from disk.
55          */
56         public Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ read_channelmonitors(KeysInterface keys_manager) {
57                 long ret = bindings.FilesystemPersister_read_channelmonitors(this.ptr, keys_manager == null ? 0 : keys_manager.ptr);
58                 if (ret >= 0 && ret <= 4096) { return null; }
59                 Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ ret_hu_conv = Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ.constr_from_ptr(ret);
60                 this.ptrs_to.add(keys_manager);
61                 return ret_hu_conv;
62         }
63
64         /**
65          * Constructs a new Persist which calls the relevant methods on this_arg.
66          * This copies the `inner` pointer in this_arg and thus the returned Persist must be freed before this_arg is
67          */
68         public Persist as_Persist() {
69                 long ret = bindings.FilesystemPersister_as_Persist(this.ptr);
70                 if (ret >= 0 && ret <= 4096) { return null; }
71                 Persist ret_hu_conv = new Persist(null, ret);
72                 ret_hu_conv.ptrs_to.add(this);
73                 return ret_hu_conv;
74         }
75
76 }