diff --git a/back-end-projects/Explorer/src/main/java/com/github/ontio/controller/SummaryController.java b/back-end-projects/Explorer/src/main/java/com/github/ontio/controller/SummaryController.java index 6502b301..a90d01b2 100644 --- a/back-end-projects/Explorer/src/main/java/com/github/ontio/controller/SummaryController.java +++ b/back-end-projects/Explorer/src/main/java/com/github/ontio/controller/SummaryController.java @@ -13,7 +13,6 @@ @Slf4j @RestController -@RequestMapping(value = "/v2/summary") public class SummaryController { private final String CLASS_NAME = this.getClass().getSimpleName(); @@ -27,7 +26,7 @@ public SummaryController(SummaryServiceImpl summaryService) { @ApiOperation(value = "Get blockchain latest summary information") - @GetMapping(value = "/blockchain/latest-info") + @GetMapping(value = "/v2/summary/blockchain/latest-info") public ResponseBean getBlockChainLatestInfo() { log.info("####{}.{} begin...", CLASS_NAME, Helper.currentMethod()); @@ -35,7 +34,7 @@ public ResponseBean getBlockChainLatestInfo() { } @ApiOperation(value = "Get blockchain tps information") - @GetMapping(value = "/blockchain/tps") + @GetMapping(value = "/v2/summary/blockchain/tps") public ResponseBean getBlockChainTps() { log.info("####{}.{} begin...", CLASS_NAME, Helper.currentMethod()); @@ -45,7 +44,7 @@ public ResponseBean getBlockChainTps() { @RequestLimit(count = 120) @ApiOperation(value = "Get blockchain daily summary information") - @GetMapping(value = "/blockchain/daily") + @GetMapping(value = "/v2/summary/blockchain/daily") public ResponseBean getBlockChainSummary(@RequestParam("start_time") Long startTime, @RequestParam("end_time") Long endTime) { @@ -60,7 +59,7 @@ public ResponseBean getBlockChainSummary(@RequestParam("start_time") Long startT @RequestLimit(count = 120) @ApiOperation(value = "Get contract daily summary information") - @GetMapping(value = "/contracts/{contract_hash}/daily") + @GetMapping(value = "/v2/summary/contracts/{contract_hash}/daily") public ResponseBean getContractSummary(@PathVariable("contract_hash") @Length(min = 40, max = 40, message = "Incorrect contract hash") String contractHash, @RequestParam("start_time") Long startTime, @RequestParam("end_time") Long endTime) { @@ -72,4 +71,24 @@ public ResponseBean getContractSummary(@PathVariable("contract_hash") @Length(mi } return summaryService.getContractDailySummary(contractHash, startTime, endTime); } + + + @ApiOperation(value = "Get ONT,ONG total supply") + @GetMapping(value = "/v2/summary/native/totalsupply") + public ResponseBean queryNativeTotalSupply() { + log.info("####{}.{} begin...", CLASS_NAME, Helper.currentMethod()); + ResponseBean rs = summaryService.getNativeTotalSupply(); + return rs; + } + + + @ApiOperation(value = "Get ONT,ONG total supply") + @GetMapping(value = "/api/v1/explorer/summary/native/totalsupply") + public ResponseBean queryNativeTotalSupplyV1() { + log.info("####{}.{} begin...", CLASS_NAME, Helper.currentMethod()); + ResponseBean rs = summaryService.getNativeTotalSupply(); + return rs; + } + + } diff --git a/back-end-projects/Explorer/src/main/java/com/github/ontio/service/ISummaryService.java b/back-end-projects/Explorer/src/main/java/com/github/ontio/service/ISummaryService.java index e8054cc5..3500f237 100644 --- a/back-end-projects/Explorer/src/main/java/com/github/ontio/service/ISummaryService.java +++ b/back-end-projects/Explorer/src/main/java/com/github/ontio/service/ISummaryService.java @@ -11,4 +11,7 @@ public interface ISummaryService { ResponseBean getBlockChainDailySummary(Long startTime, Long endTime); ResponseBean getContractDailySummary(String contractHash, Long startTime, Long endTime); + + ResponseBean getNativeTotalSupply(); + } diff --git a/back-end-projects/Explorer/src/main/java/com/github/ontio/service/impl/SummaryServiceImpl.java b/back-end-projects/Explorer/src/main/java/com/github/ontio/service/impl/SummaryServiceImpl.java index 32730fb3..246a6d0b 100644 --- a/back-end-projects/Explorer/src/main/java/com/github/ontio/service/impl/SummaryServiceImpl.java +++ b/back-end-projects/Explorer/src/main/java/com/github/ontio/service/impl/SummaryServiceImpl.java @@ -11,6 +11,7 @@ import com.github.ontio.util.ConstantParam; import com.github.ontio.util.ErrorInfo; import com.github.ontio.util.Helper; +import com.github.ontio.util.OntologySDKService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -25,21 +26,26 @@ @Service("SummaryService") public class SummaryServiceImpl implements ISummaryService { + private static final Integer TIMESTAMP_20190630000000_UTC = 1561852800; + private static final Integer TIMESTAMP_20180630000000_UTC = 1530316800; + private final ParamsConfig paramsConfig; private final TxEventLogMapper txEventLogMapper; private final DailySummaryMapper dailySummaryMapper; private final ContractDailySummaryMapper contractDailySummaryMapper; private final CurrentMapper currentMapper; private final AddressDailySummaryMapper addressDailySummaryMapper; + private final OntologySDKService ontologySDKService; @Autowired - public SummaryServiceImpl(ParamsConfig paramsConfig, TxEventLogMapper txEventLogMapper, DailySummaryMapper dailySummaryMapper, ContractDailySummaryMapper contractDailySummaryMapper, CurrentMapper currentMapper, AddressDailySummaryMapper addressDailySummaryMapper) { + public SummaryServiceImpl(ParamsConfig paramsConfig, TxEventLogMapper txEventLogMapper, DailySummaryMapper dailySummaryMapper, ContractDailySummaryMapper contractDailySummaryMapper, CurrentMapper currentMapper, AddressDailySummaryMapper addressDailySummaryMapper, OntologySDKService ontologySDKService) { this.paramsConfig = paramsConfig; this.txEventLogMapper = txEventLogMapper; this.dailySummaryMapper = dailySummaryMapper; this.contractDailySummaryMapper = contractDailySummaryMapper; this.currentMapper = currentMapper; this.addressDailySummaryMapper = addressDailySummaryMapper; + this.ontologySDKService = ontologySDKService; } @@ -115,4 +121,27 @@ public ResponseBean getContractDailySummary(String contractHash, Long startTime, return new ResponseBean(ErrorInfo.SUCCESS.code(), ErrorInfo.SUCCESS.desc(), pageResponseBean); } + + + @Override + public ResponseBean getNativeTotalSupply() { + + BigDecimal specialAddrOnt = new BigDecimal("0"); + for (String addr : + ConstantParam.SPECIALADDRLIST) { + Map map = ontologySDKService.getNativeAssetBalance(addr); + specialAddrOnt = specialAddrOnt.add(new BigDecimal(map.get("ont"))); + } + BigDecimal ontTotalSupply = ConstantParam.ONT_TOTAL.subtract(specialAddrOnt); + + BigDecimal ong01 = new BigDecimal(TIMESTAMP_20190630000000_UTC).subtract(new BigDecimal(TIMESTAMP_20180630000000_UTC)).multiply(new BigDecimal(5)); + BigDecimal ong02 = new BigDecimal(System.currentTimeMillis() / 1000L).subtract(new BigDecimal(TIMESTAMP_20190630000000_UTC)).multiply(paramsConfig.ONG_SECOND_GENERATE); + BigDecimal totalOng = ong01.add(ong02); + BigDecimal ongTotalSupply = totalOng.multiply(ontTotalSupply).divide(ConstantParam.ONT_TOTAL); + + Map rsMap = new HashMap<>(); + rsMap.put("ong", ongTotalSupply); + rsMap.put("ont", ontTotalSupply); + return new ResponseBean(ErrorInfo.SUCCESS.code(), ErrorInfo.SUCCESS.desc(), rsMap); + } } diff --git a/back-end-projects/Explorer/src/main/java/com/github/ontio/util/ConstantParam.java b/back-end-projects/Explorer/src/main/java/com/github/ontio/util/ConstantParam.java index 39e814a7..792f8fc3 100644 --- a/back-end-projects/Explorer/src/main/java/com/github/ontio/util/ConstantParam.java +++ b/back-end-projects/Explorer/src/main/java/com/github/ontio/util/ConstantParam.java @@ -79,7 +79,15 @@ public class ConstantParam { //技术社区奖励锁仓地址 "AcdUMgeF16ScW9ts3kiD3pZkjYRMdYwtVQ", //生态合作地址 - "AMX6ZebrPDFELCYRMpSMbZWrhWkKbKg4y8"); + "AMX6ZebrPDFELCYRMpSMbZWrhWkKbKg4y8", + //oge 地址 + "ARHGtgY9Z8HdChFEjdPKKhpT4WDKfVntfC", + //社区地址 + "ATBdqiUBKnNoJE4L53UkZZjWyFjd1AdamL", + //NEO counsel + "AR36E5jLdWDKW3Yg51qDFWPGKSLvfPhbqS", + //NGC + "Af48R4EUNYm6kg9kS7rn5xj4fneuFpbkXi"); //资产类型