Skip to content

Commit

Permalink
Update getCurrentOnChainInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
leej1012 committed Jan 17, 2024
1 parent e5e6d91 commit 8d94c57
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
@Data
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class NodeInfoOnChainWithRankChange extends NodeInfoOnChain {
public class NodeInfoOnChainWithRankChange extends NodeInfoOnChainDto {

private Integer rankChange;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,35 @@

import com.fasterxml.jackson.annotation.JsonInclude;
import com.github.ontio.model.dao.NodeInfoOnChain;
import lombok.NoArgsConstructor;
import lombok.Data;

import javax.persistence.Column;
import javax.persistence.Table;

@Table(name = "tbl_node_info_on_chain")
@JsonInclude(JsonInclude.Include.NON_NULL)
@NoArgsConstructor
@Data
public class NodeInfoOnChainDto extends NodeInfoOnChain {

//@Builder
public NodeInfoOnChainDto(Integer nodeRank, String name, Long currentStake, String progress, String detailUrl,
String publicKey, String address, Integer status, Long initPos, Long totalPos,
Long maxAuthorize, String nodeProportion, String userProportion, String currentStakePercentage) {
super(nodeRank, name, currentStake, progress, detailUrl, publicKey, address, status, initPos, totalPos,
maxAuthorize, nodeProportion, userProportion, currentStakePercentage);
}
@Column(name = "fee_sharing_ratio")
private Integer feeSharingRatio;

@Column(name = "ontology_harbinger")
private Integer ontologyHarbinger;

private Integer risky;

@Column(name = "bad_actor")
private Integer badActor;

public NodeInfoOnChainDto() {

}
public NodeInfoOnChainDto(NodeInfoOnChainDto nodeInfoOnChain) {
super(nodeInfoOnChain);
this.feeSharingRatio = nodeInfoOnChain.getFeeSharingRatio();
this.ontologyHarbinger = nodeInfoOnChain.getOntologyHarbinger();
this.risky = nodeInfoOnChain.getRisky();
this.badActor = nodeInfoOnChain.getBadActor();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,26 @@
</cache>

<select id="selectAllInfo" resultType="com.github.ontio.model.dto.NodeInfoOnChainDto" useCache="true">
SELECT node_rank,
name,
current_stake,
progress,
detail_url,
public_key,
address,
status,
init_pos,
total_pos,
max_authorize,
node_proportion,
user_proportion,
current_stake_percentage
FROM tbl_node_info_on_chain
SELECT a.node_rank,
a.name,
a.current_stake,
a.progress,
a.detail_url,
a.public_key,
a.address,
a.status,
a.init_pos,
a.total_pos,
a.max_authorize,
a.node_proportion,
a.user_proportion,
a.current_stake_percentage,
b.ontology_harbinger,
b.fee_sharing_ratio,
b.risky,
b.bad_actor
FROM tbl_node_info_on_chain a
LEFT JOIN tbl_node_info_off_chain b ON a.public_key = b.public_key
</select>

<select id="selectTotalStake" resultType="java.lang.Long" useCache="true">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,17 @@
d.contract_hash as contractHash,
c.type AS assetType
FROM tbl_tx_detail d
INNER JOIN
(
SELECT DISTINCT tx_hash AS `hash`
FROM tbl_tx_detail_index
WHERE address = #{address}
<if test="assetName != '' and assetName != null">
AND asset_name = #{assetName}
</if>
ORDER BY desc_block_height, tx_hash, tx_index
LIMIT #{startIndex}, #{pageSize}
) idx ON idx.hash = d.tx_hash
<!-- INNER JOIN-->
<!-- (-->
<!-- SELECT DISTINCT tx_hash AS `hash`-->
<!-- FROM tbl_tx_detail_index-->
<!-- WHERE address = #{address}-->
<!-- <if test="assetName != '' and assetName != null">-->
<!-- AND asset_name = #{assetName}-->
<!-- </if>-->
<!-- ORDER BY desc_block_height, tx_hash, tx_index-->
<!-- LIMIT #{startIndex}, #{pageSize}-->
<!-- ) idx ON idx.hash = d.tx_hash-->
LEFT JOIN tbl_contract c ON d.contract_hash = c.contract_hash
WHERE (d.from_address = #{address}
OR d.to_address = #{address})
Expand All @@ -167,6 +167,7 @@
</if>
AND d.event_type IN (2, 3)
ORDER BY block_height DESC, block_index, tx_hash, tx_index
LIMIT #{startIndex}, #{pageSize}
</select>

<select id="selectTransferTxsByTime" resultType="com.github.ontio.model.dto.TransferTxDto">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ public int getRemoteBlockHeight() throws Exception {
* @throws Exception
*/
public JSONObject getBlockJsonByHeight(int height) throws Exception {
JSONObject blockObj = new JSONObject();
JSONObject blockObj;
int tryTime = 1;
while (true) {
try {
Expand Down Expand Up @@ -611,7 +611,7 @@ public String getOepSymbol(Boolean isWasm, String contract, String tokenId) {
InvokeWasmCode tx = ontSdk.wasmvm().makeInvokeCodeTransaction(contract, ConstantParam.FUN_SYMBOL, invokeParams, Address.ZERO, 20000, 2500);
JSONObject jsonObject = (JSONObject) ontSdk.getConnect().sendRawTransactionPreExec(tx.toHexString());
String result = jsonObject.getString("Result");
symbol = new String(Helper.hexToBytes(result));
symbol = new String(Helper.hexToBytes(result.substring(2)));
} else {
OntSdk ontSdk = ConstantParam.ONT_SDKSERVICE;
List<Object> paramList = new ArrayList<>();
Expand Down

0 comments on commit 8d94c57

Please sign in to comment.