Skip to content

Commit

Permalink
Update putStakingInfoList4Onto
Browse files Browse the repository at this point in the history
  • Loading branch information
leej1012 committed May 29, 2024
1 parent 9b093de commit 2e6af27
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ public ResponseBean getAddressStakingInfo(String address, String channel) {
try {
if (!publicKey.startsWith(ConstantParam.FAKE_NODE_PUBKEY_PREFIX)) {
String stakingInfo = sdk.getAuthorizeInfo(publicKey, address);
putStakingInfoList4Onto(stakingInfo, nodeInfoOffChain, nodeStakeDtos, currentRound);
putStakingInfoList4Onto(address, stakingInfo, nodeInfoOffChain, nodeStakeDtos, currentRound);
}
} catch (Exception e) {
log.error("getAddressStakingInfo error:{},{},{}", address, publicKey, e.getMessage());
Expand All @@ -1614,11 +1614,14 @@ public ResponseBean getAddressStakingInfo(String address, String channel) {
return new ResponseBean(ErrorInfo.SUCCESS.code(), ErrorInfo.SUCCESS.desc(), nodeStakeDtos);
}

private void putStakingInfoList4Onto(String stakingInfo, NodeInfoOffChain nodeInfoOffChain, List<NodeStakeDto> nodeStakeDtos, int currentRound) {
private void putStakingInfoList4Onto(String address, String stakingInfo, NodeInfoOffChain nodeInfoOffChain, List<NodeStakeDto> nodeStakeDtos, int currentRound) {
if (stakingInfo != null) {
String publicKey = nodeInfoOffChain.getPublicKey();
String nodeName = nodeInfoOffChain.getName();
String address = nodeInfoOffChain.getAddress();
String stakeWalletAddress = nodeInfoOffChain.getAddress();
if (address.equalsIgnoreCase(stakeWalletAddress)) {
return;
}
String progress = nodeInfoOffChain.getProgress();
Long totalPos = Optional.ofNullable(nodeInfoOffChain.getTotalPos()).orElse(0L);
Long maxAuthorize = Optional.ofNullable(nodeInfoOffChain.getMaxAuthorize()).orElse(0L);
Expand All @@ -1641,7 +1644,7 @@ private void putStakingInfoList4Onto(String stakingInfo, NodeInfoOffChain nodeIn
NodeStakeDto dto = new NodeStakeDto();
dto.setNodeName(nodeName);
dto.setNodePubKey(publicKey);
dto.setNodeWalletAddress(address);
dto.setNodeWalletAddress(stakeWalletAddress);
dto.setAmount(String.valueOf(stakedAmount));
if (newPos > 0) {
dto.setProcessingAmount(newPos.toString());
Expand All @@ -1660,7 +1663,7 @@ private void putStakingInfoList4Onto(String stakingInfo, NodeInfoOffChain nodeIn
NodeStakeDto dto = new NodeStakeDto();
dto.setNodeName(nodeName);
dto.setNodePubKey(publicKey);
dto.setNodeWalletAddress(address);
dto.setNodeWalletAddress(stakeWalletAddress);
dto.setAmount(withdrawUnfreezePos.toString());
dto.setState(StakeStatusEnum.WITHDRAWABLE.state());
dto.setNodeType(nodeType);
Expand All @@ -1677,7 +1680,7 @@ private void putStakingInfoList4Onto(String stakingInfo, NodeInfoOffChain nodeIn
NodeStakeDto dto = new NodeStakeDto();
dto.setNodeName(nodeName);
dto.setNodePubKey(publicKey);
dto.setNodeWalletAddress(address);
dto.setNodeWalletAddress(stakeWalletAddress);
dto.setAmount(Long.toString(amount));
dto.setState(StakeStatusEnum.CANCELLING.state());
dto.setNodeType(nodeType);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE tbl_node_info_on_chain ADD INDEX idx_public_key (public_key);

0 comments on commit 2e6af27

Please sign in to comment.