X-Git-Url: http://git.bitcoin.ninja/index.cgi?p=ldk-java;a=blobdiff_plain;f=ts%2Fstructs%2FNetGraphMsgHandler.mts;h=e5fff47eef13ab0b07055dbe55416d6cd7a56f7b;hp=5ca801b6097478b344028bf38e26c3d919bb45bc;hb=c629a01650402c8e2f9b9db8ced9ed63ce687727;hpb=d1d0121c000b713c10fd0bedd249eb8dda2e4db7 diff --git a/ts/structs/NetGraphMsgHandler.mts b/ts/structs/NetGraphMsgHandler.mts index 5ca801b6..e5fff47e 100644 --- a/ts/structs/NetGraphMsgHandler.mts +++ b/ts/structs/NetGraphMsgHandler.mts @@ -281,12 +281,26 @@ import CommonBase from './CommonBase.mjs'; import * as bindings from '../bindings.mjs' +/** + * Receives and validates network updates from peers, + * stores authentic and relevant data as a network graph. + * This network graph is then used for routing payments. + * Provides interface to help with initial routing sync by + * serving historical announcements. + * + * Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the + * [`NetworkGraph`]. + */ export class NetGraphMsgHandler extends CommonBase { /* @internal */ public constructor(_dummy: object, ptr: number) { super(ptr, bindings.NetGraphMsgHandler_free); } + /** + * Constructs a new EventHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned EventHandler must be freed before this_arg is + */ public as_EventHandler(): EventHandler { const ret: number = bindings.NetGraphMsgHandler_as_EventHandler(this.ptr); const ret_hu_conv: EventHandler = new EventHandler(null, ret); @@ -294,6 +308,13 @@ export class NetGraphMsgHandler extends CommonBase { return ret_hu_conv; } + /** + * Creates a new tracker of the actual state of the network of channels and nodes, + * assuming an existing Network Graph. + * Chain monitor is used to make sure announced channels exist on-chain, + * channel data is correct, and that the announcement is signed with + * channel owners' keys. + */ public static constructor_new(network_graph: NetworkGraph, chain_access: Option_AccessZ, logger: Logger): NetGraphMsgHandler { const ret: number = bindings.NetGraphMsgHandler_new(network_graph == null ? 0 : CommonBase.get_ptr_of(network_graph) & ~1, CommonBase.get_ptr_of(chain_access), logger == null ? 0 : CommonBase.get_ptr_of(logger)); const ret_hu_conv: NetGraphMsgHandler = new NetGraphMsgHandler(null, ret); @@ -304,11 +325,20 @@ export class NetGraphMsgHandler extends CommonBase { return ret_hu_conv; } + /** + * Adds a provider used to check new announcements. Does not affect + * existing announcements unless they are updated. + * Add, update or remove the provider would replace the current one. + */ public add_chain_access(chain_access: Option_AccessZ): void { bindings.NetGraphMsgHandler_add_chain_access(this.ptr, CommonBase.get_ptr_of(chain_access)); CommonBase.add_ref_from(this, chain_access); } + /** + * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is + */ public as_RoutingMessageHandler(): RoutingMessageHandler { const ret: number = bindings.NetGraphMsgHandler_as_RoutingMessageHandler(this.ptr); const ret_hu_conv: RoutingMessageHandler = new RoutingMessageHandler(null, ret); @@ -316,6 +346,10 @@ export class NetGraphMsgHandler extends CommonBase { return ret_hu_conv; } + /** + * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg. + * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is + */ public as_MessageSendEventsProvider(): MessageSendEventsProvider { const ret: number = bindings.NetGraphMsgHandler_as_MessageSendEventsProvider(this.ptr); const ret_hu_conv: MessageSendEventsProvider = new MessageSendEventsProvider(null, ret);