Search in sources :

Example 16 with LedgerBlock

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

the class LedgerQueryController method getTransactionByContentHash.

@RequestMapping(method = RequestMethod.GET, path = GET_TRANSACTION)
@Override
public LedgerTransaction getTransactionByContentHash(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "contentHash") HashDigest contentHash) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerBlock block = ledger.getLatestBlock();
    TransactionSet txset = ledger.getTransactionSet(block);
    LedgerTransaction transaction = txset.getTransaction(contentHash);
    // TODO: 去掉包装类,通过修正针对代理对象的 JSON 序列化来解决; by huanghaiquan at 2020-09-21;
    return txDecorator(transaction);
}
Also used : LedgerBlock(com.jd.blockchain.ledger.LedgerBlock) LedgerQuery(com.jd.blockchain.ledger.core.LedgerQuery) TransactionSet(com.jd.blockchain.ledger.core.TransactionSet) LedgerTransaction(com.jd.blockchain.ledger.LedgerTransaction) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 17 with LedgerBlock

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

the class LedgerQueryController method getDataAccountCount.

@RequestMapping(method = RequestMethod.GET, path = GET_DATA_ACCOUNT_COUNT_ON_BLOCK_HASH)
@Override
public long getDataAccountCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "blockHash") HashDigest blockHash) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerBlock block = ledger.getBlock(blockHash);
    if (null == block) {
        return 0;
    }
    DataAccountSet dataAccountSet = ledger.getDataAccountSet(block);
    return dataAccountSet.getTotal();
}
Also used : 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)

Example 18 with LedgerBlock

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

the class LedgerQueryController method getSystemEvents.

@RequestMapping(method = RequestMethod.GET, path = GET_SYSTEM_EVENT_SEQUENCE)
@Override
public Event[] getSystemEvents(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "eventName") String eventName, @RequestParam(name = "fromSequence", required = false, defaultValue = "0") long fromSequence, @RequestParam(name = "count", required = false, defaultValue = "-1") int count) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerBlock block = ledger.getLatestBlock();
    EventGroup systemEvents = ledger.getSystemEventGroup(block);
    return systemEvents.getEvents(eventName, fromSequence, count);
}
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)

Example 19 with LedgerBlock

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

the class LedgerQueryController method getUserCount.

@RequestMapping(method = RequestMethod.GET, path = GET_USER_COUNT_ON_BLOCK_HASH)
@Override
public long getUserCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "blockHash") HashDigest blockHash) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerBlock block = ledger.getBlock(blockHash);
    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 20 with LedgerBlock

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

the class LedgerQueryController method getSystemEventNameTotalCount.

@RequestMapping(method = RequestMethod.GET, path = GET_SYSTEM_EVENT_SUBJECT_COUNT)
@Override
public long getSystemEventNameTotalCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerBlock block = ledger.getLatestBlock();
    EventGroup systemEvents = ledger.getSystemEventGroup(block);
    return systemEvents.totalEventNames();
}
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

LedgerBlock (com.jd.blockchain.ledger.LedgerBlock)53 LedgerQuery (com.jd.blockchain.ledger.core.LedgerQuery)36 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)36 QueryArgs (utils.query.QueryArgs)10 LedgerTransaction (com.jd.blockchain.ledger.LedgerTransaction)9 DataAccountSet (com.jd.blockchain.ledger.core.DataAccountSet)9 LedgerEditor (com.jd.blockchain.ledger.core.LedgerEditor)9 Test (org.junit.Test)9 BlockchainKeypair (com.jd.blockchain.ledger.BlockchainKeypair)8 TransactionRequest (com.jd.blockchain.ledger.TransactionRequest)8 LedgerRepository (com.jd.blockchain.ledger.core.LedgerRepository)8 HashDigest (com.jd.blockchain.crypto.HashDigest)7 LedgerManager (com.jd.blockchain.ledger.core.LedgerManager)7 TransactionSet (com.jd.blockchain.ledger.core.TransactionSet)7 MemoryKVStorage (com.jd.blockchain.storage.service.utils.MemoryKVStorage)7 ContractAccountSet (com.jd.blockchain.ledger.core.ContractAccountSet)6 DataAccount (com.jd.blockchain.ledger.core.DataAccount)6 UserAccount (com.jd.blockchain.ledger.core.UserAccount)6 TransactionResponse (com.jd.blockchain.ledger.TransactionResponse)5 DefaultOperationHandleRegisteration (com.jd.blockchain.ledger.core.DefaultOperationHandleRegisteration)5