Skip to content

Commit

Permalink
Add setTermWeight
Browse files Browse the repository at this point in the history
  • Loading branch information
morebtcg committed Oct 9, 2024
1 parent ca6e7f4 commit 5002969
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ dependencies {
//implementation 'org.fisco-bcos:solcJ:0.5.2.1'
implementation 'org.fisco-bcos:solcJ:1.0.0-SNAPSHOT'

implementation ('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:3.8.0-SNAPSHOT') {
implementation ('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:3.9.0-SNAPSHOT') {
exclude group: "org.slf4j"
}

Expand Down
15 changes: 14 additions & 1 deletion src/main/java/console/command/category/ConsensusOpCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,18 @@ public Map<String, CommandInfo> getAllCommandInfo(boolean isWasm) {
2,
2);

public static final CommandInfo SET_CONSENSUS_TERM_WEIGHT =
new CommandInfo(
"setConsensusTermWeight",
"Set consensus term weight for the specified node",
HelpInfo::setConsensusWeightHelp,
(consoleInitializer, params, pwd) ->
consoleInitializer
.getPrecompiledFace()
.setConsensusNodeTermWeight(params),
2,
2);

static {
Field[] fields = ConsensusOpCommand.class.getDeclaredFields();
for (Field field : fields) {
Expand All @@ -159,5 +171,6 @@ public Map<String, CommandInfo> getAllCommandInfo(boolean isWasm) {
ConsensusOpCommand.ADD_OBSERVER.getCommand(),
ConsensusOpCommand.ADD_SEALER.getCommand(),
ConsensusOpCommand.REMOVE_NODE.getCommand(),
ConsensusOpCommand.SET_CONSENSUS_WEIGHT.getCommand()));
ConsensusOpCommand.SET_CONSENSUS_WEIGHT.getCommand(),
ConsensusOpCommand.SET_CONSENSUS_TERM_WEIGHT.getCommand()));
}
2 changes: 2 additions & 0 deletions src/main/java/console/precompiled/PrecompiledFace.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ void setSystemConfigByKey(ConsoleInitializer consoleInitializer, String[] params

void setConsensusNodeWeight(String[] params) throws Exception;

void setConsensusNodeTermWeight(String[] params) throws Exception;

void changeDir(String[] params) throws Exception;

void makeDir(String[] params) throws Exception;
Expand Down
17 changes: 17 additions & 0 deletions src/main/java/console/precompiled/PrecompiledImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,23 @@ public void setConsensusNodeWeight(String[] params) throws Exception {
}
}

@Override
public void setConsensusNodeTermWeight(String[] params) throws Exception {
String nodeId = params[1];
int weight = ConsoleUtils.processNonNegativeNumber("consensusWeight", params[2]);
if (nodeId.length() != 128) {
ConsoleUtils.printJson(PrecompiledRetCode.CODE_INVALID_NODEID.toString());
} else {
RetCode retCode =
this.consensusService.setTermWeight(nodeId, BigInteger.valueOf(weight));
ConsoleUtils.printJson(retCode.toString());
if (retCode.getCode() == PrecompiledRetCode.CODE_NO_AUTHORIZED.getCode()) {
System.out.println(
"Maybe you should use 'setConsensusNodeTermWeightProposal' command to change system config.");
}
}
}

@Override
public void setSystemConfigByKey(ConsoleInitializer consoleInitializer, String[] params)
throws Exception {
Expand Down

0 comments on commit 5002969

Please sign in to comment.