Skip to content

回复:比特币 API 研究进展 ​

首次公开证据

打开首次公开证据
查看 1 个交叉存档
来源说明

Published on GitHub in February 2024 as part of Martti Malmi's testimony in the COPA v. Wright trial

我在 wxSocketServer::Accept(bool wait = true) 的文档中注意到了这一段: “如果 wait 为 true,且没有等待接受的连接,它就会等待下一个传入连接到达。警告:这会阻塞 GUI。”

wxWidgets 病态地依赖单线程。不只是单线程,而且还必须在 GUI 线程里。就连 wxStandardPaths 这种与 UI 毫不相关的东西也让我吃了苦头。这对于 UI 代码来说没问题,因为 Windows 本来就施加了同样的限制;但对于没有 UI 的服务器守护进程代码,wx 调用是否可用就不好说了。

我目前的研究进展:

要让 PHP、Python 等访问服务器,我们需要使用常规套接字。我想可以通过只绑定 localhost 将其限制在本地,使它只能通过回环接口访问。也有人说,只需检查收到的连接的 IP,并断开所有不是 127.0.0.1 的连接,同样滴水不漏。两种方法不妨一起用。

XML-RPC 有点臃肿。C++ 有 4 个库,但都很庞大且难以构建,还存在依赖和许可证问题。一些发帖者抱怨所有 C++ 和 PHP XML-RPC 库都有缺陷。

JSON-RPC 是一种更简单、更优雅的标准。它简单到我可以使用通用 JSON 解析器。

PHP、Python 和 Java 都有不错的 JSON-RPC 实现。

我目前倾向于 JSON-RPC。

英文原文 ​

展开英文原文

I noticed this in the docs for wxSocketServer::Accept(bool wait = true): "If wait is true and there are no pending connections to be accepted, it will wait for the next incoming connection to arrive. **Warning: This will block the GUI."

wxWidgets is pathologically single-threaded. Not only single-threaded, but must-be-the-GUI-thread-ed. Even for something as non-UI as wxStandardPaths I got nailed. All this is fine for UI code, since this is the same constraint placed by Windows anyway, but for UI-less server daemon code, wx calls are uncertain.

Status of my research currently:

For PHP, Python, etc to access the server, we need to use regular sockets. I think we can make it local-only by binding to localhost only, so it can only be accessed through the loopback. They say it's also watertight to simply check the IP of connections received and disconnect anything not 127.0.0.1. May as well do both.

XML-RPC is a bit fat. There are 4 libraries for C++ but they're all big and hard to build, dependencies, license issues. Some posters complain all the C++ and PHP XML-RPC libraries are buggy.

JSON-RPC is a simpler more elegant standard. It's simple enough I could use a generic JSON parser.

PHP, Python and Java all have good implementations of JSON-RPC.

I'm currently leaning towards JSON-RPC.

为历史保存,为中文读者整理。每篇档案均附来源与英文原文。