Update auto-generated bindings to 0.0.101
[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(byte[] val_genesis_hash) {
56                 bindings.NetGraphMsgHandler_set_network_graph(this.ptr, bindings.NetworkGraph_new(val_genesis_hash));
57         }
58
59         /**
60          * Creates a new tracker of the actual state of the network of channels and nodes,
61          * assuming an existing Network Graph.
62          * Chain monitor is used to make sure announced channels exist on-chain,
63          * channel data is correct, and that the announcement is signed with
64          * channel owners' keys.
65          */
66         public static NetGraphMsgHandler of(byte[] network_graph_genesis_hash, Option_AccessZ chain_access, Logger logger) {
67                 long ret = bindings.NetGraphMsgHandler_new(bindings.NetworkGraph_new(network_graph_genesis_hash), chain_access.ptr, logger == null ? 0 : logger.ptr);
68                 if (ret < 1024) { return null; }
69                 NetGraphMsgHandler ret_hu_conv = new NetGraphMsgHandler(null, ret);
70                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
71                 ret_hu_conv.ptrs_to.add(logger);
72                 return ret_hu_conv;
73         }
74
75         /**
76          * Adds a provider used to check new announcements. Does not affect
77          * existing announcements unless they are updated.
78          * Add, update or remove the provider would replace the current one.
79          */
80         public void add_chain_access(Option_AccessZ chain_access) {
81                 bindings.NetGraphMsgHandler_add_chain_access(this.ptr, chain_access.ptr);
82         }
83
84         /**
85          * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg.
86          * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is
87          */
88         public RoutingMessageHandler as_RoutingMessageHandler() {
89                 long ret = bindings.NetGraphMsgHandler_as_RoutingMessageHandler(this.ptr);
90                 if (ret < 1024) { return null; }
91                 RoutingMessageHandler ret_hu_conv = new RoutingMessageHandler(null, ret);
92                 ret_hu_conv.ptrs_to.add(this);
93                 return ret_hu_conv;
94         }
95
96         /**
97          * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
98          * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
99          */
100         public MessageSendEventsProvider as_MessageSendEventsProvider() {
101                 long ret = bindings.NetGraphMsgHandler_as_MessageSendEventsProvider(this.ptr);
102                 if (ret < 1024) { return null; }
103                 MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret);
104                 ret_hu_conv.ptrs_to.add(this);
105                 return ret_hu_conv;
106         }
107
108 }