Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,6 @@ jobs:
dist: bionic
sudo: required

# # os
# - language: java
# os: osx
# osx_image: xcode11.3
addons:
apt:
packages:
Expand All @@ -77,3 +73,6 @@ before_install:
- gradle wrapper
script: |
bash .ci/ci_check.sh
after_success:
- ./gradlew jacocoTestReport
- bash <(curl -s https://codecov.io/bash)
9 changes: 9 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,12 @@ dependencies {
archivesBaseName = 'java-sdk'
group = 'org.fisco-bcos'
version = '1.0.0-SNAPSHOT'

jacocoTestReport {
reports {
xml.enabled true
html.enabled false
}
}

check.dependsOn jacocoTestReport
36 changes: 33 additions & 3 deletions src/main/java/org/fisco/bcos/sdk/channel/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.List;
import org.fisco.bcos.sdk.model.Message;
import org.fisco.bcos.sdk.model.MsgType;
import org.fisco.bcos.sdk.model.Response;
import org.fisco.bcos.sdk.network.ConnectionInfo;
import org.fisco.bcos.sdk.network.MsgHandler;

Expand Down Expand Up @@ -62,14 +63,41 @@ static Channel build(String filepath) {
*/
void addDisconnectHandler(MsgHandler handler);

/**
* Synchronize interface, send a message to the given peer, and get the response
*
* @param out: Message to be sent
* @param peerIpPort: Remote ip:port information
* @param callback: The callback to be called when the response returns
* @return: Remote reply
*/
Response sendToPeer(Message out, String peerIpPort);
/**
* Synchronize interface, send a message to the given group, and get the response
*
* @param out: Message to be sent
* @param groupId: ID of the group receiving the message packet
* @param callback: The callback to be called when the response returns
* @return: Remote reply
*/
Response sendToGroup(Message out, String groupId);
/**
* Synchronize interface, randomly select nodes to send messages
*
* @param out: Message to be sent
* @param callback: The callback to be called when the response returns
* @return: Remote reply
*/
Response sendToRandom(Message out);

/**
* Send message to peer
*
* @param out message
* @param peerIpPort the peer to send to
* @param callback response callback
*/
void sendToPeer(Message out, String peerIpPort, ResponseCallback callback);
void asyncSendToPeer(Message out, String peerIpPort, ResponseCallback callback);

/**
* Send to a best peer with highest block height in Group
Expand All @@ -78,7 +106,7 @@ static Channel build(String filepath) {
* @param groupId
* @param callback
*/
void sendToGroup(Message out, String groupId, ResponseCallback callback);
void asyncSendToGroup(Message out, String groupId, ResponseCallback callback);

/**
* Broadcast to all peer
Expand All @@ -94,12 +122,14 @@ static Channel build(String filepath) {
* @param out
* @param callback
*/
void sendToRandom(Message out, ResponseCallback callback);
void asyncSendToRandom(Message out, ResponseCallback callback);

/**
* Get connection information
*
* @return List of connection information
*/
List<ConnectionInfo> getConnectionInfo();

public String newSeq();
}
66 changes: 33 additions & 33 deletions src/main/java/org/fisco/bcos/sdk/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,39 +18,39 @@
import java.math.BigInteger;
import java.util.List;
import org.fisco.bcos.sdk.channel.Channel;
import org.fisco.bcos.sdk.client.request.DefaultBlockParameter;
import org.fisco.bcos.sdk.client.request.Transaction;
import org.fisco.bcos.sdk.client.response.BcosBlock;
import org.fisco.bcos.sdk.client.response.BcosBlockHeader;
import org.fisco.bcos.sdk.client.response.BcosTransaction;
import org.fisco.bcos.sdk.client.response.BcosTransactionReceipt;
import org.fisco.bcos.sdk.client.response.BlockHash;
import org.fisco.bcos.sdk.client.response.BlockNumber;
import org.fisco.bcos.sdk.client.response.Call;
import org.fisco.bcos.sdk.client.response.Code;
import org.fisco.bcos.sdk.client.response.ConsensusStatus;
import org.fisco.bcos.sdk.client.response.GenerateGroup;
import org.fisco.bcos.sdk.client.response.GroupList;
import org.fisco.bcos.sdk.client.response.GroupPeers;
import org.fisco.bcos.sdk.client.response.NodeIDList;
import org.fisco.bcos.sdk.client.response.NodeVersion;
import org.fisco.bcos.sdk.client.response.ObserverList;
import org.fisco.bcos.sdk.client.response.PbftView;
import org.fisco.bcos.sdk.client.response.Peers;
import org.fisco.bcos.sdk.client.response.PendingTransactions;
import org.fisco.bcos.sdk.client.response.PendingTxSize;
import org.fisco.bcos.sdk.client.response.QueryGroupStatus;
import org.fisco.bcos.sdk.client.response.RecoverGroup;
import org.fisco.bcos.sdk.client.response.RemoveGroup;
import org.fisco.bcos.sdk.client.response.SealerList;
import org.fisco.bcos.sdk.client.response.SendTransaction;
import org.fisco.bcos.sdk.client.response.StartGroup;
import org.fisco.bcos.sdk.client.response.StopGroup;
import org.fisco.bcos.sdk.client.response.SyncStatus;
import org.fisco.bcos.sdk.client.response.SystemConfig;
import org.fisco.bcos.sdk.client.response.TotalTransactionCount;
import org.fisco.bcos.sdk.client.response.TransactionReceiptWithProof;
import org.fisco.bcos.sdk.client.response.TransactionWithProof;
import org.fisco.bcos.sdk.client.protocol.request.DefaultBlockParameter;
import org.fisco.bcos.sdk.client.protocol.request.Transaction;
import org.fisco.bcos.sdk.client.protocol.response.BcosBlock;
import org.fisco.bcos.sdk.client.protocol.response.BcosBlockHeader;
import org.fisco.bcos.sdk.client.protocol.response.BcosTransaction;
import org.fisco.bcos.sdk.client.protocol.response.BcosTransactionReceipt;
import org.fisco.bcos.sdk.client.protocol.response.BlockHash;
import org.fisco.bcos.sdk.client.protocol.response.BlockNumber;
import org.fisco.bcos.sdk.client.protocol.response.Call;
import org.fisco.bcos.sdk.client.protocol.response.Code;
import org.fisco.bcos.sdk.client.protocol.response.ConsensusStatus;
import org.fisco.bcos.sdk.client.protocol.response.GenerateGroup;
import org.fisco.bcos.sdk.client.protocol.response.GroupList;
import org.fisco.bcos.sdk.client.protocol.response.GroupPeers;
import org.fisco.bcos.sdk.client.protocol.response.NodeIDList;
import org.fisco.bcos.sdk.client.protocol.response.NodeVersion;
import org.fisco.bcos.sdk.client.protocol.response.ObserverList;
import org.fisco.bcos.sdk.client.protocol.response.PbftView;
import org.fisco.bcos.sdk.client.protocol.response.Peers;
import org.fisco.bcos.sdk.client.protocol.response.PendingTransactions;
import org.fisco.bcos.sdk.client.protocol.response.PendingTxSize;
import org.fisco.bcos.sdk.client.protocol.response.QueryGroupStatus;
import org.fisco.bcos.sdk.client.protocol.response.RecoverGroup;
import org.fisco.bcos.sdk.client.protocol.response.RemoveGroup;
import org.fisco.bcos.sdk.client.protocol.response.SealerList;
import org.fisco.bcos.sdk.client.protocol.response.SendTransaction;
import org.fisco.bcos.sdk.client.protocol.response.StartGroup;
import org.fisco.bcos.sdk.client.protocol.response.StopGroup;
import org.fisco.bcos.sdk.client.protocol.response.SyncStatus;
import org.fisco.bcos.sdk.client.protocol.response.SystemConfig;
import org.fisco.bcos.sdk.client.protocol.response.TotalTransactionCount;
import org.fisco.bcos.sdk.client.protocol.response.TransactionReceiptWithProof;
import org.fisco.bcos.sdk.client.protocol.response.TransactionWithProof;

/**
* This is the interface of client module.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
*
*/

package org.fisco.bcos.sdk.client.request;
package org.fisco.bcos.sdk.client.protocol.request;

public interface DefaultBlockParameter {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* Copyright 2014-2020 [fisco-dev]
*
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* <p>http://www.apache.org/licenses/LICENSE-2.0
*
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.fisco.bcos.sdk.client.protocol.request;

public class JsonRpcMethods {
/** define the method name for all jsonRPC interfaces */
// the interface related to the group
public static final String GET_BLOCK_NUMBER = "getBlockNumber";

public static final String GET_PBFT_VIEW = "getPbftView";
public static final String GET_SEALER_LIST = "getSealerList";
public static final String GET_SYSTEM_CONFIG_BY_KEY = "getSystemConfigByKey";
public static final String GET_OBSERVER_LIST = "getObserverList";
public static final String GET_CONSENSUS_STATUS = "getConsensusStatus";
public static final String GET_SYNC_STATUS = "getSyncStatus";
public static final String GET_GROUP_PEERS = "getGroupPeers";
public static final String GET_BLOCK_BY_HASH = "getBlockByHash";
public static final String GET_BLOCKHEADER_BY_HASH = "getBlockHeaderByHash";
public static final String GET_BLOCK_BY_NUMBER = "getBlockByNumber";
public static final String GET_BLOCKHEADER_BY_NUMBER = "getBlockHeaderByNumber";
public static final String GET_BLOCKHASH_BY_NUMBER = "getBlockHashByNumber";
public static final String GET_TRANSACTION_BY_HASH = "getTransactionByHash";
public static final String GET_TRANSACTION_BY_BLOCKHASH_AND_INDEX =
"getTransactionByBlockHashAndIndex";
public static final String GET_TRANSACTION_BY_BLOCKNUMBER_AND_INDEX =
"getTransactionByBlockNumberAndIndex";
public static final String GET_TRANSACTIONRECEIPT = "getTransactionReceipt";
public static final String GET_PENDING_TX_SIZE = "getPendingTxSize";
public static final String CALL = "call";
public static final String SEND_RAWTRANSACTION = "sendRawTransaction";
public static final String SEND_RAWTRANSACTION_AND_GET_PROOF = "sendRawTransactionAndGetProof";
public static final String GET_CODE = "getCode";
public static final String GET_TOTAL_TRANSACTION_COUNT = "getTotalTransactionCount";
public static final String GET_TRANSACTION_BY_HASH_WITH_PROOF = "getTransactionByHashWithProof";
public static final String GET_TRANSACTION_RECEIPT_BY_HASH_WITH_PROOF =
"getTransactionReceiptByHashWithProof";

// the interface related to the node
public static final String GET_CLIENT_VERSION = "getClientVersion";
public static final String GET_PEERS = "getPeers";
public static final String GET_GROUP_LIST = "getGroupList";
public static final String GET_NODEIDLIST = "getNodeIDList";

// the interface related to group-runtime-manager
public static final String GENERATE_GROUP = "generateGroup";
public static final String START_GROUP = "startGroup";
public static final String STOP_GROUP = "stopGroup";
public static final String REMOVE_GROUP = "removeGroup";
public static final String RECOVER_GROUP = "recoverGroup";
public static final String QUERY_GROUP_STATUS = "queryGroupStatus";

private JsonRpcMethods() {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* Copyright 2014-2020 [fisco-dev]
*
* <p>Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of the License at
*
* <p>http://www.apache.org/licenses/LICENSE-2.0
*
* <p>Unless required by applicable law or agreed to in writing, software distributed under the
* License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.fisco.bcos.sdk.client.protocol.request;

import java.util.List;
import java.util.concurrent.atomic.AtomicLong;

public class JsonRpcRequest<T> {
// for set the json id
private static AtomicLong nextIdGetter = new AtomicLong(0);
// the jsonrpc version, default is 2.0
private String jsonRpcVersion = "2.0";
// rpc method
private String method;
// params for the rpc interface
private List<T> params;
// the json rpc request id
private long id;

public JsonRpcRequest(String method, List<T> params) {
this.method = method;
this.params = params;
this.id = nextIdGetter.getAndIncrement();
}

// getter and setter for the class members
public String getJsonRpcVersion() {
return this.jsonRpcVersion;
}

public String getMethod() {
return this.method;
}

public long getId() {
return this.id;
}

public List<T> getParams() {
return this.params;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
*
*/

package org.fisco.bcos.sdk.client.request;
package org.fisco.bcos.sdk.client.protocol.request;

public class Transaction {}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
*
*/

package org.fisco.bcos.sdk.client.response;
package org.fisco.bcos.sdk.client.protocol.response;

public class BcosBlock {}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
*
*/

package org.fisco.bcos.sdk.client.response;
package org.fisco.bcos.sdk.client.protocol.response;

public class BcosBlockHeader {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package org.fisco.bcos.sdk.client.protocol.response;

public class BcosTransaction {}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

package org.fisco.bcos.sdk.client.response;
package org.fisco.bcos.sdk.client.protocol.response;

/** getTransactionReceipt. */
public class BcosTransactionReceipt {}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

package org.fisco.bcos.sdk.client.response;
package org.fisco.bcos.sdk.client.protocol.response;

/** getBlockHashByNumber */
public class BlockHash {}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

package org.fisco.bcos.sdk.client.response;
package org.fisco.bcos.sdk.client.protocol.response;

/** getblockNumber. */
public class BlockNumber {}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

package org.fisco.bcos.sdk.client.response;
package org.fisco.bcos.sdk.client.protocol.response;

/**
* RPC response of ledger call
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

package org.fisco.bcos.sdk.client.response;
package org.fisco.bcos.sdk.client.protocol.response;

/**
* Get code response
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
*/

package org.fisco.bcos.sdk.client.response;
package org.fisco.bcos.sdk.client.protocol.response;

/** getConsensusStatus */
public class ConsensusStatus {}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
*
*/

package org.fisco.bcos.sdk.client.response;
package org.fisco.bcos.sdk.client.protocol.response;

public class GenerateGroup {}
Loading