Skip to content

Commit 66723e0

Browse files
committed
update notary selection
1 parent 47a25b1 commit 66723e0

File tree

21 files changed

+71
-95
lines changed

21 files changed

+71
-95
lines changed

Advanced/auction-cordapp/workflows/src/main/java/net/corda/samples/auction/flows/AuctionDvPFlow.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,8 @@ public SignedTransaction call() throws FlowException {
7979
.withNewOwner(auctionState.getWinner());
8080

8181
// Obtain a reference to a notary we wish to use.
82-
/** METHOD 1: Take first notary on network, WARNING: use for test, non-prod environments, and single-notary networks only!*
83-
* METHOD 2: Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)
84-
*
85-
* * - For production you always want to use Method 2 as it guarantees the expected notary is returned.
86-
*/
87-
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0); // METHOD 1
88-
// final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")); // METHOD 2
82+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
83+
final Party notary = auctionStateAndRef.getState().getNotary();
8984

9085
// Create the transaction builder.
9186
TransactionBuilder transactionBuilder = new TransactionBuilder(notary);

Advanced/auction-cordapp/workflows/src/main/java/net/corda/samples/auction/flows/CreateAssetFlow.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import net.corda.core.transactions.TransactionBuilder;
99
import net.corda.samples.auction.contracts.AssetContract;
1010
import net.corda.samples.auction.states.Asset;
11+
import net.corda.core.identity.CordaX500Name;
1112

1213
import java.util.Arrays;
1314
import java.util.Collections;
@@ -42,13 +43,8 @@ public CreateAssetFlow(String title, String description, String imageURL) {
4243
@Suspendable
4344
public SignedTransaction call() throws FlowException {
4445
// Obtain a reference to a notary we wish to use.
45-
/** METHOD 1: Take first notary on network, WARNING: use for test, non-prod environments, and single-notary networks only!*
46-
* METHOD 2: Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)
47-
*
48-
* * - For production you always want to use Method 2 as it guarantees the expected notary is returned.
49-
*/
50-
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0); // METHOD 1
51-
// final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")); // METHOD 2
46+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
47+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
5248

5349
// Create the output states
5450
Asset output = new Asset(new UniqueIdentifier(), title, description, imageURL,

Advanced/auction-cordapp/workflows/src/main/java/net/corda/samples/auction/flows/CreateAuctionFlow.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@
77
import net.corda.core.contracts.LinearState;
88
import net.corda.core.contracts.UniqueIdentifier;
99
import net.corda.core.flows.*;
10+
import net.corda.core.identity.CordaX500Name;
1011
import net.corda.core.identity.Party;
1112
import net.corda.core.transactions.SignedTransaction;
1213
import net.corda.core.transactions.TransactionBuilder;
1314
import net.corda.core.utilities.ProgressTracker;
1415
import net.corda.samples.auction.contracts.AuctionContract;
1516
import net.corda.samples.auction.states.AuctionState;
17+
import net.corda.core.identity.CordaX500Name;
1618

1719
import java.time.LocalDateTime;
1820
import java.time.ZoneId;
@@ -56,13 +58,8 @@ public ProgressTracker getProgressTracker() {
5658
@Override
5759
public SignedTransaction call() throws FlowException {
5860
// Obtain a reference to a notary we wish to use.
59-
/** METHOD 1: Take first notary on network, WARNING: use for test, non-prod environments, and single-notary networks only!*
60-
* METHOD 2: Explicit selection of notary by CordaX500Name - argument can by coded in flow or parsed from config (Preferred)
61-
*
62-
* * - For production you always want to use Method 2 as it guarantees the expected notary is returned.
63-
*/
64-
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0); // METHOD 1
65-
// final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")); // METHOD 2
61+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
62+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
6663

6764
Party auctioneer = getOurIdentity();
6865

Advanced/auction-cordapp/workflows/src/test/java/net/corda/samples/auction/FlowTests.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,14 @@
33
import com.google.common.collect.ImmutableList;
44
import net.corda.core.concurrent.CordaFuture;
55
import net.corda.core.contracts.Amount;
6+
import net.corda.core.identity.CordaX500Name;
67
import net.corda.core.node.NetworkParameters;
78
import net.corda.core.transactions.SignedTransaction;
89
import net.corda.samples.auction.flows.CreateAssetFlow;
910
import net.corda.samples.auction.flows.CreateAuctionFlow;
1011
import net.corda.samples.auction.states.Asset;
1112
import net.corda.samples.auction.states.AuctionState;
12-
import net.corda.testing.node.MockNetwork;
13-
import net.corda.testing.node.MockNetworkParameters;
14-
import net.corda.testing.node.StartedMockNode;
15-
import net.corda.testing.node.TestCordapp;
13+
import net.corda.testing.node.*;
1614
import org.junit.After;
1715
import org.junit.Before;
1816
import org.junit.Test;
@@ -39,7 +37,8 @@ public void setup() {
3937
)
4038
).withNetworkParameters(new NetworkParameters(4, Collections.emptyList(),
4139
10485760, 10485760 * 50, Instant.now(), 1,
42-
Collections.emptyMap()))
40+
Collections.emptyMap())
41+
).withNotarySpecs(ImmutableList.of(new MockNetworkNotarySpec(CordaX500Name.parse("O=Notary,L=London,C=GB"))))
4342
);
4443
a = network.createPartyNode(null);
4544
b = network.createPartyNode(null);

Advanced/duediligence-cordapp/workflows/src/main/java/net/corda/samples/duediligence/flows/RequestToValidateCorporateRecords.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import net.corda.core.transactions.TransactionBuilder;
99
import net.corda.samples.duediligence.contracts.CorporateRecordsContract;
1010
import net.corda.samples.duediligence.states.CorporateRecordsAuditRequest;
11+
import net.corda.core.identity.CordaX500Name;
1112

1213
import java.util.Arrays;
1314
import java.util.List;
@@ -33,7 +34,8 @@ public RequestToValidateCorporateRecordsInitiator(Party validater, int numberOfF
3334
@Override
3435
public String call() throws FlowException {
3536
//notary
36-
Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0);
37+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
38+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
3739

3840
//Initiate Corporate Records validation
3941
CorporateRecordsAuditRequest cr = new CorporateRecordsAuditRequest(getOurIdentity(),this.validater,this.numberOfFiles);

Advanced/duediligence-cordapp/workflows/src/test/java/net/corda/samples/duediligence/FlowTests.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,12 @@
44
import net.corda.core.contracts.ContractState;
55
import net.corda.core.contracts.StateAndRef;
66
import net.corda.core.contracts.UniqueIdentifier;
7+
import net.corda.core.identity.CordaX500Name;
78
import net.corda.core.node.services.Vault;
89
import net.corda.core.node.services.vault.QueryCriteria;
910
import net.corda.samples.duediligence.flows.RequestToValidateCorporateRecords;
1011
import net.corda.samples.duediligence.states.CorporateRecordsAuditRequest;
11-
import net.corda.testing.node.MockNetwork;
12-
import net.corda.testing.node.MockNetworkParameters;
13-
import net.corda.testing.node.StartedMockNode;
14-
import net.corda.testing.node.TestCordapp;
12+
import net.corda.testing.node.*;
1513
import org.junit.After;
1614
import org.junit.Before;
1715
import org.junit.Test;
@@ -31,7 +29,8 @@ public class FlowTests {
3129
public void setup() {
3230
network = new MockNetwork(new MockNetworkParameters().withCordappsForAllNodes(ImmutableList.of(
3331
TestCordapp.findCordapp("net.corda.samples.duediligence.contracts"),
34-
TestCordapp.findCordapp("net.corda.samples.duediligence.flows"))));
32+
TestCordapp.findCordapp("net.corda.samples.duediligence.flows")))
33+
.withNotarySpecs(ImmutableList.of(new MockNetworkNotarySpec(CordaX500Name.parse("O=Notary,L=London,C=GB")))));
3534
a = network.createPartyNode(null);
3635
b = network.createPartyNode(null);
3736
network.runNetwork();

Advanced/negotiation-cordapp/build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
111111

112112
nodeDefaults {
113113
cordapp project(':contracts')
114+
cordapp project(':workflows')
114115
runSchemaMigration = true
115116
}
116117

Advanced/negotiation-cordapp/workflows/src/main/java/net/corda/samples/negotiation/flows/ProposalFlow.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
import java.security.PublicKey;
1717
import java.util.List;
18+
import net.corda.core.identity.CordaX500Name;
1819

1920
public class ProposalFlow {
2021
@InitiatingFlow
@@ -51,13 +52,8 @@ public UniqueIdentifier call() throws FlowException {
5152
//Building the transaction
5253

5354
// Obtain a reference to a notary we wish to use.
54-
/** METHOD 1: Take first notary on network, WARNING: use for test, non-prod environments, and single-notary networks only!*
55-
* METHOD 2: Explicit selection of notary by CordaX500Name - argument can by coded in flow or parsed from config (Preferred)
56-
*
57-
* * - For production you always want to use Method 2 as it guarantees the expected notary is returned.
58-
*/
59-
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0); // METHOD 1
60-
// final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")); // METHOD 2
55+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
56+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
6157

6258
TransactionBuilder txBuilder = new TransactionBuilder(notary)
6359
.addOutputState(output, ProposalAndTradeContract.ID)

Advanced/negotiation-cordapp/workflows/src/test/java/net/corda/samples/negotiation/flows/FlowTestBase.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
import com.google.common.collect.ImmutableList;
44
import net.corda.core.contracts.UniqueIdentifier;
5+
import net.corda.core.identity.CordaX500Name;
56
import net.corda.core.identity.Party;
6-
import net.corda.testing.node.MockNetwork;
7-
import net.corda.testing.node.MockNetworkParameters;
8-
import net.corda.testing.node.StartedMockNode;
9-
import net.corda.testing.node.TestCordapp;
7+
import net.corda.testing.driver.VerifierType;
8+
import net.corda.testing.node.*;
109
import org.junit.After;
1110
import org.junit.Before;
1211

12+
import java.util.Collections;
1313
import java.util.List;
1414
import java.util.concurrent.ExecutionException;
1515
import java.util.concurrent.Future;
@@ -21,11 +21,11 @@ abstract class FlowTestBase {
2121

2222
@Before
2323
public void setup() {
24-
network = new MockNetwork(new MockNetworkParameters(ImmutableList.of(
25-
TestCordapp.findCordapp("net.corda.samples.negotiation.flows"),
26-
TestCordapp.findCordapp("net.corda.samples.negotiation.contracts")
27-
)
28-
));
24+
network = new MockNetwork(new MockNetworkParameters(
25+
ImmutableList.of(
26+
TestCordapp.findCordapp("net.corda.samples.negotiation.flows"),
27+
TestCordapp.findCordapp("net.corda.samples.negotiation.contracts"))
28+
).withNotarySpecs(ImmutableList.of(new MockNetworkNotarySpec(CordaX500Name.parse("O=Notary,L=London,C=GB")))));
2929
a = network.createPartyNode(null);
3030
b = network.createPartyNode(null);
3131

Advanced/obligation-cordapp/workflows/src/main/java/net/corda/samples/obligation/flows/IOUIssueFlow.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import net.corda.samples.obligation.contracts.IOUContract;
1919
import net.corda.samples.obligation.states.IOUState;
2020
import static net.corda.samples.obligation.contracts.IOUContract.Commands.*;
21+
import net.corda.core.identity.CordaX500Name;
2122

2223
/**
2324
* This is the flows which handles issuance of new IOUs on the ledger.
@@ -39,14 +40,8 @@ public InitiatorFlow(IOUState state) {
3940
@Override
4041
public SignedTransaction call() throws FlowException {
4142
// Step 1. Get a reference to the notary service on our network and our key pair.
42-
43-
/** METHOD 1: Take first notary on network, WARNING: use for test, non-prod environments, and single-notary networks only!*
44-
* METHOD 2: Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)
45-
*
46-
* * - For production you always want to use Method 2 as it guarantees the expected notary is returned.
47-
*/
48-
final Party notary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0); // METHOD 1
49-
// final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB")); // METHOD 2
43+
/** Explicit selection of notary by CordaX500Name - argument can by coded in flows or parsed from config (Preferred)*/
44+
final Party notary = getServiceHub().getNetworkMapCache().getNotary(CordaX500Name.parse("O=Notary,L=London,C=GB"));
5045

5146
// Step 2. Create a new issue command.
5247
// Remember that a command is a CommandData object and a list of CompositeKeys

0 commit comments

Comments
 (0)