Search in sources :

Example 16 with DataAccount

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

the class LedgerQueryController method getDataEntriesTotalCount.

@RequestMapping(method = RequestMethod.GET, path = GET_KV_COUNT)
@Override
public long getDataEntriesTotalCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "address") String address) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerBlock block = ledger.getLatestBlock();
    DataAccountSet dataAccountSet = ledger.getDataAccountSet(block);
    DataAccount dataAccount = dataAccountSet.getAccount(Bytes.fromBase58(address));
    if (dataAccount == null) {
        return 0;
    }
    return dataAccount.getDataset().getDataCount();
}
Also used : DataAccount(com.jd.blockchain.ledger.core.DataAccount) LedgerBlock(com.jd.blockchain.ledger.LedgerBlock) LedgerQuery(com.jd.blockchain.ledger.core.LedgerQuery) DataAccountSet(com.jd.blockchain.ledger.core.DataAccountSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

DataAccount (com.jd.blockchain.ledger.core.DataAccount)16 TypedKVData (com.jd.blockchain.ledger.TypedKVData)11 BytesValue (com.jd.blockchain.ledger.BytesValue)10 TypedKVEntry (com.jd.blockchain.ledger.TypedKVEntry)9 LedgerBlock (com.jd.blockchain.ledger.LedgerBlock)6 DataAccountSet (com.jd.blockchain.ledger.core.DataAccountSet)6 LedgerQuery (com.jd.blockchain.ledger.core.LedgerQuery)4 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)4 KVDataVO (com.jd.blockchain.ledger.KVDataVO)3 IteratorDataset (com.jd.blockchain.ledger.core.IteratorDataset)3 ArrayList (java.util.ArrayList)3 DataEntry (utils.DataEntry)3 QueryArgs (utils.query.QueryArgs)3 HashDigest (com.jd.blockchain.crypto.HashDigest)2 BlockchainKeypair (com.jd.blockchain.ledger.BlockchainKeypair)2 DataVersionConflictException (com.jd.blockchain.ledger.DataVersionConflictException)2 SecurityPolicy (com.jd.blockchain.ledger.SecurityPolicy)2 LedgerEditor (com.jd.blockchain.ledger.core.LedgerEditor)2 LedgerManager (com.jd.blockchain.ledger.core.LedgerManager)2 LedgerRepository (com.jd.blockchain.ledger.core.LedgerRepository)2