Skip to content

Instantly share code, notes, and snippets.

val clientConnection = client.start(rpcUsername, rpcPassword)
val proxy = clientConnection.proxy
val nodes = proxy.networkMapSnapshot()
val partyA = getNodeWithName(nodes,"PartyA", "O=PartyA, L=London, C=GB")
val partyB = getNodeWithName(nodes,"PartyB", "O=PartyB, L=New York, C=US")
// Instead of searching for accounts owned by PartyA you can simply pass the PaymentAccountId to the MakePayment flow
val accountA = proxy.startTrackedFlow(
::PaymentAccounts,
Bing! 0!
Bong! 0!
Bing! 1!
Bong! 1!
Bing! 2!
Bong! 2!
Bing! 3!
Bong! 3!
Bing! 4!
Bong! 4!
Bing! 0!
Bing! 1!
Bing! 2!
Bing! 3!
Bing! 4!
Bing! 5!
Bong! 0!
Bong! 1!
Bong! 2!
Bong! 3!
@Test
public void wakeyFlowTest() {
WakeyFlow flow1 = new WakeyFlow("Bing!", 5);
WakeyFlow flow2 = new WakeyFlow("Bong!", 5);
CordaFuture<Void> futureA = nodeA.startFlow(flow1);
CordaFuture<Void> futureB = nodeB.startFlow(flow2);
}
@Test
public void sleepyFlowTest() {
SleepyFlow flow1 = new SleepyFlow("Bing!", 5, 500L);
SleepyFlow flow2 = new SleepyFlow("Bong!", 5, 500L);
CordaFuture<Void> futureA = nodeA.startFlow(flow1);
CordaFuture<Void> futureB = nodeA.startFlow(flow2);
}
@Suspendable
@Override
public Void call() throws FlowException{
for (int i = 0; i < limit; i++){
System.out.println(message + " " + i + "!");
try {
FlowLogic.sleep(Duration.ofMillis(sleepTime));
} catch (Exception e) {
System.out.println(e);
}
@Suspendable
@Override
public Void call() throws FlowException{
for (int i = 0; i < limit; i++){
System.out.println(message + " " + i + "!");
}
return null;
}
@iryna-09
iryna-09 / cordaservice.java
Last active September 23, 2020 12:26
CordaService class
@CordaService
public class ShipOrderService extends SingletonSerializeAsToken {
private final AppServiceHub serviceHub;
public ShipOrderService(AppServiceHub serviceHub) {
this.serviceHub = serviceHub;
directShipment();
}
private void directShipment() {
@iryna-09
iryna-09 / cordaservice-call.java
Last active October 22, 2020 11:30
Call CordaService from flow
public SignedTransaction call() throws FlowException {
// some code ...
// calling Corda Services
ShipOrderService service = getServiceHub().cordaService(ShipOrderService.class);
// more code ...
}