Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use typed ACS/transaction streams in quickstart-java examples #15191

Closed
6 of 7 tasks
S11001001 opened this issue Oct 7, 2022 · 0 comments · Fixed by #15363
Closed
6 of 7 tasks

use typed ACS/transaction streams in quickstart-java examples #15191

S11001001 opened this issue Oct 7, 2022 · 0 comments · Fixed by #15363
Assignees
Labels
component/daml-assistant Daml SDK Assistant component/documentation component/java-ecosystem Java development experience ledger clients facade enriching the ledger API by bindings/codegen, JSON API, custom view team/ledger-clients Related to the Ledger Clients team's components.

Comments

@S11001001
Copy link
Contributor

S11001001 commented Oct 7, 2022

client
.getActiveContractSetClient()
.getActiveContracts(iouFilter, true)
.blockingForEach(
response -> {
response
.getOffset()
.ifPresent(offset -> acsOffset.set(new LedgerOffset.Absolute(offset)));
response.getCreatedEvents().stream()
.map(Iou.Contract::fromCreatedEvent)
.forEach(
contract -> {
long id = idCounter.getAndIncrement();
contracts.put(id, contract.data);
idMap.put(id, contract.id);
});
});
Disposable ignore =
client
.getTransactionsClient()
.getTransactions(acsOffset.get(), iouFilter, true)
.forEach(
t -> {
for (Event event : t.getEvents()) {
if (event instanceof CreatedEvent) {
CreatedEvent createdEvent = (CreatedEvent) event;
long id = idCounter.getAndIncrement();
Iou.Contract contract = Iou.Contract.fromCreatedEvent(createdEvent);
contracts.put(id, contract.data);
idMap.put(id, contract.id);
} else if (event instanceof ArchivedEvent) {
ArchivedEvent archivedEvent = (ArchivedEvent) event;
long id =
idMap.inverse().get(new Iou.ContractId(archivedEvent.getContractId()));
contracts.remove(id);
idMap.remove(id);
}
}
});

  • and this can be removed:

private static TransactionFilter filterFor(Identifier templateId, String party) {
InclusiveFilter inclusiveFilter = new InclusiveFilter(Collections.singleton(templateId));
Map<String, Filter> filter = Collections.singletonMap(party, inclusiveFilter);
return new FiltersByParty(filter);
}

@S11001001 S11001001 added component/documentation component/java-ecosystem Java development experience team/ledger-clients Related to the Ledger Clients team's components. ledger clients facade enriching the ledger API by bindings/codegen, JSON API, custom view component/daml-assistant Daml SDK Assistant labels Oct 7, 2022
@chunlokling-da chunlokling-da self-assigned this Oct 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/daml-assistant Daml SDK Assistant component/documentation component/java-ecosystem Java development experience ledger clients facade enriching the ledger API by bindings/codegen, JSON API, custom view team/ledger-clients Related to the Ledger Clients team's components.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants