Skip to content

Commit

Permalink
Update getCurrentStake
Browse files Browse the repository at this point in the history
  • Loading branch information
leej1012 committed Jul 24, 2024
1 parent 9acf874 commit 24123e6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ public ResponseBean getCurrentTotalStake() {

@ApiOperation(value = "Get candidate nodes information")
@GetMapping(value = "/current-stakes")
public ResponseBean getCurrentStake() {
List<NodeInfoOnChainWithRankChange> nodeInfoList = nodesService.getCurrentOnChainInfo();
public ResponseBean getCurrentStake(@RequestParam(value = "public_key", required = false) String publicKey) {
List<NodeInfoOnChainWithRankChange> nodeInfoList = nodesService.getCurrentOnChainStakeInfo(publicKey);
if (nodeInfoList.size() == 0) {
return new ResponseBean(ErrorInfo.NOT_FOUND.code(), ErrorInfo.NOT_FOUND.desc(), nodeInfoList);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
@Repository
public interface NodeInfoOnChainMapper extends Mapper<NodeInfoOnChain> {

List<NodeInfoOnChainDto> selectAllInfo();
List<NodeInfoOnChainDto> selectAllInfo(String publicKey);

Long selectTotalStake();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public class NodeInfoOnChainDto extends NodeInfoOnChain {
@Transient
private Integer badActor;

@Transient
private String userApy;

public NodeInfoOnChainDto() {

}
Expand All @@ -42,5 +45,6 @@ public NodeInfoOnChainDto(NodeInfoOnChainDto nodeInfoOnChain) {
this.ontologyHarbinger = nodeInfoOnChain.getOntologyHarbinger();
this.risky = nodeInfoOnChain.getRisky();
this.badActor = nodeInfoOnChain.getBadActor();
this.userApy = nodeInfoOnChain.getUserApy();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

public interface INodesService {

List<NodeInfoOnChainWithRankChange> getCurrentOnChainInfo();
List<NodeInfoOnChainWithRankChange> getCurrentOnChainStakeInfo(String publicKey);

NodeInfoOffChain getCurrentOffChainInfo(String publicKey, Integer openFlag);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ private Map<String, NodeRankChange> getNodeRankChange() {
}

@Override
public List<NodeInfoOnChainWithRankChange> getCurrentOnChainInfo() {
public List<NodeInfoOnChainWithRankChange> getCurrentOnChainStakeInfo(String publicKey) {
try {
List<NodeInfoOnChainDto> nodeInfoOnChainList = nodeInfoOnChainMapper.selectAllInfo();
List<NodeInfoOnChainDto> nodeInfoOnChainList = nodeInfoOnChainMapper.selectAllInfo(publicKey);
Map<String, NodeRankChange> nodeRankChangeMap = getNodeRankChange();
List<NodeInfoOnChainWithRankChange> nodeInfoOnChainWithRankChanges = new ArrayList<>();
for (NodeInfoOnChainDto nodeInfo : nodeInfoOnChainList) {
Expand Down Expand Up @@ -320,7 +320,7 @@ public List<NodeInfoOnChainWithBonus> getLatestBonusesWithInfos() {
List<NodeInfoOnChainDto> nodeInfoOnChainLst;
List<NodeBonus> nodeBonusLst;
try {
nodeInfoOnChainLst = nodeInfoOnChainMapper.selectAllInfo();
nodeInfoOnChainLst = nodeInfoOnChainMapper.selectAllInfo(null);
int nodeCount = nodeBonusMapper.selectNodeCount();
nodeBonusLst = nodeBonusMapper.selectLatestNodeBonusList(nodeCount);
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@
b.ontology_harbinger,
b.fee_sharing_ratio,
b.risky,
b.bad_actor
b.bad_actor,
IFNULL(c.user_apy,'0.00%') as user_apy
FROM tbl_node_info_on_chain a
LEFT JOIN tbl_node_info_off_chain b ON a.public_key = b.public_key
LEFT JOIN tbl_node_inspire c ON a.public_key = c.public_key
<where>
<if test="publicKey != null and publicKey !=''">
AND a.public_key = #{publicKey}
</if>
</where>
</select>

<select id="selectTotalStake" resultType="java.lang.Long" useCache="true">
Expand Down

0 comments on commit 24123e6

Please sign in to comment.