1 package org.ldk.structs;
3 import org.ldk.impl.bindings;
4 import org.ldk.enums.*;
6 import java.util.Arrays;
8 @SuppressWarnings("unchecked") // We correctly assign various generic arrays
9 public class PeerManager extends CommonBase {
10 PeerManager(Object _dummy, long ptr) { super(ptr); }
11 @Override @SuppressWarnings("deprecation")
12 protected void finalize() throws Throwable {
14 if (ptr != 0) { bindings.PeerManager_free(ptr); }
17 public static PeerManager constructor_new(ChannelMessageHandler message_handler_chan_handler_arg, RoutingMessageHandler message_handler_route_handler_arg, byte[] our_node_secret, byte[] ephemeral_random_data, Logger logger) {
18 long ret = bindings.PeerManager_new(bindings.MessageHandler_new(message_handler_chan_handler_arg == null ? 0 : message_handler_chan_handler_arg.ptr, message_handler_route_handler_arg == null ? 0 : message_handler_route_handler_arg.ptr), our_node_secret, ephemeral_random_data, logger == null ? 0 : logger.ptr);
19 PeerManager ret_hu_conv = new PeerManager(null, ret);
20 ret_hu_conv.ptrs_to.add(message_handler_chan_handler_arg);
21 ret_hu_conv.ptrs_to.add(message_handler_route_handler_arg);
22 ret_hu_conv.ptrs_to.add(logger);
26 public byte[][] get_peer_node_ids() {
27 byte[][] ret = bindings.PeerManager_get_peer_node_ids(this.ptr);
31 public Result_CVec_u8ZPeerHandleErrorZ new_outbound_connection(byte[] their_node_id, SocketDescriptor descriptor) {
32 long ret = bindings.PeerManager_new_outbound_connection(this.ptr, their_node_id, descriptor == null ? 0 : descriptor.ptr);
33 Result_CVec_u8ZPeerHandleErrorZ ret_hu_conv = Result_CVec_u8ZPeerHandleErrorZ.constr_from_ptr(ret);
34 ret_hu_conv.ptrs_to.add(this);
35 this.ptrs_to.add(descriptor);
39 public Result_NonePeerHandleErrorZ new_inbound_connection(SocketDescriptor descriptor) {
40 long ret = bindings.PeerManager_new_inbound_connection(this.ptr, descriptor == null ? 0 : descriptor.ptr);
41 Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
42 ret_hu_conv.ptrs_to.add(this);
43 this.ptrs_to.add(descriptor);
47 public Result_NonePeerHandleErrorZ write_buffer_space_avail(SocketDescriptor descriptor) {
48 long ret = bindings.PeerManager_write_buffer_space_avail(this.ptr, descriptor == null ? 0 : descriptor.ptr);
49 Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
50 ret_hu_conv.ptrs_to.add(this);
51 this.ptrs_to.add(descriptor);
55 public Result_boolPeerHandleErrorZ read_event(SocketDescriptor peer_descriptor, byte[] data) {
56 long ret = bindings.PeerManager_read_event(this.ptr, peer_descriptor == null ? 0 : peer_descriptor.ptr, data);
57 Result_boolPeerHandleErrorZ ret_hu_conv = Result_boolPeerHandleErrorZ.constr_from_ptr(ret);
58 ret_hu_conv.ptrs_to.add(this);
59 this.ptrs_to.add(peer_descriptor);
63 public void process_events() {
64 bindings.PeerManager_process_events(this.ptr);
67 public void socket_disconnected(SocketDescriptor descriptor) {
68 bindings.PeerManager_socket_disconnected(this.ptr, descriptor == null ? 0 : descriptor.ptr);
69 this.ptrs_to.add(descriptor);
72 public void timer_tick_occured() {
73 bindings.PeerManager_timer_tick_occured(this.ptr);