use of com.jd.blockchain.ledger.core.LedgerQuery 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.core.LedgerQuery 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.core.LedgerQuery 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.core.LedgerQuery 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();
}
use of com.jd.blockchain.ledger.core.LedgerQuery in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getDataAccounts.
/**
* get more dataAccounts by fromIndex and count;
*
* @param ledgerHash
* @param fromIndex
* @param count
* @return
*/
@RequestMapping(method = RequestMethod.GET, path = GET_DATA_ACCOUNT_SEQUENCE)
@Override
public BlockchainIdentity[] getDataAccounts(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @RequestParam(name = "fromIndex", required = false, defaultValue = "0") int fromIndex, @RequestParam(name = "count", required = false, defaultValue = "-1") int count) {
LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
LedgerBlock block = ledger.getLatestBlock();
DataAccountSet dataAccountSet = ledger.getDataAccountSet(block);
QueryArgs queryArgs = QueryUtils.calFromIndexAndCountDescend(fromIndex, count, (int) dataAccountSet.getTotal());
SkippingIterator<BlockchainIdentity> it = dataAccountSet.identityIterator();
it.skip(queryArgs.getFrom());
return it.next(queryArgs.getCount(), BlockchainIdentity.class);
}
Aggregations