lightningdevkit
Version:
Lightning Development Kit
53 lines • 2.16 kB
JavaScript
import { Result_CVec_C3Tuple_StrStrStrZZIOErrorZ } from '../structs/Result_CVec_C3Tuple_StrStrStrZZIOErrorZ.mjs';
import { KVStore } from '../structs/KVStore.mjs';
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
class LDKMigratableKVStoreHolder {
constructor() {
this.held = null;
}
}
/**
* Provides additional interface methods that are required for [`KVStore`]-to-[`KVStore`]
* data migration.
*/
export class MigratableKVStore extends CommonBase {
/* @internal */
constructor(_dummy, ptr) {
super(ptr, bindings.MigratableKVStore_free);
this.bindings_instance = null;
}
/** Creates a new instance of MigratableKVStore from a given implementation */
static new_impl(arg, kVStore_impl) {
const impl_holder = new LDKMigratableKVStoreHolder();
let structImplementation = {
list_all_keys() {
const ret = arg.list_all_keys();
const result = ret.clone_ptr();
return result;
},
};
const kVStore = KVStore.new_impl(kVStore_impl);
const ptr_idx = bindings.LDKMigratableKVStore_new(structImplementation, kVStore.instance_idx);
impl_holder.held = new MigratableKVStore(null, ptr_idx[0]);
impl_holder.held.instance_idx = ptr_idx[1];
impl_holder.held.bindings_instance = structImplementation;
impl_holder.held.ptrs_to.push(kVStore);
return impl_holder.held;
}
/**
* Returns *all* known keys as a list of `primary_namespace`, `secondary_namespace`, `key` tuples.
*
* This is useful for migrating data from [`KVStore`] implementation to [`KVStore`]
* implementation.
*
* Must exhaustively return all entries known to the store to ensure no data is missed, but
* may return the items in arbitrary order.
*/
list_all_keys() {
const ret = bindings.MigratableKVStore_list_all_keys(this.ptr);
const ret_hu_conv = Result_CVec_C3Tuple_StrStrStrZZIOErrorZ.constr_from_ptr(ret);
return ret_hu_conv;
}
}
//# sourceMappingURL=MigratableKVStore.mjs.map