在 Windows 上存储 Ganache GUI 区块链

Store Ganache GUI Blockchain on Windows

有没有办法将内存区块链中的Ganache存储到一个文件夹中?我看到我们有 ganache-cli --db 允许我们这样做,但我很想知道我是否可以用 Ganache GUI 做同样的事情。

Ganache UI 没有支持 ganache-cli 提供的 --db 参数的参数。但是,可以通过在您的计算机上手动构建和 运行ning Ganache UI 来指定此位置(注意:这是一种变通方法)

按照 these steps 克隆 ganache 存储库并安装必要的 npm 包。

然后,在克隆的存储库中,导航到 src/chain/chain.js 文件。搜索启动 ganache-core 服务器的代码行。它应该是这样的:

server = ganacheLib.server(options);

现在,在此之前添加一行代码来指定数据库路径:

// This option will tell ganache-core where to instantiate the database.
options.db_path = "C://my_example_db_folder"; 
server = ganacheLib.server(options);

最后,您所要做的就是使用 npm start 命令从源代码中 运行 应用程序。 (您可能还需要通过 npm install -g electron-forge 安装 electron-forge。)您现在将 Ganache UI 运行 数据库指向您指定的文件夹。

请注意,Ganache 利用 LevelDB and the levelup JavaScript 库来保存数据并与之交互。另请注意,您可能需要在重新启动 Ganache 时清除文件夹中的内容 UI。