Skip to content

Commit 8591657

Browse files
authored
<feat>(client): add getNodeListByType interface. (#822)
1 parent c9012ea commit 8591657

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

src/main/java/org/fisco/bcos/sdk/v3/client/Client.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,44 @@ void getTransactionReceiptAsync(
752752
*/
753753
void getSealerListAsync(String node, RespCallback<SealerList> callback);
754754

755+
/**
756+
* get node list by type
757+
*
758+
* @param type type of node, now support consensus_sealer, consensus_observer and
759+
* consensus_candidate_sealer
760+
* @return node list
761+
*/
762+
SealerList getNodeListByType(String type);
763+
764+
/**
765+
* get node list by type
766+
*
767+
* @param node the node rpc request send to
768+
* @param type type of node, now support consensus_sealer, consensus_observer and
769+
* consensus_candidate_sealer
770+
* @return node list
771+
*/
772+
SealerList getNodeListByType(String node, String type);
773+
774+
/**
775+
* async get node list by type
776+
*
777+
* @param type type of node, now support consensus_sealer, consensus_observer and
778+
* consensus_candidate_sealer
779+
* @param callback the callback
780+
*/
781+
void getNodeListByTypeAsync(String type, RespCallback<SealerList> callback);
782+
783+
/**
784+
* async get node list by type
785+
*
786+
* @param node the node rpc request send to
787+
* @param type type of node, now support consensus_sealer, consensus_observer and
788+
* consensus_candidate_sealer
789+
* @param callback the callback
790+
*/
791+
void getNodeListByTypeAsync(String node, String type, RespCallback<SealerList> callback);
792+
755793
/**
756794
* Peer operation: get pbft view
757795
*

src/main/java/org/fisco/bcos/sdk/v3/client/ClientImpl.java

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,42 @@ public void getSealerListAsync(String node, RespCallback<SealerList> callback) {
909909
callback);
910910
}
911911

912+
@Override
913+
public SealerList getNodeListByType(String type) {
914+
return getNodeListByType("", type);
915+
}
916+
917+
@Override
918+
public SealerList getNodeListByType(String node, String type) {
919+
node = Objects.isNull(node) ? "" : node;
920+
return this.callRemoteMethod(
921+
this.groupID,
922+
node,
923+
new JsonRpcRequest<>(
924+
JsonRpcMethods.GET_NODE_LIST_BY_TYPE,
925+
Arrays.asList(this.groupID, node, type)),
926+
SealerList.class);
927+
}
928+
929+
@Override
930+
public void getNodeListByTypeAsync(String type, RespCallback<SealerList> callback) {
931+
this.getNodeListByTypeAsync("", type, callback);
932+
}
933+
934+
@Override
935+
public void getNodeListByTypeAsync(
936+
String node, String type, RespCallback<SealerList> callback) {
937+
node = Objects.isNull(node) ? "" : node;
938+
this.asyncCallRemoteMethod(
939+
this.groupID,
940+
node,
941+
new JsonRpcRequest<>(
942+
JsonRpcMethods.GET_NODE_LIST_BY_TYPE,
943+
Arrays.asList(this.groupID, node, type)),
944+
SealerList.class,
945+
callback);
946+
}
947+
912948
@Override
913949
public PbftView getPbftView() {
914950
return this.getPbftView("");

src/main/java/org/fisco/bcos/sdk/v3/client/protocol/request/JsonRpcMethods.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class JsonRpcMethods {
2020
public static final String GET_PBFT_VIEW = "getPbftView";
2121
public static final String GET_CONSENSUS_STATUS = "getConsensusStatus";
2222
public static final String GET_SEALER_LIST = "getSealerList";
23+
public static final String GET_NODE_LIST_BY_TYPE = "getNodeListByType";
2324
public static final String GET_SYSTEM_CONFIG_BY_KEY = "getSystemConfigByKey";
2425
public static final String GET_OBSERVER_LIST = "getObserverList";
2526
public static final String GET_SYNC_STATUS = "getSyncStatus";

0 commit comments

Comments
 (0)