Search in sources :

Example 1 with QueryArgs

use of utils.query.QueryArgs in project jdchain-core by blockchain-jd-com.

the class ContractLedgerQueryService method getDataEntries.

@Override
public TypedKVEntry[] getDataEntries(String address, int fromIndex, int count) {
    DataAccountSet dataAccountSet = ledgerQuery.getDataAccountSet();
    DataAccount dataAccount = dataAccountSet.getAccount(Bytes.fromBase58(address));
    QueryArgs queryArgs = QueryUtils.calFromIndexAndCount(fromIndex, count, (int) dataAccount.getDataset().getDataCount());
    SkippingIterator<DataEntry<String, TypedValue>> iterator = ((IteratorDataset) dataAccount.getDataset()).kvIterator();
    iterator.skip(queryArgs.getFrom());
    TypedKVEntry[] typedKVEntries = iterator.next(queryArgs.getCount(), TypedKVEntry.class, entry -> new TypedKVData(entry.getKey(), entry.getVersion(), entry.getValue()));
    return typedKVEntries;
}
Also used : DataAccount(com.jd.blockchain.ledger.core.DataAccount) DataEntry(utils.DataEntry) TypedKVEntry(com.jd.blockchain.ledger.TypedKVEntry) TypedKVData(com.jd.blockchain.ledger.TypedKVData) QueryArgs(utils.query.QueryArgs) IteratorDataset(com.jd.blockchain.ledger.core.IteratorDataset) DataAccountSet(com.jd.blockchain.ledger.core.DataAccountSet)

Example 2 with QueryArgs

use of utils.query.QueryArgs 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 3 with QueryArgs

use of utils.query.QueryArgs 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 4 with QueryArgs

use of utils.query.QueryArgs in project jdchain-core by blockchain-jd-com.

the class UncommittedLedgerQueryService method getContractAccounts.

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

Example 5 with QueryArgs

use of utils.query.QueryArgs in project jdchain-core by blockchain-jd-com.

the class UncommittedLedgerQueryService method getDataAccounts.

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

Aggregations

QueryArgs (utils.query.QueryArgs)30 BlockchainIdentity (com.jd.blockchain.ledger.BlockchainIdentity)12 LedgerQuery (com.jd.blockchain.ledger.core.LedgerQuery)11 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)11 LedgerBlock (com.jd.blockchain.ledger.LedgerBlock)10 DataAccountSet (com.jd.blockchain.ledger.core.DataAccountSet)6 LedgerTransaction (com.jd.blockchain.ledger.LedgerTransaction)4 DataEntry (utils.DataEntry)4 TypedKVData (com.jd.blockchain.ledger.TypedKVData)3 TypedKVEntry (com.jd.blockchain.ledger.TypedKVEntry)3 ContractAccountSet (com.jd.blockchain.ledger.core.ContractAccountSet)3 DataAccount (com.jd.blockchain.ledger.core.DataAccount)3 EventAccountSet (com.jd.blockchain.ledger.core.EventAccountSet)3 IteratorDataset (com.jd.blockchain.ledger.core.IteratorDataset)3 UserAccountSet (com.jd.blockchain.ledger.core.UserAccountSet)3 TransactionSet (com.jd.blockchain.ledger.core.TransactionSet)2 HashDigest (com.jd.blockchain.crypto.HashDigest)1 ParticipantNode (com.jd.blockchain.ledger.ParticipantNode)1 TypedValue (com.jd.blockchain.ledger.TypedValue)1 EventGroup (com.jd.blockchain.ledger.core.EventGroup)1