Skip to content

Commit

Permalink
Update node status
Browse files Browse the repository at this point in the history
  • Loading branch information
leej1012 committed Jun 11, 2024
1 parent 89f004f commit 54fdba9
Showing 1 changed file with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,17 @@ public NodeInfoOffChain getCurrentOffChainInfoPublic(String publicKey, Integer o
try {
NodeInfoOffChainDto nodeInfoOffChainDto = nodeInfoOffChainMapper.selectByPublicKey(publicKey, openFlag);
if (nodeInfoOffChainDto != null && ConstantParam.CHANNEL_ONTO.equalsIgnoreCase(channel)) {
int nodeStatus;
int nodeStatus = 3;
initSDK();
String peerPoolInfoStr = sdk.getPeerPoolInfo(publicKey);
if (StringUtils.hasLength(peerPoolInfoStr)) {
JSONObject peerPoolInfo = JSONObject.parseObject(peerPoolInfoStr);
int status = peerPoolInfo.getIntValue("status");
if (status == 1 || status == 2) {
nodeStatus = 1;
} else {
} else if (status == 3 || status == 4) {
nodeStatus = 2;
}
} else {
nodeStatus = 3;
}
nodeInfoOffChainDto.setStatus(nodeStatus);
}
Expand Down Expand Up @@ -669,7 +667,7 @@ public InspireResultDto calculationUserIncentives(UserInspireCalculationDto dto)
if (CollectionUtils.isEmpty(nodeInfoOnChains)) {
return null;
}
NodeInfoOnChain calculationNode = new NodeInfoOnChain();
NodeInfoOnChain calculationNode = null;
for (NodeInfoOnChain one : nodeInfoOnChains) {
if (one.getPublicKey().equals(publicKey)) {
oldCurrentStake = one.getCurrentStake();
Expand Down Expand Up @@ -703,6 +701,10 @@ public InspireResultDto calculationUserIncentives(UserInspireCalculationDto dto)
break;
}
}

if (calculationNode == null) {
throw new ExplorerException(ErrorInfo.NOT_REGISTRY);
}
nodeInfoOnChains.sort((v1, v2) -> Long.compare(v2.getInitPos() + v2.getTotalPos(), v1.getInitPos() + v1.getTotalPos()));
BigDecimal stakeAmountDecimal = new BigDecimal(stakeAmount);

Expand Down Expand Up @@ -872,7 +874,7 @@ public InspireResultDto calculationUserIncentives(UserInspireCalculationDto dto)
}
Long maxAuthorize = calculationNode.getMaxAuthorize();
// 考虑此节点用户质押部分满了的情况,此时用户不能再进行质押,收益为0
if (maxAuthorize == 0 && totalPos1 == 0) {
if (maxAuthorize == 0 || totalPos1 == 0) {
nodeInspire.setUserReleasedOngIncentive("0");
nodeInspire.setUserGasFeeIncentive("0");
nodeInspire.setUserFoundationBonusIncentive("0");
Expand Down Expand Up @@ -1083,8 +1085,17 @@ public ResponseBean getAddressRegisterNodeList(String address) {
totalPos = item.totalPos;
if (item.status == 1 || item.status == 2) {
status = 1;
} else {
} else if (item.status == 3 || item.status == 4) {
status = 2;
} else if (item.status == 5) {
// 黑名单节点为退出状态
String authorizeInfo = sdk.getAuthorizeInfo(publicKey, address);
if (StringUtils.hasLength(authorizeInfo)) {
JSONObject jsonObject = JSONObject.parseObject(authorizeInfo);
initPos = jsonObject.getLong("withdrawUnfreezePos");
} else {
continue;
}
}
} else {
String authorizeInfo = sdk.getAuthorizeInfo(publicKey, address);
Expand Down

0 comments on commit 54fdba9

Please sign in to comment.