Solidity

乙太坊橋 - 觸髮帶有合約 myid 的 WARN 日誌,但之前已經看到,跳過事件

  • February 23, 2018

我正在使用帶有 nodejs 的 ganache 桌面應用程序,我需要通過 ethereum-bridge 從 API 獲取值。

以下是合約程式碼 -

pragma solidity ^0.4.4;

import "./usingOraclize.sol";

contract BondRegister is usingOraclize {

uint public energy;

event Log(string text);

function BondRegister() {

Log("Contract created");
OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475);
}


function getCall() payable returns(bool success) {

oraclize_query("URL", "json(https://min-api.cryptocompare.com/data/price?fsym=ETH&tsyms=USD).USD");
}


function __callback(bytes32 _myid,string result) {

if (msg.sender != oraclize_cbAddress()) { 
    Log("thrown error");
    throw;
}
Log("Entered callback function");
Log(result);
energy = parseInt(result, 2);

}


function getenergy() returns (uint) {
return energy;
}
}

在 ethereum-bridge 控制台中,我收到了event is skipped的警告。

node bridge -H localhost:7545 -a 5

Please wait...
[2018-02-20T03:21:51.031Z] INFO you are running ethereum-bridge - version: 0.5.5
[2018-02-20T03:21:51.033Z] INFO saving logs to: ./bridge.log
[2018-02-20T03:21:51.034Z] INFO using active mode
[2018-02-20T03:21:51.034Z] INFO Connecting to eth node 
http://localhost:7545
[2018-02-20T03:21:53.953Z] INFO connected to node type EthereumJS TestRPC/v2.0.2/ethereum-js
[2018-02-20T03:21:54.857Z] WARN Using 0x2932b7a2355d6fecc4b5c0b6bd44cc31df247a2e to query contracts on your blockchain, make sure it is unlocked and do not use the same address to deploy your contracts
[2018-02-20T03:21:55.087Z] INFO deploying the oraclize connector contract...
[2018-02-20T03:22:06.056Z] INFO connector deployed to: 0x2fcea879fdc9fe5e90394faf0ca644a1749d0ad6
[2018-02-20T03:22:06.299Z] INFO deploying the address resolver with a deterministic address...
[2018-02-20T03:22:30.183Z] INFO address resolver (OAR) deployed to: 0x6f485c8bf6fc43ea212e93bbf8ce046c7f1cb475
[2018-02-20T03:22:30.184Z] INFO updating connector pricing...
[2018-02-20T03:22:42.308Z] INFO successfully deployed all contracts
[2018-02-20T03:22:42.349Z] INFO instance configuration file saved to /home/kottackal/Downloads/ethereumbridge/ethereum-bridge-master/config/instance/oracle_instance_20180220T085242.json

Please add this line to your contract constructor:

OAR = OraclizeAddrResolverI(0x6f485C8BF6fc43eA212E93BBF8ce046C7f1cb475);

[2018-02-20T03:22:42.363Z] WARN re-org block listen is disabled while using TestRPC
[2018-02-20T03:22:42.363Z] WARN if you are running a test suit with Truffle and TestRPC or your chain is reset often please use the --dev mode
[2018-02-20T03:22:42.364Z] INFO Listening @ 0x2fcea879fdc9fe5e90394faf0ca644a1749d0ad6 (Oraclize Connector)

(Ctrl+C to exit)

[2018-02-20T03:26:32.709Z] WARN log with contract myid: 0x1e84508fa52c2d976ef07fe21f02446249a23e0a0b20eeaee263fa309b9c7e49 was triggered, but it was already seen before, skipping event...

當我清除文件夾中的CallbackTxs文件和 Queries文件時ethereum-bridge-master/database/tingodb,Apicall 成功執行。只需要清除以前的日誌資訊,因為為 event 生成的myid已經在 db 文件中。

引用自:https://ethereum.stackexchange.com/questions/40249