6 namespace org { namespace ldk { namespace structs {
10 * FilesystemPersister persists channel data on disk, where each channel's
11 * data is stored in a file named after its funding outpoint.
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
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.
23 public class FilesystemPersister : CommonBase {
24 internal FilesystemPersister(object _dummy, long ptr) : base(ptr) { }
25 ~FilesystemPersister() {
26 if (ptr != 0) { bindings.FilesystemPersister_free(ptr); }
30 * Initialize a new FilesystemPersister and set the path to the individual channels'
33 public static FilesystemPersister of(string path_to_channel_data) {
34 long ret = bindings.FilesystemPersister_new(path_to_channel_data);
35 GC.KeepAlive(path_to_channel_data);
36 if (ret >= 0 && ret <= 4096) { return null; }
37 org.ldk.structs.FilesystemPersister ret_hu_conv = null; if (ret < 0 || ret > 4096) { ret_hu_conv = new org.ldk.structs.FilesystemPersister(null, ret); }
38 if (ret_hu_conv != null) { ret_hu_conv.ptrs_to.AddLast(ret_hu_conv); };
43 * Get the directory which was provided when this persister was initialized.
45 public string get_data_dir() {
46 string ret = bindings.FilesystemPersister_get_data_dir(this.ptr);
52 * Read `ChannelMonitor`s from disk.
54 public Result_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ read_channelmonitors(org.ldk.structs.KeysInterface keys_manager) {
55 long ret = bindings.FilesystemPersister_read_channelmonitors(this.ptr, keys_manager == null ? 0 : keys_manager.ptr);
57 GC.KeepAlive(keys_manager);
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 if (this != null) { this.ptrs_to.AddLast(keys_manager); };