【问题标题】:Store Ganache GUI Blockchain on Windows在 Windows 上存储 Ganache GUI 区块链
【发布时间】:2019-05-29 09:20:09
【问题描述】:

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

【问题讨论】:

    标签: blockchain ethereum solidity truffle ganache


    【解决方案1】:

    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 使用 LevelDBlevelup JavaScript 库来持久化数据并与数据交互。另请注意,在重新启动 Ganache UI 时,您可能需要清除文件夹的内容。

    【讨论】:

    • 重启后有没有办法恢复DB?我不想在重启后丢失我所有的区块链。
    • @EmersonMicu,并不是说我不知道​​。 Ganache 背后的想法是为以太坊创建一个不可重复使用的开发沙箱。如果您想要可重用的东西,我建议您通过 geth 或 parity 在本地运行单节点。
    猜你喜欢
    • 2018-06-14
    • 2022-08-22
    • 2019-04-22
    • 1970-01-01
    • 2019-06-05
    • 1970-01-01
    • 1970-01-01
    • 2022-10-05
    • 2022-01-06
    相关资源
    最近更新 更多