use of com.jd.blockchain.ledger.core.LedgerQuery in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getContractCount.
@RequestMapping(method = RequestMethod.GET, path = GET_CONTRACT_COUNT_ON_BLOCK_HASH)
@Override
public long getContractCount(@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;
}
ContractAccountSet contractAccountSet = ledger.getContractAccountSet(block);
return contractAccountSet.getTotal();
}
use of com.jd.blockchain.ledger.core.LedgerQuery in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getUserEventAccounts.
@RequestMapping(method = RequestMethod.GET, path = GET_EVENT_ACCOUNT_SEQUENCE)
@Override
public BlockchainIdentity[] getUserEventAccounts(@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);
EventAccountSet eventAccountSet = ledger.getEventAccountSet(ledger.getLatestBlock());
QueryArgs queryArgs = QueryUtils.calFromIndexAndCount(fromIndex, count, (int) eventAccountSet.getTotal());
SkippingIterator<BlockchainIdentity> it = eventAccountSet.identityIterator();
it.skip(queryArgs.getFrom());
return it.next(queryArgs.getCount(), BlockchainIdentity.class);
}
use of com.jd.blockchain.ledger.core.LedgerQuery in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getTransactionTotalCount.
@RequestMapping(method = RequestMethod.GET, path = GET_TOTAL_TRANSACTION_COUNT)
@Override
public long getTransactionTotalCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash) {
LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
LedgerBlock block = ledger.getLatestBlock();
TransactionSet txSet = ledger.getTransactionSet(block);
return txSet.getTotalCount();
}
use of com.jd.blockchain.ledger.core.LedgerQuery in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getUsers.
/**
* get more users by fromIndex and count;
*
* @param ledgerHash
* @param fromIndex
* @param count
* @return
*/
@RequestMapping(method = RequestMethod.GET, path = GET_USER_SEQUENCE)
@Override
public BlockchainIdentity[] getUsers(@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();
UserAccountSet userAccountSet = ledger.getUserAccountSet(block);
QueryArgs queryArgs = QueryUtils.calFromIndexAndCountDescend(fromIndex, count, (int) userAccountSet.getTotal());
SkippingIterator<BlockchainIdentity> it = userAccountSet.identityIterator();
it.skip(queryArgs.getFrom());
return it.next(queryArgs.getCount(), BlockchainIdentity.class);
}
use of com.jd.blockchain.ledger.core.LedgerQuery in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getDataAccountTotalCount.
@RequestMapping(method = RequestMethod.GET, path = GET_TOTAL_DATA_ACCOUNT_COUNT)
@Override
public long getDataAccountTotalCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash) {
LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
LedgerBlock block = ledger.getLatestBlock();
DataAccountSet dataAccountSet = ledger.getDataAccountSet(block);
return dataAccountSet.getTotal();
}
Aggregations