3 public class PeerManager {
5 public internal(set) var cOpaqueStruct: LDKPeerManager?;
7 /* DEFAULT_CONSTRUCTOR_START */
8 public init(message_handler: MessageHandler, our_node_secret: [UInt8], ephemeral_random_data: [UInt8], logger: Logger) {
10 self.cOpaqueStruct = withUnsafePointer(to: Bindings.array_to_tuple32(array: ephemeral_random_data)) { (ephemeral_random_dataPointer: UnsafePointer<(UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8,UInt8)>) in
11 PeerManager_new(message_handler.cOpaqueStruct!, Bindings.new_LDKSecretKey(array: our_node_secret), ephemeral_random_dataPointer, logger.cOpaqueStruct!)
14 /* DEFAULT_CONSTRUCTOR_END */
16 public init(pointer: LDKPeerManager){
17 self.cOpaqueStruct = pointer
20 /* STRUCT_METHODS_START */
22 public func get_peer_node_ids() -> [[UInt8]] {
24 return Bindings.LDKCVec_PublicKeyZ_to_array(nativeType: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKPeerManager>) in
25 PeerManager_get_peer_node_ids(this_argPointer)
29 public func new_outbound_connection(their_node_id: [UInt8], descriptor: SocketDescriptor) -> Result_CVec_u8ZPeerHandleErrorZ {
31 return Result_CVec_u8ZPeerHandleErrorZ(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKPeerManager>) in
32 PeerManager_new_outbound_connection(this_argPointer, Bindings.new_LDKPublicKey(array: their_node_id), descriptor.cOpaqueStruct!)
36 public func new_inbound_connection(descriptor: SocketDescriptor) -> Result_NonePeerHandleErrorZ {
38 return Result_NonePeerHandleErrorZ(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKPeerManager>) in
39 PeerManager_new_inbound_connection(this_argPointer, descriptor.cOpaqueStruct!)
43 public func write_buffer_space_avail(descriptor: SocketDescriptor) -> Result_NonePeerHandleErrorZ {
45 let descriptorPointer = UnsafeMutablePointer<LDKSocketDescriptor>.allocate(capacity: 1)
46 descriptorPointer.initialize(to: descriptor.cOpaqueStruct!)
48 return Result_NonePeerHandleErrorZ(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKPeerManager>) in
49 PeerManager_write_buffer_space_avail(this_argPointer, descriptorPointer)
53 public func read_event(peer_descriptor: SocketDescriptor, data: [UInt8]) -> Result_boolPeerHandleErrorZ {
55 let peer_descriptorPointer = UnsafeMutablePointer<LDKSocketDescriptor>.allocate(capacity: 1)
56 peer_descriptorPointer.initialize(to: peer_descriptor.cOpaqueStruct!)
58 return Result_boolPeerHandleErrorZ(pointer: withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKPeerManager>) in
59 PeerManager_read_event(this_argPointer, peer_descriptorPointer, Bindings.new_LDKu8slice(array: data))
63 public func process_events() -> Void {
65 return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKPeerManager>) in
66 PeerManager_process_events(this_argPointer)
70 public func socket_disconnected(descriptor: SocketDescriptor) -> Void {
72 return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKPeerManager>) in
73 withUnsafePointer(to: descriptor.cOpaqueStruct!) { (descriptorPointer: UnsafePointer<LDKSocketDescriptor>) in
74 PeerManager_socket_disconnected(this_argPointer, descriptorPointer)
79 public func disconnect_by_node_id(node_id: [UInt8], no_connection_possible: Bool) -> Void {
81 return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKPeerManager>) in
82 PeerManager_disconnect_by_node_id(this_argPointer, Bindings.new_LDKPublicKey(array: node_id), no_connection_possible)
86 public func timer_tick_occurred() -> Void {
88 return withUnsafePointer(to: self.cOpaqueStruct!) { (this_argPointer: UnsafePointer<LDKPeerManager>) in
89 PeerManager_timer_tick_occurred(this_argPointer)
95 if self.cOpaqueStruct?.is_owned == false {
99 PeerManager_free(self.cOpaqueStruct!)
105 /* STRUCT_METHODS_END */