lightningdevkit
Version:
Lightning Development Kit
80 lines • 2.92 kB
JavaScript
import { P2PGossipSync } from '../structs/P2PGossipSync.mjs';
import { RapidGossipSync } from '../structs/RapidGossipSync.mjs';
import { CommonBase } from './CommonBase.mjs';
import * as bindings from '../bindings.mjs';
/**
* Either [`P2PGossipSync`] or [`RapidGossipSync`].
*/
export class GossipSync extends CommonBase {
constructor(_dummy, ptr) { super(ptr, bindings.GossipSync_free); }
/* @internal */
static constr_from_ptr(ptr) {
const raw_ty = bindings.LDKGossipSync_ty_from_ptr(ptr);
switch (raw_ty) {
case 0: return new GossipSync_P2P(ptr);
case 1: return new GossipSync_Rapid(ptr);
case 2: return new GossipSync_None(ptr);
default:
throw new Error('oops, this should be unreachable'); // Unreachable without extending the (internal) bindings interface
}
}
/**
* Utility method to constructs a new P2P-variant GossipSync
*/
static constructor_p2_p(a) {
const ret = bindings.GossipSync_p2_p(CommonBase.get_ptr_of(a));
const ret_hu_conv = GossipSync.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
CommonBase.add_ref_from(ret_hu_conv, a);
return ret_hu_conv;
}
/**
* Utility method to constructs a new Rapid-variant GossipSync
*/
static constructor_rapid(a) {
const ret = bindings.GossipSync_rapid(CommonBase.get_ptr_of(a));
const ret_hu_conv = GossipSync.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
CommonBase.add_ref_from(ret_hu_conv, a);
return ret_hu_conv;
}
/**
* Utility method to constructs a new None-variant GossipSync
*/
static constructor_none() {
const ret = bindings.GossipSync_none();
const ret_hu_conv = GossipSync.constr_from_ptr(ret);
CommonBase.add_ref_from(ret_hu_conv, ret_hu_conv);
return ret_hu_conv;
}
}
/** A GossipSync of type P2P */
export class GossipSync_P2P extends GossipSync {
/* @internal */
constructor(ptr) {
super(null, ptr);
const p2p = bindings.LDKGossipSync_P2P_get_p2p(ptr);
const p2p_hu_conv = new P2PGossipSync(null, p2p);
CommonBase.add_ref_from(p2p_hu_conv, this);
this.p2p = p2p_hu_conv;
}
}
/** A GossipSync of type Rapid */
export class GossipSync_Rapid extends GossipSync {
/* @internal */
constructor(ptr) {
super(null, ptr);
const rapid = bindings.LDKGossipSync_Rapid_get_rapid(ptr);
const rapid_hu_conv = new RapidGossipSync(null, rapid);
CommonBase.add_ref_from(rapid_hu_conv, this);
this.rapid = rapid_hu_conv;
}
}
/** A GossipSync of type None */
export class GossipSync_None extends GossipSync {
/* @internal */
constructor(ptr) {
super(null, ptr);
}
}
//# sourceMappingURL=GossipSync.mjs.map