Skip to content

Commit

Permalink
Fix hub support
Browse files Browse the repository at this point in the history
  • Loading branch information
cocreature committed Feb 24, 2022
1 parent 9527586 commit d5ce5e1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion daml.yaml
@@ -1,7 +1,7 @@
# Copyright (c) 2020, Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
# SPDX-License-Identifier: Apache-2.0

sdk-version: 1.0.0
sdk-version: 1.18.1
name: ex-java-bindings
source: daml/PingPong.daml
parties:
Expand Down
23 changes: 8 additions & 15 deletions src/main/java/examples/pingpong/reactive/PingPongProcessor.java
Expand Up @@ -20,37 +20,30 @@ public class PingPongProcessor {

private static final Logger logger = LoggerFactory.getLogger(PingPongProcessor.class);

private final String party;
private String party;
private String token;
private LedgerClient client;
private String ledgerId;

private final Identifier pingIdentifier;
private final Identifier pongIdentifier;

public PingPongProcessor(String party, LedgerClient client, Identifier pingIdentifier, Identifier pongIdentifier) {
public PingPongProcessor(String party, String token, LedgerClient client, Identifier pingIdentifier, Identifier pongIdentifier) {
this.party = party;
this.token = token;
this.ledgerId = client.getLedgerId();
this.client = client;
this.pingIdentifier = pingIdentifier;
this.pongIdentifier = pongIdentifier;
}

private static TransactionFilter filterFor(Identifier templateId, String party) {
logger.info("Filtering transactions by templateId {} party {}", templateId, party);

InclusiveFilter inclusiveFilter = new InclusiveFilter(Collections.singleton(templateId));
Map<String, Filter> filter = Collections.singletonMap(party, inclusiveFilter);
return new FiltersByParty(filter);
}

public void runIndefinitely(Identifier identifier, String partyId, String token) {
public void runIndefinitely() {
// assemble the request for the transaction stream
logger.info("{} starts reading transactions. for entityName={}", party, identifier.getEntityName());
logger.info("{} starts reading transactions", party);

Flowable<Transaction> transactions = client.getTransactionsClient().getTransactions(
LedgerOffset.LedgerEnd.getInstance(),
//new FiltersByParty(Collections.singletonMap(party, NoFilter.instance)), true); // <-- original filter from DA
filterFor(identifier, partyId), true, token);
new FiltersByParty(Collections.singletonMap(party, NoFilter.instance)), true, token);

transactions.forEach(t-> logger.info("transaction = {}", t.toString()));

Expand Down Expand Up @@ -79,7 +72,7 @@ private void processTransaction(Transaction tx) {
PingPongReactiveMain.APP_ID,
UUID.randomUUID().toString(),
party,
exerciseCommands)
exerciseCommands, token)
.blockingGet();
}
}
Expand Down
Expand Up @@ -81,14 +81,14 @@ public static void main(String[] args) throws SSLException {
logger.info("Created two Identifiers for Ping and Pong for module {}", pingIdentifier.getModuleName());

// initialize the ping pong processors for Alice and Bob
PingPongProcessor aliceProcessor = new PingPongProcessor(ALICE, client, pingIdentifier, pongIdentifier);
PingPongProcessor bobProcessor = new PingPongProcessor(BOB, client, pingIdentifier, pongIdentifier);
PingPongProcessor aliceProcessor = new PingPongProcessor(alicePartyId, aliceToken, client, pingIdentifier, pongIdentifier);
PingPongProcessor bobProcessor = new PingPongProcessor(bobPartyId, bobToken, client, pingIdentifier, pongIdentifier);

logger.info("Created two PingPongProcessor for Alice and Bob");

// start the processors asynchronously
aliceProcessor.runIndefinitely(Ping.TEMPLATE_ID, alicePartyId, aliceToken);
bobProcessor.runIndefinitely(Pong.TEMPLATE_ID, bobPartyId, bobToken);
aliceProcessor.runIndefinitely();
bobProcessor.runIndefinitely();

logger.info("After runIndefinitely for Alice and Bob");

Expand Down

0 comments on commit d5ce5e1

Please sign in to comment.