We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pragma solidity ^0.4.25; //pragma experimental ABIEncoderV2;
import "./Table.sol"; // contract test{ // event event selectEvent(int256 ret, bytes32 RootHash); constructor() public { // 构造函数中创建car_msg表 createtestTable(); } function createtestTable() private{ TableFactory tf = TableFactory(0x1001); // 车辆数据管理表car_msg, key(主键:车企ID) : carID, field : time : , location : 经度范围、纬度范围, totalnum_car, datahash, sig // 创建表 tf.createTable("test_table", "ID", "RootHash"); } function opentestTable() private returns(Table) { TableFactory tf = TableFactory(0x1001); Table table = tf.openTable("test_table"); return table; } function select(string ID) public returns(int256,**bytes32**) { // 打开表 Table table = opentestTable(); // 查询 Entries entries = table.select(ID, table.newCondition()); bytes32 RootHash; if (0 == uint256(entries.size())) { emit selectEvent(-1, RootHash); return (-1, RootHash); } else { Entry entry = entries.get(0); RootHash=entry.getBytes4("RootHash"); emit selectEvent(0,RootHash); return (0, RootHash); } } function register(string ID, bytes32 _RootHash) public returns(int256){ int256 ret_code = 0; int256 ret= 0; bytes32 temp_RootHash; // 查询账户是否存在 (ret, temp_RootHash) = select(ID); if(ret != 0) { Table table = opentestTable(); Entry entry = table.newEntry(); entry.set("ID", ID); entry.set("RootHash", _RootHash); // 插入 int count = table.insert(ID, entry); if (count == 1) { // 成功 ret_code = 0; } else { // 失败? 无权限或者其他错误 ret_code = -2; } } else { // 账户已存在 ret_code = -1; } return ret_code; } }
The text was updated successfully, but these errors were encountered:
2.0 table接口中entry应该没有set bytes32的接口,你可以先把bytes32的数据转成string类型,再进行设置看看。
Sorry, something went wrong.
No branches or pull requests
pragma solidity ^0.4.25;
//pragma experimental ABIEncoderV2;
The text was updated successfully, but these errors were encountered: