Search in sources :

Example 1 with EventAccountSet

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

the class ContractLedgerQueryService method getUserEventAccounts.

@Override
public BlockchainIdentity[] getUserEventAccounts(int fromIndex, int count) {
    EventAccountSet eventAccountSet = ledgerQuery.getLedgerEventSet().getEventAccountSet();
    QueryArgs queryArgs = QueryUtils.calFromIndexAndCountDescend(fromIndex, count, (int) eventAccountSet.getTotal());
    SkippingIterator<BlockchainIdentity> it = eventAccountSet.identityIterator();
    it.skip(queryArgs.getFrom());
    return it.next(queryArgs.getCount(), BlockchainIdentity.class);
}
Also used : QueryArgs(utils.query.QueryArgs) BlockchainIdentity(com.jd.blockchain.ledger.BlockchainIdentity) EventAccountSet(com.jd.blockchain.ledger.core.EventAccountSet)

Example 2 with EventAccountSet

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

the class UncommittedLedgerQueryService method getUserEventAccounts.

@Override
public BlockchainIdentity[] getUserEventAccounts(int fromIndex, int count) {
    EventAccountSet eventAccountSet = transactionContext.getEventSet().getEventAccountSet();
    QueryArgs queryArgs = QueryUtils.calFromIndexAndCountDescend(fromIndex, count, (int) eventAccountSet.getTotal());
    SkippingIterator<BlockchainIdentity> it = eventAccountSet.identityIterator();
    it.skip(queryArgs.getFrom());
    return it.next(queryArgs.getCount(), BlockchainIdentity.class);
}
Also used : QueryArgs(utils.query.QueryArgs) BlockchainIdentity(com.jd.blockchain.ledger.BlockchainIdentity) EventAccountSet(com.jd.blockchain.ledger.core.EventAccountSet)

Example 3 with EventAccountSet

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

the class LedgerQueryController method getUserEventNameTotalCount.

@RequestMapping(method = RequestMethod.GET, path = GET_EVENT_SUBJECT_COUNT)
@Override
public long getUserEventNameTotalCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "address") String address) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    EventAccountSet eventAccountSet = ledger.getEventAccountSet(ledger.getLatestBlock());
    EventPublishingAccount account = eventAccountSet.getAccount(address);
    if (null == account) {
        return 0;
    }
    return account.totalEventNames();
}
Also used : LedgerQuery(com.jd.blockchain.ledger.core.LedgerQuery) EventPublishingAccount(com.jd.blockchain.ledger.core.EventPublishingAccount) EventAccountSet(com.jd.blockchain.ledger.core.EventAccountSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with EventAccountSet

use of com.jd.blockchain.ledger.core.EventAccountSet 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);
}
Also used : LedgerQuery(com.jd.blockchain.ledger.core.LedgerQuery) QueryArgs(utils.query.QueryArgs) BlockchainIdentity(com.jd.blockchain.ledger.BlockchainIdentity) EventAccountSet(com.jd.blockchain.ledger.core.EventAccountSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 5 with EventAccountSet

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

the class LedgerQueryController method getUserEventAccount.

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

Aggregations

EventAccountSet (com.jd.blockchain.ledger.core.EventAccountSet)6 LedgerQuery (com.jd.blockchain.ledger.core.LedgerQuery)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 BlockchainIdentity (com.jd.blockchain.ledger.BlockchainIdentity)3 QueryArgs (utils.query.QueryArgs)3 EventPublishingAccount (com.jd.blockchain.ledger.core.EventPublishingAccount)1