use of com.jd.blockchain.ledger.LedgerBlock in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getTransactionByContentHash.
@RequestMapping(method = RequestMethod.GET, path = GET_TRANSACTION)
@Override
public LedgerTransaction getTransactionByContentHash(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "contentHash") HashDigest contentHash) {
LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
LedgerBlock block = ledger.getLatestBlock();
TransactionSet txset = ledger.getTransactionSet(block);
LedgerTransaction transaction = txset.getTransaction(contentHash);
// TODO: 去掉包装类,通过修正针对代理对象的 JSON 序列化来解决; by huanghaiquan at 2020-09-21;
return txDecorator(transaction);
}
use of com.jd.blockchain.ledger.LedgerBlock in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getDataAccountCount.
@RequestMapping(method = RequestMethod.GET, path = GET_DATA_ACCOUNT_COUNT_ON_BLOCK_HASH)
@Override
public long getDataAccountCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "blockHash") HashDigest blockHash) {
LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
LedgerBlock block = ledger.getBlock(blockHash);
if (null == block) {
return 0;
}
DataAccountSet dataAccountSet = ledger.getDataAccountSet(block);
return dataAccountSet.getTotal();
}
use of com.jd.blockchain.ledger.LedgerBlock in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getSystemEvents.
@RequestMapping(method = RequestMethod.GET, path = GET_SYSTEM_EVENT_SEQUENCE)
@Override
public Event[] getSystemEvents(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "eventName") String eventName, @RequestParam(name = "fromSequence", required = false, defaultValue = "0") long fromSequence, @RequestParam(name = "count", required = false, defaultValue = "-1") int count) {
LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
LedgerBlock block = ledger.getLatestBlock();
EventGroup systemEvents = ledger.getSystemEventGroup(block);
return systemEvents.getEvents(eventName, fromSequence, count);
}
use of com.jd.blockchain.ledger.LedgerBlock in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getUserCount.
@RequestMapping(method = RequestMethod.GET, path = GET_USER_COUNT_ON_BLOCK_HASH)
@Override
public long getUserCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "blockHash") HashDigest blockHash) {
LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
LedgerBlock block = ledger.getBlock(blockHash);
if (null == block) {
return 0;
}
UserAccountSet userAccountSet = ledger.getUserAccountSet(block);
return userAccountSet.getTotal();
}
use of com.jd.blockchain.ledger.LedgerBlock in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getSystemEventNameTotalCount.
@RequestMapping(method = RequestMethod.GET, path = GET_SYSTEM_EVENT_SUBJECT_COUNT)
@Override
public long getSystemEventNameTotalCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash) {
LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
LedgerBlock block = ledger.getLatestBlock();
EventGroup systemEvents = ledger.getSystemEventGroup(block);
return systemEvents.totalEventNames();
}
Aggregations