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
8
9 /**
10  * Receives and validates network updates from peers,
11  * stores authentic and relevant data as a network graph.
12  * This network graph is then used for routing payments.
13  * Provides interface to help with initial routing sync by
14  * serving historical announcements.
15  */
16 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
17 public class NetGraphMsgHandler extends CommonBase {
18         NetGraphMsgHandler(Object _dummy, long ptr) { super(ptr); }
19         @Override @SuppressWarnings("deprecation")
20         protected void finalize() throws Throwable {
21                 super.finalize();
22                 if (ptr != 0) { bindings.NetGraphMsgHandler_free(ptr); }
23         }
24
25         /**
26          * Creates a new tracker of the actual state of the network of channels and nodes,
27          * assuming a fresh network graph.
28          * Chain monitor is used to make sure announced channels exist on-chain,
29          * channel data is correct, and that the announcement is signed with
30          * channel owners' keys.
31          */
32         public static NetGraphMsgHandler of(byte[] genesis_hash, Access chain_access, Logger logger) {
33                 long ret = bindings.NetGraphMsgHandler_new(genesis_hash, chain_access == null ? 0 : chain_access.ptr, logger == null ? 0 : logger.ptr);
34                 NetGraphMsgHandler ret_hu_conv = new NetGraphMsgHandler(null, ret);
35                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
36                 ret_hu_conv.ptrs_to.add(chain_access);
37                 ret_hu_conv.ptrs_to.add(logger);
38                 return ret_hu_conv;
39         }
40
41         /**
42          * Creates a new tracker of the actual state of the network of channels and nodes,
43          * assuming an existing Network Graph.
44          */
45         public static NetGraphMsgHandler from_net_graph(Access chain_access, Logger logger, NetworkGraph network_graph) {
46                 long ret = bindings.NetGraphMsgHandler_from_net_graph(chain_access == null ? 0 : chain_access.ptr, logger == null ? 0 : logger.ptr, network_graph == null ? 0 : network_graph.ptr & ~1);
47                 NetGraphMsgHandler ret_hu_conv = new NetGraphMsgHandler(null, ret);
48                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
49                 ret_hu_conv.ptrs_to.add(chain_access);
50                 ret_hu_conv.ptrs_to.add(logger);
51                 ret_hu_conv.ptrs_to.add(network_graph);
52                 return ret_hu_conv;
53         }
54
55         /**
56          * Adds a provider used to check new announcements. Does not affect
57          * existing announcements unless they are updated.
58          * Add, update or remove the provider would replace the current one.
59          */
60         public void add_chain_access(Access chain_access) {
61                 bindings.NetGraphMsgHandler_add_chain_access(this.ptr, chain_access == null ? 0 : chain_access.ptr);
62                 this.ptrs_to.add(chain_access);
63         }
64
65         /**
66          * Take a read lock on the network_graph and return it in the C-bindings
67          * newtype helper. This is likely only useful when called via the C
68          * bindings as you can call `self.network_graph.read().unwrap()` in Rust
69          * yourself.
70          */
71         public LockedNetworkGraph read_locked_graph() {
72                 long ret = bindings.NetGraphMsgHandler_read_locked_graph(this.ptr);
73                 LockedNetworkGraph ret_hu_conv = new LockedNetworkGraph(null, ret);
74                 ret_hu_conv.ptrs_to.add(this);
75                 return ret_hu_conv;
76         }
77
78         /**
79          * Constructs a new RoutingMessageHandler which calls the relevant methods on this_arg.
80          * This copies the `inner` pointer in this_arg and thus the returned RoutingMessageHandler must be freed before this_arg is
81          */
82         public RoutingMessageHandler as_RoutingMessageHandler() {
83                 long ret = bindings.NetGraphMsgHandler_as_RoutingMessageHandler(this.ptr);
84                 RoutingMessageHandler ret_hu_conv = new RoutingMessageHandler(null, ret);
85                 ret_hu_conv.ptrs_to.add(this);
86                 return ret_hu_conv;
87         }
88
89         /**
90          * Constructs a new MessageSendEventsProvider which calls the relevant methods on this_arg.
91          * This copies the `inner` pointer in this_arg and thus the returned MessageSendEventsProvider must be freed before this_arg is
92          */
93         public MessageSendEventsProvider as_MessageSendEventsProvider() {
94                 long ret = bindings.NetGraphMsgHandler_as_MessageSendEventsProvider(this.ptr);
95                 MessageSendEventsProvider ret_hu_conv = new MessageSendEventsProvider(null, ret);
96                 ret_hu_conv.ptrs_to.add(this);
97                 return ret_hu_conv;
98         }
99
100 }