- byte[] random_data = keys_interface.get_secure_random_bytes();
- if (net_graph_serialized != null) {
- Result_NetworkGraphDecodeErrorZ graph_res = NetworkGraph.read(net_graph_serialized, logger);
- if (!graph_res.is_ok()) {
- throw new InvalidSerializedDataException("Serialized Network Graph was corrupt");
- }
- this.net_graph = ((Result_NetworkGraphDecodeErrorZ.Result_NetworkGraphDecodeErrorZ_OK)graph_res).res;
- } else {
- this.net_graph = null;
- }
- Result_SecretKeyNoneZ node_secret = keys_interface.get_node_secret(Recipient.LDKRecipient_Node);
- assert node_secret.is_ok();
- if (net_graph != null) {
- //TODO: We really need to expose the Access here to let users prevent DoS issues
- this.graph_msg_handler = P2PGossipSync.of(net_graph, Option_AccessZ.none(), logger);
- this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(),
- graph_msg_handler.as_RoutingMessageHandler(),
- ignoring_handler.as_OnionMessageHandler(),
- ((Result_SecretKeyNoneZ.Result_SecretKeyNoneZ_OK)node_secret).res,
- System.currentTimeMillis() / 1000,
- random_data, logger, ignoring_handler.as_CustomMessageHandler());
- } else {
- this.graph_msg_handler = null;
- this.peer_manager = PeerManager.of(channel_manager.as_ChannelMessageHandler(),
- ignoring_handler.as_RoutingMessageHandler(),
- ignoring_handler.as_OnionMessageHandler(),
- ((Result_SecretKeyNoneZ.Result_SecretKeyNoneZ_OK)node_secret).res,
- System.currentTimeMillis() / 1000,
- random_data, logger, ignoring_handler.as_CustomMessageHandler());
- }
- NioPeerHandler nio_peer_handler = null;
- try {
- nio_peer_handler = new NioPeerHandler(this.peer_manager);
- } catch (IOException e) {
- throw new IllegalStateException("We should never fail to construct nio objects unless we're on a platform that cannot run LDK.");
- }
- this.nio_peer_handler = nio_peer_handler;