Skip to content

Commit

Permalink
Update getPreConsensusCount
Browse files Browse the repository at this point in the history
  • Loading branch information
leej1012 committed Dec 25, 2024
1 parent 70dc133 commit 36fd9fa
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1198,14 +1198,14 @@ public ResponseBean getAddressRegisterNodeList(String address) {
}
list.sort((o1, o2) -> {
// 先按照status排序(1-在线->3-已退出->2-正在退出),status相同的情况下按照节点质押数量倒序
int compareByPrice = Integer.compare(o1.getStatus(), o2.getStatus());
if (compareByPrice != 0) {
int compareByStatus = Integer.compare(o1.getStatus(), o2.getStatus());
if (compareByStatus != 0) {
if (o1.getStatus() == 2 && o2.getStatus() == 3) {
return 1;
} else if (o1.getStatus() == 3 && o2.getStatus() == 2) {
return -1;
} else {
return compareByPrice;
return compareByStatus;
}
} else {
return Long.compare(o2.getInitPos(), o1.getInitPos());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,13 @@ public int getPreConsensusCount() {
Configuration preConfiguration = getPreConfiguration();
return preConfiguration.K;
} catch (Exception e) {
log.warn("Getting authorize info failed: {}", e.getMessage());
log.warn("getPreConfiguration failed: {}", e.getMessage());
try {
Configuration vbftConfiguration = getVbftConfiguration();
return vbftConfiguration.K;
} catch (Exception e1) {
log.warn("getVbftConfiguration failed: {}", e.getMessage());
}
}
return 0;
}
Expand All @@ -694,6 +700,19 @@ public Configuration getPreConfiguration() throws Exception {
return configuration;
}

public Configuration getVbftConfiguration() throws Exception {
OntSdk ontSdk = getOntSdk();
String res = ontSdk.getConnect().getStorage(Helper.reverse(contractAddress), Helper.toHexString("vbftConfig".getBytes()));
if (res == null) {
return null;
}
Configuration configuration = new Configuration();
ByteArrayInputStream in = new ByteArrayInputStream(Helper.hexToBytes(res));
BinaryReader reader = new BinaryReader(in);
configuration.deserialize(reader);
return configuration;
}

public Object getTxJson(String txHash) {
OntSdk ontSdk = getOntSdk();
ontSdk.setRestful(paramsConfig.MASTERNODE_RESTFUL_URL);
Expand Down

0 comments on commit 36fd9fa

Please sign in to comment.