Reputation: 5061
I have multiple questions on Corda:
h2
configuration to pick in build.gradle
file?corda
network where i want to validate something based on custom fields
the validation has to happen based on query that needs to be fired on all 3 parties sender
, receiver
, notary
how can i fetch the session of all 3 nodes? i am able to pull the session of sender
using getServiceHub().jdbcSession()
Upvotes: 0
Views: 400
Reputation: 23140
You can set the h2Port
option in deployNodes
:
node {
name "O=PartyA,L=London,C=GB"
advertisedServices = []
p2pPort 10005
rpcPort 10006
webPort 10007
h2Port 10008
cordapps = ["net.corda:corda-finance:$corda_release_version"]
rpcUsers = [[ user: "user1", "password": "test", "permissions": []]]
}
Is that the kind of configuration you needed?
Each node's database is private by design, and cannot be queried from another node. Instead, you need to communicate with the other nodes as part of your flow in a way that causes them to initiate a response flow on their end where they query their own databases and send the results back. Something like:
public class CollectDBDataFlow {
@InitiatingFlow
@StartableByRPC
public static class Initiator extends FlowLogic<List<Object>> {
Party counterparty;
public Initiator(Party counterparty) {
this.counterparty = counterparty;
}
@Suspendable
@Override public List<Object> call() {
// TODO: Implement queryMyDatabase to perform querying.
Object myDBData = queryMyDatabase();
FlowSession counterpartySession = initiateFlow(counterparty);
Object theirDBData = counterpartySession.receive(Object.class);
return ImmutableList.of(myDBData, theirDBData);
}
}
@InitiatedBy(Initiator.class)
public static class Responder extends FlowLogic<Void> {
private FlowSession counterpartySession;
public Responder(FlowSession counterpartySession) {
this.counterpartySession = counterpartySession;
}
@Suspendable
@Override
public Void call() {
// TODO: Implement queryMyDatabase to perform querying.
Object myDBData = queryMyDatabase();
counterpartySession.send(myDBData);
return null;
}
}
}
The role of the notary isn't to be queried for data, but to prevent double-spends. You could technically do it using the method described in (2) above, but it wouldn't be advised. What are you trying to achieve?
The validation logic is written into the platform. See https://github.com/corda/corda/blob/release-V1/node/src/main/kotlin/net/corda/node/services/transactions/ValidatingNotaryFlow.kt.
The auto-complete should appear automatically, just like any other library.
Upvotes: 1