Search in sources :

Example 6 with UserAccountSet

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

the class ContractLedgerQueryService method getUsers.

@Override
public BlockchainIdentity[] getUsers(int fromIndex, int count) {
    UserAccountSet userAccountSet = ledgerQuery.getUserAccountSet();
    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);
}
Also used : QueryArgs(utils.query.QueryArgs) BlockchainIdentity(com.jd.blockchain.ledger.BlockchainIdentity) UserAccountSet(com.jd.blockchain.ledger.core.UserAccountSet)

Example 7 with UserAccountSet

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

the class UncommittedLedgerQueryService method getUsers.

@Override
public BlockchainIdentity[] getUsers(int fromIndex, int count) {
    UserAccountSet userAccountSet = transactionContext.getDataset().getUserAccountSet();
    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);
}
Also used : QueryArgs(utils.query.QueryArgs) BlockchainIdentity(com.jd.blockchain.ledger.BlockchainIdentity) UserAccountSet(com.jd.blockchain.ledger.core.UserAccountSet)

Example 8 with UserAccountSet

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

the class LedgerQueryController method getUser.

@RequestMapping(method = RequestMethod.GET, path = GET_USER)
@Override
public UserInfo getUser(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "address") String address) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerBlock block = ledger.getLatestBlock();
    UserAccountSet userAccountSet = ledger.getUserAccountSet(block);
    return userAccountSet.getAccount(address);
}
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 9 with UserAccountSet

use of com.jd.blockchain.ledger.core.UserAccountSet 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)

Aggregations

UserAccountSet (com.jd.blockchain.ledger.core.UserAccountSet)9 LedgerBlock (com.jd.blockchain.ledger.LedgerBlock)5 LedgerQuery (com.jd.blockchain.ledger.core.LedgerQuery)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 BlockchainIdentity (com.jd.blockchain.ledger.BlockchainIdentity)3 QueryArgs (utils.query.QueryArgs)3 MemoryKVStorage (com.jd.blockchain.storage.service.utils.MemoryKVStorage)2 Test (org.junit.Test)2 HashDigest (com.jd.blockchain.crypto.HashDigest)1 BlockchainKeypair (com.jd.blockchain.ledger.BlockchainKeypair)1 LedgerPermission (com.jd.blockchain.ledger.LedgerPermission)1 Privileges (com.jd.blockchain.ledger.Privileges)1 SecurityPolicy (com.jd.blockchain.ledger.SecurityPolicy)1 TransactionPermission (com.jd.blockchain.ledger.TransactionPermission)1 ContractAccountSet (com.jd.blockchain.ledger.core.ContractAccountSet)1 DataAccountSet (com.jd.blockchain.ledger.core.DataAccountSet)1 DataAccountSetEditor (com.jd.blockchain.ledger.core.DataAccountSetEditor)1 LedgerDataSetEditor (com.jd.blockchain.ledger.core.LedgerDataSetEditor)1 LedgerEditor (com.jd.blockchain.ledger.core.LedgerEditor)1 LedgerManager (com.jd.blockchain.ledger.core.LedgerManager)1