Update auto-generated bindings
[ldk-java] / src / main / java / org / ldk / structs / NetGraphMsgHandler.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 import javax.annotation.Nullable;
8
9
10 /**
11  * Receives and validates network updates from peers,
12  * stores authentic and relevant data as a network graph.
13  * This network graph is then used for routing payments.
14  * Provides interface to help with initial routing sync by
15  * serving historical announcements.
16  * 
17  * Serves as an [`EventHandler`] for applying updates from [`Event::PaymentPathFailed`] to the
18  * [`NetworkGraph`].
19  */
20 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
21 public class NetGraphMsgHandler extends CommonBase {
22         NetGraphMsgHandler(Object _dummy, long ptr) { super(ptr); }
23         @Override @SuppressWarnings("deprecation")
24         protected void finalize() throws Throwable {
25                 super.finalize();
26                 if (ptr != 0) { bindings.NetGraphMsgHandler_free(ptr); }
27         }
28
29         /**
30          * Constructs a new EventHandler which calls the relevant methods on this_arg.
31          * This copies the `inner` pointer in this_arg and thus the returned EventHandler must be freed before this_arg is
32          */
33         public EventHandler as_EventHandler() {
34                 long ret = bindings.NetGraphMsgHandler_as_EventHandler(this.ptr);
35                 if (ret < 1024) { return null; }
36                 EventHandler ret_hu_conv = new EventHandler(null, ret);
37                 ret_hu_conv.ptrs_to.add(this);
38                 return ret_hu_conv;
39         }
40
41         /**
42          * Representation of the payment channel network
43          */
44         public NetworkGraph get_network_graph() {
45                 long ret = bindings.NetGraphMsgHandler_get_network_graph(this.ptr);
46                 if (ret < 1024) { return null; }
47                 NetworkGraph ret_hu_conv = new NetworkGraph(null, ret);
48                 ret_hu_conv.ptrs_to.add(this);
49                 return ret_hu_conv;
50         }
51
52         /**
53          * Representation of the payment channel network
54          */
55         public void set_network_graph(NetworkGraph val) {
56                 bindings.NetGraphMsgHandler_set_network_graph(this.ptr, val == null ? 0 : val.ptr & ~1);
57                 this.ptrs_to.add(val);
58         }
59
60         /**
61          * Creates a new tracker of the actual state of the network of channels and nodes,
62          * assuming an existing Network Graph.
63          * Chain monitor is used to make sure announced channels exist on-chain,
64          * channel data is correct, and that the announcement is signed with
65          * channel owners' keys.
66          */
67         public static NetGraphMsgHandler of(NetworkGraph network_graph, Option_AccessZ chain_access, Logger logger) {
68                 long ret = bindings.NetGraphMsgHandler_new(network_graph == null ? 0 : network_graph.ptr & ~1, chain_access.ptr, logger == null ? 0 : logger.ptr);
69                 if (ret < 1024) { return null; }
70                 NetGraphMsgHandler ret_hu_conv = new NetGraphMsgHandler(null, ret);
71                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
72                 ret_hu_conv.ptrs_to.add(network_graph);
73                 ret_hu_conv.ptrs_to.add(logger);
74                 return ret_hu_conv;
75         }
76
77         /**
78          * Adds a provider used to check new announcements. Does not affect
79          * existing announcements unless they are updated.
80          * Add, update or remove the provider would replace the current one.
81          */
82         public void add_chain_access(Option_AccessZ chain_access) {
83                 bindings.NetGraphMsgHandler_add_chain_access(this.ptr, chain_access.ptr);
84         }
85
86         /**
87          * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg.
88          * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is
89          */
90         public RoutingMessageHandler as_RoutingMessageHandler() {
91                 long ret = bindings.NetGraphMsgHandler_as_RoutingMessageHandler(this.ptr);
92                 if (ret < 1024) { return null; }
93                 RoutingMessageHandler ret_hu_conv = new RoutingMessageHandler(null, ret);
94                 ret_hu_conv.ptrs_to.add(this);
95                 return ret_hu_conv;
96         }
97
98         /**
99          * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
100          * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
101          */
102         public MessageSendEventsProvider as_MessageSendEventsProvider() {
103                 long ret = bindings.NetGraphMsgHandler_as_MessageSendEventsProvider(this.ptr);
104                 if (ret < 1024) { return null; }
105                 MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret);
106                 ret_hu_conv.ptrs_to.add(this);
107                 return ret_hu_conv;
108         }
109
110 }