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