Search in sources :

Example 6 with TransactionSet

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

the class LedgerQueryController method getTransactionCount.

@RequestMapping(method = RequestMethod.GET, path = GET_TRANSACTION_COUNT_ON_BLOCK_HASH)
@Override
public long getTransactionCount(@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;
    }
    TransactionSet txSet = ledger.getTransactionSet(block);
    return txSet.getTotalCount();
}
Also used : LedgerBlock(com.jd.blockchain.ledger.LedgerBlock) LedgerQuery(com.jd.blockchain.ledger.core.LedgerQuery) TransactionSet(com.jd.blockchain.ledger.core.TransactionSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 7 with TransactionSet

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

the class LedgerQueryController method getTransactionStateByContentHash.

@RequestMapping(method = RequestMethod.GET, path = GET_TRANSACTION_STATE)
@Override
public TransactionState getTransactionStateByContentHash(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "contentHash") HashDigest contentHash) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerBlock block = ledger.getLatestBlock();
    TransactionSet txset = ledger.getTransactionSet(block);
    return txset.getState(contentHash);
}
Also used : LedgerBlock(com.jd.blockchain.ledger.LedgerBlock) LedgerQuery(com.jd.blockchain.ledger.core.LedgerQuery) TransactionSet(com.jd.blockchain.ledger.core.TransactionSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

LedgerBlock (com.jd.blockchain.ledger.LedgerBlock)7 LedgerQuery (com.jd.blockchain.ledger.core.LedgerQuery)7 TransactionSet (com.jd.blockchain.ledger.core.TransactionSet)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)7 LedgerTransaction (com.jd.blockchain.ledger.LedgerTransaction)3 QueryArgs (utils.query.QueryArgs)2