ubuntu - geth 使用智能合约备份/恢复添加到区块链的数据
问题描述
我正在使用 nodejs 应用程序使用智能合约和松露将数据添加到 go-ethereum (geth) 本地环境。如果由于某种原因或其他任何事情发生并且我需要停止 geth 并稍后恢复它,我将无法获取数据。重现:
ps -aux | grep geth
sudo kill -9 ProcessID
geth --datadir ./myDataDir --rpc --targetgaslimit 18446744073709551615 --networkid 1441 console 2>> myEth.log
miner.start()
personal.unlockAccount(personal.listAccounts[0], "Password", 0)
pm2 restart myApp
当我尝试使用在停止 geth 之前添加的数据的 GET API 时,NodeJS 应用程序上显示错误:
0|myApp | 21-06 12:19:44.271: You have triggered an unhandledRejection, you may have forgotten to catch a Promise rejection:
0|myApp | Error: Invalid address passed to BankFactory.at(): 0x
这显然是分配地址的冲突,因为它没有读取 BankFactory 的正确地址。合同地址通常是在我这样做时生成的truffle deploy
,然后我将合同复制到我的应用程序的目录中,但在这种情况下,它们仍在我的节点应用程序中,因此区块链本身的合同似乎被删除或更改了!
如何解决?
解决方案
推荐阅读
- java - 我可以拥有一个 Avro 架构,其中的枚举包含值作为枚举成员吗?
- javascript - Onclick在React js中关闭模式
- php - Spatie Laravel 权限编码问题
- angular-cli - 复制资产作为 Angular 9 库构建的一部分
- python - Networkx Kernighan-Lin 多分区
- javascript - vue-pdf 无法加载到所有页面“未定义的属性”
- cordova - 如何在科尔多瓦应用程序中包含 git 描述信息
- python - 如何从这样的目录结构中正确导入类?
- python - 根据前一行将数据添加到新列
- django - Django 用户配置文件更新表单返回空白