+ /**
+ * Indicates a new outbound connection has been established to a node with the given node_id.
+ * Note that if an Err is returned here you MUST NOT call socket_disconnected for the new
+ * descriptor but must disconnect the connection immediately.
+ *
+ * Returns a small number of bytes to send to the remote node (currently always 50).
+ *
+ * Panics if descriptor is duplicative with some other descriptor which has not yet had a
+ * socket_disconnected().
+ */
+ public Result_CVec_u8ZPeerHandleErrorZ new_outbound_connection(byte[] their_node_id, SocketDescriptor descriptor) {
+ long ret = bindings.PeerManager_new_outbound_connection(this.ptr, their_node_id, descriptor == null ? 0 : descriptor.ptr);
+ Result_CVec_u8ZPeerHandleErrorZ ret_hu_conv = Result_CVec_u8ZPeerHandleErrorZ.constr_from_ptr(ret);
+ this.ptrs_to.add(descriptor);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Indicates a new inbound connection has been established.
+ *
+ * May refuse the connection by returning an Err, but will never write bytes to the remote end
+ * (outbound connector always speaks first). Note that if an Err is returned here you MUST NOT
+ * call socket_disconnected for the new descriptor but must disconnect the connection
+ * immediately.
+ *
+ * Panics if descriptor is duplicative with some other descriptor which has not yet had
+ * socket_disconnected called.
+ */
+ public Result_NonePeerHandleErrorZ new_inbound_connection(SocketDescriptor descriptor) {
+ long ret = bindings.PeerManager_new_inbound_connection(this.ptr, descriptor == null ? 0 : descriptor.ptr);
+ Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
+ this.ptrs_to.add(descriptor);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Indicates that there is room to write data to the given socket descriptor.
+ *
+ * May return an Err to indicate that the connection should be closed.
+ *
+ * Will most likely call send_data on the descriptor passed in (or the descriptor handed into
+ * new_*\\_connection) before returning. Thus, be very careful with reentrancy issues! The
+ * invariants around calling write_buffer_space_avail in case a write did not fully complete
+ * must still hold - be ready to call write_buffer_space_avail again if a write call generated
+ * here isn't sufficient! Panics if the descriptor was not previously registered in a
+ * new_\\*_connection event.
+ */
+ public Result_NonePeerHandleErrorZ write_buffer_space_avail(SocketDescriptor descriptor) {
+ long ret = bindings.PeerManager_write_buffer_space_avail(this.ptr, descriptor == null ? 0 : descriptor.ptr);
+ Result_NonePeerHandleErrorZ ret_hu_conv = Result_NonePeerHandleErrorZ.constr_from_ptr(ret);
+ this.ptrs_to.add(descriptor);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Indicates that data was read from the given socket descriptor.
+ *
+ * May return an Err to indicate that the connection should be closed.
+ *
+ * Will *not* call back into send_data on any descriptors to avoid reentrancy complexity.
+ * Thus, however, you almost certainly want to call process_events() after any read_event to
+ * generate send_data calls to handle responses.
+ *
+ * If Ok(true) is returned, further read_events should not be triggered until a send_data call
+ * on this file descriptor has resume_read set (preventing DoS issues in the send buffer).
+ *
+ * Panics if the descriptor was not previously registered in a new_*_connection event.
+ */
+ public Result_boolPeerHandleErrorZ read_event(SocketDescriptor peer_descriptor, byte[] data) {
+ long ret = bindings.PeerManager_read_event(this.ptr, peer_descriptor == null ? 0 : peer_descriptor.ptr, data);
+ Result_boolPeerHandleErrorZ ret_hu_conv = Result_boolPeerHandleErrorZ.constr_from_ptr(ret);
+ this.ptrs_to.add(peer_descriptor);
+ return ret_hu_conv;
+ }
+
+ /**
+ * Checks for any events generated by our handlers and processes them. Includes sending most
+ * response messages as well as messages generated by calls to handler functions directly (eg
+ * functions like ChannelManager::process_pending_htlc_forward or send_payment).
+ */