Search in sources :

Example 41 with LedgerQuery

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_HEIGHT)
@Override
public long getUserCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "blockHeight") long height) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerBlock block = ledger.getBlock(height);
    if (null == block) {
        return 0;
    }
    UserAccountSet userAccountSet = ledger.getUserAccountSet(block);
    return userAccountSet.getTotal();
}
Also used : LedgerBlock(com.jd.blockchain.ledger.LedgerBlock) LedgerQuery(com.jd.blockchain.ledger.core.LedgerQuery) UserAccountSet(com.jd.blockchain.ledger.core.UserAccountSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 42 with LedgerQuery

use of com.jd.blockchain.ledger.core.LedgerQuery in project jdchain-core by blockchain-jd-com.

the class LedgerQueryController method getUserEventAccountTotalCount.

@RequestMapping(method = RequestMethod.GET, path = GET_TOTAL_EVENT_ACCOUNT_COUNT)
@Override
public long getUserEventAccountTotalCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    EventAccountSet eventAccountSet = ledger.getEventAccountSet(ledger.getLatestBlock());
    return eventAccountSet.getTotal();
}
Also used : LedgerQuery(com.jd.blockchain.ledger.core.LedgerQuery) EventAccountSet(com.jd.blockchain.ledger.core.EventAccountSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 43 with LedgerQuery

use of com.jd.blockchain.ledger.core.LedgerQuery in project jdchain-core by blockchain-jd-com.

the class LedgerQueryController method getUserEventNames.

@RequestMapping(method = RequestMethod.GET, path = GET_EVENT_SUBJECTS)
@Override
public String[] getUserEventNames(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "address") String address, @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();
    EventPublishingAccount account = ledger.getEventAccountSet(block).getAccount(address);
    if (null == account) {
        return null;
    }
    QueryArgs queryArgs = QueryUtils.calFromIndexAndCount(fromIndex, count, (int) account.totalEventNames());
    return account.getEventNames(queryArgs.getFrom(), queryArgs.getCount());
}
Also used : LedgerBlock(com.jd.blockchain.ledger.LedgerBlock) LedgerQuery(com.jd.blockchain.ledger.core.LedgerQuery) QueryArgs(utils.query.QueryArgs) EventPublishingAccount(com.jd.blockchain.ledger.core.EventPublishingAccount) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 44 with LedgerQuery

use of com.jd.blockchain.ledger.core.LedgerQuery in project jdchain-core by blockchain-jd-com.

the class LedgerQueryController method getLedgerAdminInfo.

@RequestMapping(method = RequestMethod.GET, path = GET_LEDGER_ADMIN_INFO)
@Override
public LedgerAdminInfo getLedgerAdminInfo(@PathVariable(name = "ledgerHash") HashDigest ledgerHash) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerAdminInfo ledgerAdministration = ledger.getAdminInfo();
    return ledgerAdminInfoDecorator(ledgerAdministration);
}
Also used : LedgerAdminInfo(com.jd.blockchain.ledger.LedgerAdminInfo) LedgerQuery(com.jd.blockchain.ledger.core.LedgerQuery) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 45 with LedgerQuery

use of com.jd.blockchain.ledger.core.LedgerQuery in project jdchain-core by blockchain-jd-com.

the class LedgerQueryController method getSystemEventsTotalCount.

@RequestMapping(method = RequestMethod.GET, path = GET_SYSTEM_EVENT_COUNT)
@Override
public long getSystemEventsTotalCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "eventName") String eventName) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerBlock block = ledger.getLatestBlock();
    EventGroup systemEvents = ledger.getSystemEventGroup(block);
    return systemEvents.totalEvents(eventName);
}
Also used : LedgerBlock(com.jd.blockchain.ledger.LedgerBlock) LedgerQuery(com.jd.blockchain.ledger.core.LedgerQuery) EventGroup(com.jd.blockchain.ledger.core.EventGroup) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

LedgerQuery (com.jd.blockchain.ledger.core.LedgerQuery)45 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)45 LedgerBlock (com.jd.blockchain.ledger.LedgerBlock)36 QueryArgs (utils.query.QueryArgs)11 DataAccountSet (com.jd.blockchain.ledger.core.DataAccountSet)9 TransactionSet (com.jd.blockchain.ledger.core.TransactionSet)7 ContractAccountSet (com.jd.blockchain.ledger.core.ContractAccountSet)6 LedgerTransaction (com.jd.blockchain.ledger.LedgerTransaction)5 EventGroup (com.jd.blockchain.ledger.core.EventGroup)5 EventPublishingAccount (com.jd.blockchain.ledger.core.EventPublishingAccount)5 UserAccountSet (com.jd.blockchain.ledger.core.UserAccountSet)5 BlockchainIdentity (com.jd.blockchain.ledger.BlockchainIdentity)4 DataAccount (com.jd.blockchain.ledger.core.DataAccount)4 EventAccountSet (com.jd.blockchain.ledger.core.EventAccountSet)4 TypedKVData (com.jd.blockchain.ledger.TypedKVData)3 TypedKVEntry (com.jd.blockchain.ledger.TypedKVEntry)3 BytesValue (com.jd.blockchain.ledger.BytesValue)2 LedgerAdminInfo (com.jd.blockchain.ledger.LedgerAdminInfo)2 ContractException (com.jd.blockchain.contract.ContractException)1 KVDataVO (com.jd.blockchain.ledger.KVDataVO)1