【发布时间】:2019-05-29 09:20:09
【问题描述】:
有没有办法将内存区块链中的 Ganache 存储到文件夹中?我看到我们有 ganache-cli --db 允许我们这样做,但我很感兴趣是否可以使用 Ganache GUI 做同样的事情。
【问题讨论】:
标签: blockchain ethereum solidity truffle ganache
有没有办法将内存区块链中的 Ganache 存储到文件夹中?我看到我们有 ganache-cli --db 允许我们这样做,但我很感兴趣是否可以使用 Ganache GUI 做同样的事情。
【问题讨论】:
标签: blockchain ethereum solidity truffle ganache
Ganache UI 没有支持 ganache-cli 提供的--db 参数的参数。但是,可以通过在您的计算机上手动构建和运行 Ganache UI 来指定此位置(注意:这是一种变通方法)
关注 these steps 以克隆 ganache 存储库并安装必要的 npm 包。
然后,在克隆的 repo 中,导航到 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 和 levelup JavaScript 库来持久化数据并与数据交互。另请注意,在重新启动 Ganache UI 时,您可能需要清除文件夹的内容。
【讨论】: