Search in sources :

Example 1 with EventGroup

use of com.jd.blockchain.ledger.core.EventGroup 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 2 with EventGroup

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

Example 3 with EventGroup

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

the class LedgerQueryController method getSystemEventNames.

@RequestMapping(method = RequestMethod.GET, path = GET_SYSTEM_EVENT_SUBJECTS)
@Override
public String[] getSystemEventNames(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @RequestParam(name = "fromIndex", required = false, defaultValue = "0") int fromIndex, @RequestParam(name = "maxCount", required = false, defaultValue = "-1") int count) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerBlock block = ledger.getLatestBlock();
    EventGroup systemEvents = ledger.getSystemEventGroup(block);
    QueryArgs queryArgs = QueryUtils.calFromIndexAndCount(fromIndex, count, (int) systemEvents.totalEventNames());
    return systemEvents.getEventNames(queryArgs.getFrom(), queryArgs.getCount());
}
Also used : LedgerBlock(com.jd.blockchain.ledger.LedgerBlock) LedgerQuery(com.jd.blockchain.ledger.core.LedgerQuery) QueryArgs(utils.query.QueryArgs) EventGroup(com.jd.blockchain.ledger.core.EventGroup) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 4 with EventGroup

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

the class LedgerQueryController method getLatestSystemEvent.

@RequestMapping(method = RequestMethod.GET, path = GET_LATEST_SYSTEM_EVENT)
@Override
public Event getLatestSystemEvent(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "eventName") String eventName) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerBlock block = ledger.getLatestBlock();
    EventGroup systemEvents = ledger.getSystemEventGroup(block);
    return systemEvents.getLatest(eventName);
}
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 5 with EventGroup

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

the class LedgerQueryController method getSystemEventsTotalCount.

@RequestMapping(method = RequestMethod.GET, path = GET_SYSTEM_EVENT_COUNT)
@Override
public long getSystemEventsTotalCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "eventName") String eventName) {
    LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
    LedgerBlock block = ledger.getLatestBlock();
    EventGroup systemEvents = ledger.getSystemEventGroup(block);
    return systemEvents.totalEvents(eventName);
}
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)5 EventGroup (com.jd.blockchain.ledger.core.EventGroup)5 LedgerQuery (com.jd.blockchain.ledger.core.LedgerQuery)5 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 QueryArgs (utils.query.QueryArgs)1