]> git.bitcoin.ninja Git - ldk-java/blob - ts/structs/PeerManager.ts
bindings updates
[ldk-java] / ts / structs / PeerManager.ts
1
2             
3 import CommonBase from './CommonBase';
4 import * as bindings from '../bindings' // TODO: figure out location
5
6
7
8             export default class PeerManager extends CommonBase {
9                 constructor(_dummy: object, ptr: number) {
10                     super(ptr);
11                 }
12
13                 
14                 protected finalize() {
15                     super.finalize();
16
17                     if (this.ptr != 0) {
18                         bindings.PeerManager_free(this.ptr);
19                     }
20                 }
21         public static PeerManager constructor_new(ChannelMessageHandler message_handler_chan_handler_arg, RoutingMessageHandler message_handler_route_handler_arg, Uint8Array our_node_secret, Uint8Array ephemeral_random_data, Logger logger) {
22                 number 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);
23                 const ret_hu_conv: PeerManager = new PeerManager(null, ret);
24                 ret_hu_conv.ptrs_to.add(ret_hu_conv);
25                 ret_hu_conv.ptrs_to.add(message_handler_chan_handler_arg);
26                 ret_hu_conv.ptrs_to.add(message_handler_route_handler_arg);
27                 ret_hu_conv.ptrs_to.add(logger);
28                 return ret_hu_conv;
29         }
30
31         public Uint8Array[] get_peer_node_ids() {
32                 Uint8Array[] ret = bindings.PeerManager_get_peer_node_ids(this.ptr);
33                 return ret;
34         }
35
36         public Result_CVec_u8ZPeerHandleErrorZ new_outbound_connection(Uint8Array their_node_id, SocketDescriptor descriptor) {
37                 number ret = bindings.PeerManager_new_outbound_connection(this.ptr, their_node_id, descriptor == null ? 0 : descriptor.ptr);
38                 Result_CVec_u8ZPeerHandleErrorZ ret_hu_conv = Result_CVec_u8ZPeerHandleErrorZ.constr_from_ptr(ret);
39                 this.ptrs_to.add(descriptor);
40                 return ret_hu_conv;
41         }
42
43         public Result_NonePeerHandleErrorZ new_inbound_connection(SocketDescriptor descriptor) {
44                 number ret = bindings.PeerManager_new_inbound_connection(this.ptr, descriptor == null ? 0 : descriptor.ptr);
45                 Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
46                 this.ptrs_to.add(descriptor);
47                 return ret_hu_conv;
48         }
49
50         public Result_NonePeerHandleErrorZ write_buffer_space_avail(SocketDescriptor descriptor) {
51                 number ret = bindings.PeerManager_write_buffer_space_avail(this.ptr, descriptor == null ? 0 : descriptor.ptr);
52                 Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
53                 this.ptrs_to.add(descriptor);
54                 return ret_hu_conv;
55         }
56
57         public Result_boolPeerHandleErrorZ read_event(SocketDescriptor peer_descriptor, Uint8Array data) {
58                 number ret = bindings.PeerManager_read_event(this.ptr, peer_descriptor == null ? 0 : peer_descriptor.ptr, data);
59                 Result_boolPeerHandleErrorZ ret_hu_conv = Result_boolPeerHandleErrorZ.constr_from_ptr(ret);
60                 this.ptrs_to.add(peer_descriptor);
61                 return ret_hu_conv;
62         }
63
64         public void process_events() {
65                 bindings.PeerManager_process_events(this.ptr);
66         }
67
68         public void socket_disconnected(SocketDescriptor descriptor) {
69                 bindings.PeerManager_socket_disconnected(this.ptr, descriptor == null ? 0 : descriptor.ptr);
70                 this.ptrs_to.add(descriptor);
71         }
72
73         public void disconnect_by_node_id(Uint8Array node_id, boolean no_connection_possible) {
74                 bindings.PeerManager_disconnect_by_node_id(this.ptr, node_id, no_connection_possible);
75         }
76
77         public void timer_tick_occured() {
78                 bindings.PeerManager_timer_tick_occured(this.ptr);
79         }
80
81 }