Skip to content
New issue

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

Add setTermWeight #862

Merged
merged 2 commits into from
Oct 10, 2024
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
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'

implementation ('org.fisco-bcos.java-sdk:fisco-bcos-java-sdk:3.8.0') {
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
Loading