use of com.jd.blockchain.ledger.EventInfo in project jdchain-core by blockchain-jd-com.
the class EventPublishingAccount method getEvents.
@Override
public Event[] getEvents(String eventName, long fromSequence, int count) {
List<Event> events = new ArrayList<>();
Dataset<String, TypedValue> ds = mklAccount.getDataset();
long maxVersion = mklAccount.getDataset().getVersion(eventName) + 1;
for (int i = 0; i < count && i <= maxVersion; i++) {
TypedValue tv = ds.getValue(eventName, fromSequence + i);
if (null == tv || tv.isNil()) {
break;
}
Event event = BinaryProtocol.decode(tv.bytesValue());
events.add(new EventInfo(event));
}
return events.toArray(new Event[events.size()]);
}
use of com.jd.blockchain.ledger.EventInfo in project jdchain-core by blockchain-jd-com.
the class EventGroupPublisher method getEvents.
@Override
public Event[] getEvents(String eventName, long fromSequence, int maxCount) {
List<Event> eventsList = new ArrayList<>();
Bytes key = encodeKey(eventName);
long maxVersion = events.getVersion(key);
for (int i = 0; i < maxCount && i <= maxVersion; i++) {
byte[] bs = events.getValue(key, fromSequence + i);
if (null == bs) {
break;
}
Event event = BinaryProtocol.decode(bs);
eventsList.add(new EventInfo(event));
}
return eventsList.toArray(new Event[eventsList.size()]);
}
Aggregations