Skip to content

Commit

Permalink
Merge pull request #551 from cyjseagull/release-2.3.0-master-new
Browse files Browse the repository at this point in the history
Release 2.3.0 to master
  • Loading branch information
cyjseagull authored Mar 24, 2020
2 parents c2c6d0c + 2e08375 commit 79b6d57
Show file tree
Hide file tree
Showing 53 changed files with 3,038 additions and 382 deletions.
2 changes: 1 addition & 1 deletion .ci/ci_check_commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

scan_code_script="cobra/cobra.py -f json -o /tmp/report.json -t "
ignore_files=(Constant.java PerformanceOkDSync.java SM2Algorithm.java SM2KeyGenerator.java test)
ignore_files=(RevertResolver.java ECCParams.java ECKeyPair.java KeyUtils.java Permission.java Frozen.java ECDSASign.java Constant.java PerformanceOkDSync.java SM2Algorithm.java SM2KeyGenerator.java test)

LOG_ERROR() {
content=${1}
Expand Down
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ dependencies {
compile 'org.projectlombok:lombok:1.18.2'
}


//archivesBaseName = 'web3sdk'
//group = 'org.fisco-bcos'
//version = '2.0.5'
Expand Down Expand Up @@ -149,6 +150,10 @@ try {
println(" .git directory not exist.");
}

tasks.withType(Test) {
maxParallelForks = 1
}

// 1 dist jar
jar {
destinationDir file('dist/apps')
Expand Down
2 changes: 1 addition & 1 deletion release_note.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2.2.3
v2.3.0
80 changes: 45 additions & 35 deletions solidity/Table.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,67 @@ pragma solidity ^0.4.24;

contract TableFactory {
function openTable(string) public constant returns (Table); //open table
function createTable(string,string,string) public returns(int); //create table
function createTable(string, string, string) public returns (int256); //create table
}

//select condition
contract Condition {
function EQ(string, int) public;
function EQ(string, int256) public;
function EQ(string, string) public;
function NE(string, int) public;
function NE(string, string) public;

function GT(string, int) public;
function GE(string, int) public;
function LT(string, int) public;
function LE(string, int) public;
function limit(int) public;
function limit(int, int) public;

function NE(string, int256) public;
function NE(string, string) public;

function GT(string, int256) public;
function GE(string, int256) public;

function LT(string, int256) public;
function LE(string, int256) public;

function limit(int256) public;
function limit(int256, int256) public;
}

//one record
//one record
contract Entry {
function getInt(string) public constant returns(int);
function getAddress(string) public constant returns(address);
function getBytes64(string) public constant returns(byte[64]);
function getBytes32(string) public constant returns(bytes32);
function getString(string) public constant returns(string);

function set(string, int) public;
function getInt(string) public constant returns (int256);
function getUInt(string) public constant returns (int256);
function getAddress(string) public constant returns (address);
function getBytes64(string) public constant returns (bytes1[64]);
function getBytes32(string) public constant returns (bytes32);
function getString(string) public constant returns (string);

function set(string, int256) public;
function set(string, uint256) public;
function set(string, string) public;
function set(string, address) public;
}

//record sets
contract Entries {
function get(int) public constant returns(Entry);
function size() public constant returns(int);
function get(int256) public constant returns (Entry);
function size() public constant returns (int256);
}

//Table main contract
contract Table {
//select api
function select(string, Condition) public constant returns(Entries);
//insert api
function insert(string, Entry) public returns(int);
//update api
function update(string, Entry, Condition) public returns(int);
//remove api
function remove(string, Condition) public returns(int);

function newEntry() public constant returns(Entry);
function newCondition() public constant returns(Condition);
function select(string, Condition) public constant returns (Entries);
function insert(string, Entry) public returns (int256);
function update(string, Entry, Condition) public returns (int256);
function remove(string, Condition) public returns (int256);

function newEntry() public constant returns (Entry);
function newCondition() public constant returns (Condition);
}

contract KVTableFactory {
function openTable(string) public constant returns (KVTable);
function createTable(string, string, string) public returns (int256);
}

//KVTable per permiary key has only one Entry
contract KVTable {
function get(string) public constant returns (bool, Entry);
function set(string, Entry) public returns (int256);
function newEntry() public constant returns (Entry);
}
104 changes: 56 additions & 48 deletions solidity/TableTest.sol
Original file line number Diff line number Diff line change
@@ -1,89 +1,97 @@
pragma solidity ^0.4.24;
pragma experimental ABIEncoderV2;

import "./Table.sol";

contract TableTest {
event CreateResult(int count);
event InsertResult(int count);
event UpdateResult(int count);
event RemoveResult(int count);

//create table
function create() public returns(int){
TableFactory tf = TableFactory(0x1001); //The fixed address is 0x1001 for TableFactory

int count = tf.createTable("t_test", "name", "item_id,item_name");
emit CreateResult(count);
return count;
event CreateResult(int256 count);
event InsertResult(int256 count);
event UpdateResult(int256 count);
event RemoveResult(int256 count);

TableFactory tableFactory;
string constant TABLE_NAME = "t_test";
constructor() public {
tableFactory = TableFactory(0x1001); //The fixed address is 0x1001 for TableFactory
// the parameters of createTable are tableName,keyField,"vlaueFiled1,vlaueFiled2,vlaueFiled3,..."
tableFactory.createTable(TABLE_NAME, "name", "item_id,item_name");
}

//select records
function select(string name) public constant returns(string[], int[], string[]){
TableFactory tf = TableFactory(0x1001);
Table table = tf.openTable("t_test");

function select(string name)
public
view
returns (string[], int256[], string[])
{
Table table = tableFactory.openTable(TABLE_NAME);

Condition condition = table.newCondition();

Entries entries = table.select(name, condition);
string[] memory user_name_bytes_list = new string[](uint256(entries.size()));
int[] memory item_id_list = new int[](uint256(entries.size()));
string[] memory item_name_bytes_list = new string[](uint256(entries.size()));

for(int i=0; i<entries.size(); ++i) {
string[] memory user_name_bytes_list = new string[](
uint256(entries.size())
);
int256[] memory item_id_list = new int256[](uint256(entries.size()));
string[] memory item_name_bytes_list = new string[](
uint256(entries.size())
);

for (int256 i = 0; i < entries.size(); ++i) {
Entry entry = entries.get(i);

user_name_bytes_list[uint256(i)] = entry.getString("name");
item_id_list[uint256(i)] = entry.getInt("item_id");
item_name_bytes_list[uint256(i)] = entry.getString("item_name");
item_name_bytes_list[uint256(i)] = entry.getString("item_name");
}

return (user_name_bytes_list, item_id_list, item_name_bytes_list);
}
//insert records
function insert(string name, int item_id, string item_name) public returns(int) {
TableFactory tf = TableFactory(0x1001);
Table table = tf.openTable("t_test");

function insert(string name, int256 item_id, string item_name)
public
returns (int256)
{
Table table = tableFactory.openTable(TABLE_NAME);

Entry entry = table.newEntry();
entry.set("name", name);
entry.set("item_id", item_id);
entry.set("item_name", item_name);
int count = table.insert(name, entry);

int256 count = table.insert(name, entry);
emit InsertResult(count);

return count;
}
//update records
function update(string name, int item_id, string item_name) public returns(int) {
TableFactory tf = TableFactory(0x1001);
Table table = tf.openTable("t_test");

function update(string name, int256 item_id, string item_name)
public
returns (int256)
{
Table table = tableFactory.openTable(TABLE_NAME);

Entry entry = table.newEntry();
entry.set("item_name", item_name);

Condition condition = table.newCondition();
condition.EQ("name", name);
condition.EQ("item_id", item_id);
int count = table.update(name, entry, condition);

int256 count = table.update(name, entry, condition);
emit UpdateResult(count);

return count;
}
//remove records
function remove(string name, int item_id) public returns(int){
TableFactory tf = TableFactory(0x1001);
Table table = tf.openTable("t_test");

function remove(string name, int256 item_id) public returns (int256) {
Table table = tableFactory.openTable(TABLE_NAME);

Condition condition = table.newCondition();
condition.EQ("name", name);
condition.EQ("item_id", item_id);
int count = table.remove(name, condition);

int256 count = table.remove(name, condition);
emit RemoveResult(count);

return count;
}
}
15 changes: 8 additions & 7 deletions src/main/java/org/fisco/bcos/channel/client/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
import org.fisco.bcos.web3j.protocol.core.methods.response.Log;
import org.fisco.bcos.web3j.protocol.core.methods.response.TransactionReceipt;
import org.fisco.bcos.web3j.protocol.exceptions.TransactionException;
import org.fisco.bcos.web3j.tuples.generated.Tuple2;
import org.fisco.bcos.web3j.tx.RevertResolver;
import org.fisco.bcos.web3j.tx.txdecode.LogResult;
import org.fisco.bcos.web3j.utils.Strings;
import org.slf4j.Logger;
Expand Down Expand Up @@ -716,13 +718,6 @@ public void run(Timeout timeout) throws Exception {
}
}

/**
* When SDK start, the initial subscribed topics information set by user will be sent to the
* node. User can update subscribed topics again by following steps: 1. Set the topics you want
* to subscribe to again Service service // Servcie object Set<String> topics // topics that
* subscribe again service.setTopics(topics) 2. send update topics message to all nodes
* service.updateTopicsToNode();
*/
public void updateTopicsToNode() {

logger.info(" updateTopicToNode, groupId: {}, topics: {}", groupId, getTopics());
Expand Down Expand Up @@ -1548,6 +1543,12 @@ public void onReceiveTransactionMessage(String seq, TransactionReceipt receipt)
}

try {
Tuple2<Boolean, String> revertMessage =
RevertResolver.tryResolveRevertMessage(receipt);
if (revertMessage.getValue1()) {
logger.debug(" revert message: {}", revertMessage.getValue2());
receipt.setMessage(revertMessage.getValue2());
}
callback.onResponse(receipt);
} catch (Exception e) {
logger.error("Error process transactionMessage: ", e);
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/org/fisco/bcos/channel/dto/ChannelMessage2.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.fisco.bcos.channel.dto;

import io.netty.buffer.ByteBuf;
import java.io.UnsupportedEncodingException;
import org.fisco.bcos.channel.handler.Message;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -36,14 +37,22 @@ public void readExtra(ByteBuf in) {
@Override
public void writeHeader(ByteBuf out) {
// total length
length = Message.HEADER_LENGTH + 1 + topic.length() + data.length;
try {
length = Message.HEADER_LENGTH + 1 + topic.getBytes("utf-8").length + data.length;
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(" topic string to utf8 failed, topic: " + topic);
}

super.writeHeader(out);
}

@Override
public void writeExtra(ByteBuf out) {
out.writeByte(1 + topic.length());
try {
out.writeByte(1 + topic.getBytes("utf-8").length);
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(" topic string to utf8 failed, topic: " + topic);
}
out.writeBytes(topic.getBytes());

out.writeBytes(data);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.fisco.bcos.web3j.abi.datatypes;

import java.util.Collections;
import java.util.List;
import org.fisco.bcos.web3j.abi.TypeReference;
import org.fisco.bcos.web3j.abi.Utils;
Expand All @@ -17,6 +18,12 @@ public Function(
this.outputParameters = Utils.convert(outputParameters);
}

public Function() {
this.name = "";
this.inputParameters = Collections.<Type>emptyList();
this.outputParameters = Collections.<TypeReference<Type>>emptyList();
}

public String getName() {
return name;
}
Expand Down
Loading

0 comments on commit 79b6d57

Please sign in to comment.