Skip to content

Commit

Permalink
Update nodeInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
leej1012 committed May 22, 2024
1 parent 31c2431 commit 28d7a09
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ public class NodeStakeDto {
// 1-待生效;2-质押中;3-可提取;4-取消中
private int state;

// 1-候选节点;2-共识节点;3-节点退出
// 1-候选节点;2-共识节点
private int nodeType;

// 0-节点退出;1-节点运行中
private int nodeState;

private boolean allowStake;
Expand All @@ -30,5 +33,4 @@ public class NodeStakeDto {

// user apr
private String apr;

}
Original file line number Diff line number Diff line change
Expand Up @@ -1586,7 +1586,6 @@ public ResponseBean getAddressStakingInfo(String address) {
int currentRound = sdk.getGovernanceView();
List<NodeInfoOffChain> currentOffChainInfo = nodeInfoOffChainMapper.selectAllStakingNodeInfo();
List<NodeStakeDto> nodeStakeDtos = new ArrayList<>();
initSDK();
for (NodeInfoOffChain nodeInfoOffChain : currentOffChainInfo) {
String publicKey = nodeInfoOffChain.getPublicKey();
try {
Expand All @@ -1607,8 +1606,11 @@ private void putStakingInfoList(String stakingInfo, NodeInfoOffChain nodeInfoOff
String nodeName = nodeInfoOffChain.getName();
String address = nodeInfoOffChain.getAddress();
String progress = nodeInfoOffChain.getProgress();
int nodeType = nodeInfoOffChain.getNodeType();
// 节点存在且质押进度没到100%,则可以质押
boolean allowStake = progress != null && !"100.00%".equals(progress);
int nodeStatus = Optional.ofNullable(nodeInfoOffChain.getStatus()).orElse(3);
// 判断节点存在是否存在
int nodeStatus = progress == null ? 0 : 1;
String userApy = Optional.ofNullable(nodeInfoOffChain.getUserApy()).orElse("");
JSONObject stakingInfoObj = JSONObject.parseObject(stakingInfo);
Long consensusPos = stakingInfoObj.getLong("consensusPos");
Expand All @@ -1626,6 +1628,7 @@ private void putStakingInfoList(String stakingInfo, NodeInfoOffChain nodeInfoOff
dto.setNodeWalletAddress(address);
dto.setAmount(Long.toString(amount));
dto.setState(StakeStatusEnum.IN_STAKE.state());
dto.setNodeType(nodeType);
dto.setNodeState(nodeStatus);
dto.setAllowStake(allowStake);
dto.setCurrentRound(currentRound);
Expand All @@ -1639,6 +1642,7 @@ private void putStakingInfoList(String stakingInfo, NodeInfoOffChain nodeInfoOff
dto.setNodeWalletAddress(address);
dto.setAmount(newPos.toString());
dto.setState(StakeStatusEnum.PENDING.state());
dto.setNodeType(nodeType);
dto.setNodeState(nodeStatus);
dto.setAllowStake(allowStake);
dto.setCurrentRound(currentRound);
Expand All @@ -1652,6 +1656,7 @@ private void putStakingInfoList(String stakingInfo, NodeInfoOffChain nodeInfoOff
dto.setNodeWalletAddress(address);
dto.setAmount(withdrawUnfreezePos.toString());
dto.setState(StakeStatusEnum.WITHDRAWABLE.state());
dto.setNodeType(nodeType);
dto.setNodeState(nodeStatus);
dto.setAllowStake(allowStake);
dto.setCurrentRound(currentRound);
Expand All @@ -1666,6 +1671,7 @@ private void putStakingInfoList(String stakingInfo, NodeInfoOffChain nodeInfoOff
dto.setNodeWalletAddress(address);
dto.setAmount(Long.toString(amount));
dto.setState(StakeStatusEnum.CANCELLING.state());
dto.setNodeType(nodeType);
dto.setNodeState(nodeStatus);
dto.setAllowStake(allowStake);
dto.setCurrentRound(currentRound);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ALTER TABLE tbl_node_info_off_chain CHANGE `node_type` `node_type` int(11) NOT NULL COMMENT '节点类型:1-候选节点;2-共识节点';

UPDATE tbl_node_info_off_chain SET node_type = 1 WHERE node_type NOT IN (1,2);
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
a.public_key,
a.name,
a.address,
b.status,
a.node_type,
b.progress,
c.user_apy
FROM tbl_node_info_off_chain a
Expand Down

0 comments on commit 28d7a09

Please sign in to comment.