Varun
Varun

Reputation: 5061

Add multiple notaries in CORDA

I am trying to create a DLT with 4 nodes and 2 notaries where each notary is responsible for communicating with 2 nodes.

Sample Gradle config

task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
directory "./build/nodes"
networkMap "O=Controller,L=London,C=GB"
node {
    name "O=Controller,L=London,C=GB"
    advertisedServices = ["corda.notary.validating"]
    p2pPort 10002
    rpcPort 10003
    cordapps = ["net.corda:corda-finance:$corda_release_version"]
}
node {
    name "O=ControllerNY,L=New York,C=US"
    advertisedServices = ["corda.notary.validating"]
    p2pPort 10004
    rpcPort 10005
    cordapps = ["net.corda:corda-finance:$corda_release_version"]
}
node {
    name "O=PartyA,L=London,C=GB"
    advertisedServices = []
    p2pPort 10006
    rpcPort 10007
    webPort 10008
    cordapps = ["net.corda:corda-finance:$corda_release_version"]
    rpcUsers = [[ user: "user1", "password": "test", "permissions": []]]
}
node {
    name "O=PartyB,L=London,C=GB"
    advertisedServices = []
    p2pPort 10009
    rpcPort 10010
    webPort 10011
    cordapps = ["net.corda:corda-finance:$corda_release_version"]
    rpcUsers = [[ user: "user1", "password": "test", "permissions": []]]
}
node {
    name "O=PartyC,L=New York,C=US"
    advertisedServices = []
    p2pPort 10012
    rpcPort 10013
    webPort 10014
    cordapps = ["net.corda:corda-finance:$corda_release_version"]
    rpcUsers = [[ user: "user1", "password": "test", "permissions": []]]
}
node {
    name "O=PartyD,L=New York,C=US"
    advertisedServices = []
    p2pPort 10015
    rpcPort 10016
    webPort 10017
    cordapps = ["net.corda:corda-finance:$corda_release_version"]
    rpcUsers = [[ user: "user1", "password": "test", "permissions": []]]
}

}

how can i add both controller, controllerNY to network so that it picks it as notary and not as a normal node

Upvotes: 1

Views: 339

Answers (1)

Joel
Joel

Reputation: 23140

Both Controller and ControllerNY will be added to your network as notaries in this case, because they both advertise a notary service.

Each node is then free to use either notary for a given transaction. You pick your notary within the flow using something like:

serviceHub.networkMapCache.getNotary(notaryToUse)

Or

serviceHub.networkMapCache.notaryIdentities.single { it.name.organisation == notaryToUse }

Upvotes: 1

Related Questions