use of com.jd.blockchain.ledger.core.EventPublishingAccount in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getUserEvents.
@RequestMapping(method = RequestMethod.GET, path = GET_EVENT_SEQUENCE)
@Override
public Event[] getUserEvents(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "address") String address, @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();
EventPublishingAccount account = ledger.getEventAccountSet(block).getAccount(address);
if (null == account) {
return null;
}
return account.getEvents(eventName, fromSequence, count);
}
use of com.jd.blockchain.ledger.core.EventPublishingAccount in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getUserEventNameTotalCount.
@RequestMapping(method = RequestMethod.GET, path = GET_EVENT_SUBJECT_COUNT)
@Override
public long getUserEventNameTotalCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "address") String address) {
LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
EventAccountSet eventAccountSet = ledger.getEventAccountSet(ledger.getLatestBlock());
EventPublishingAccount account = eventAccountSet.getAccount(address);
if (null == account) {
return 0;
}
return account.totalEventNames();
}
use of com.jd.blockchain.ledger.core.EventPublishingAccount in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getLatestUserEvent.
@RequestMapping(method = RequestMethod.GET, path = GET_LATEST_EVENT)
@Override
public Event getLatestUserEvent(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "address") String address, @PathVariable(name = "eventName") String eventName) {
LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
EventPublishingAccount account = ledger.getEventAccountSet(ledger.getLatestBlock()).getAccount(address);
if (null == account) {
return null;
}
return account.getLatest(eventName);
}
use of com.jd.blockchain.ledger.core.EventPublishingAccount in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getUserEventsTotalCount.
@RequestMapping(method = RequestMethod.GET, path = GET_EVENT_COUNT)
@Override
public long getUserEventsTotalCount(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "address") String address, @PathVariable(name = "eventName") String eventName) {
LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
EventPublishingAccount account = ledger.getEventAccountSet(ledger.getLatestBlock()).getAccount(address);
if (null == account) {
return 0;
}
return account.totalEvents(eventName);
}
use of com.jd.blockchain.ledger.core.EventPublishingAccount in project jdchain-core by blockchain-jd-com.
the class LedgerQueryController method getUserEventNames.
@RequestMapping(method = RequestMethod.GET, path = GET_EVENT_SUBJECTS)
@Override
public String[] getUserEventNames(@PathVariable(name = "ledgerHash") HashDigest ledgerHash, @PathVariable(name = "address") String address, @RequestParam(name = "fromIndex", required = false, defaultValue = "0") int fromIndex, @RequestParam(name = "count", required = false, defaultValue = "-1") int count) {
LedgerQuery ledger = ledgerService.getLedger(ledgerHash);
LedgerBlock block = ledger.getLatestBlock();
EventPublishingAccount account = ledger.getEventAccountSet(block).getAccount(address);
if (null == account) {
return null;
}
QueryArgs queryArgs = QueryUtils.calFromIndexAndCount(fromIndex, count, (int) account.totalEventNames());
return account.getEventNames(queryArgs.getFrom(), queryArgs.getCount());
}
Aggregations