Skip to content

Commit 9d120a3

Browse files
committed
clarifying readme
1 parent 26e8355 commit 9d120a3

File tree

6 files changed

+38
-27
lines changed

6 files changed

+38
-27
lines changed

Features/contractsdk-recordplayers/README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
If you're familiar with record players you probably know how difficult it is to make sure that they run in pristine condition, especially if it's a collectible.
55

6-
![](blob:https://imgur.com/04eac7f3-0849-424d-93ca-f2c11d9b3d0d)
6+
![](./cordaphone.png)
77

88

99
This cordapp simulates how you could model the process of a limited edition record player (the cordagraf) that is manufactured and issued to specific dealers, and those dealers are the only entities that can service those record players after the fact and report stats back to the manufacturer about how the players are being used.
@@ -37,8 +37,23 @@ If you've written contracts before you might be used to outlining the verify met
3737

3838
Take a look at the small RecordPlayerContract sample in this repository to see how this works in practice.
3939

40+
## Usage
4041

41-
### Sources
42+
To run the cordapps, just use the gradle wrapper script the same way you normally would.
43+
44+
```
45+
./gradlew deployNodes
46+
./build/nodes/runnodes
47+
48+
flow start net.corda.samples.contractsdk.flows.IssueRecordPlayerFlow dealer: "O=Alice Audio,L=New York,C=US", needle: spherical
49+
50+
# you can get your state id with a quick vault query
51+
run vaultQuery contractStateType: net.corda.samples.contractsdk.states.RecordPlayerState
52+
53+
flow start net.corda.samples.contractsdk.flows.UpdateRecordPlayerFlow stateId: < Place State ID here >, needleId: spherical, magneticStrength: 100, coilTurns: 100, amplifierSNR: 10000, songsPlayed: 100
54+
```
55+
56+
## Additional Information
4257

4358
If you're looking to find more information on record players specifically, I included some sources for how we modeled record players in the state class.
4459

Features/contractsdk-recordplayers/build.gradle

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -109,48 +109,38 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
109109
node {
110110
name "O=Notary,L=London,C=GB"
111111
notary = [validating : false]
112-
p2pPort 10002
112+
p2pPort 10001
113113
rpcSettings {
114-
address("localhost:10010")
115-
adminAddress("localhost:10011")
114+
address("localhost:10011")
115+
adminAddress("localhost:10021")
116116
}
117117
}
118118
node {
119119
name "O=Manufacturer,L=London,C=GB"
120-
p2pPort 10005
120+
p2pPort 10002
121121
rpcSettings {
122-
address("localhost:10021")
122+
address("localhost:10012")
123123
adminAddress("localhost:10022")
124124
}
125125
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
126126
}
127127

128128
node {
129129
name "O=Alice Audio,L=New York,C=US"
130-
p2pPort 10008
130+
p2pPort 10003
131131
rpcSettings {
132-
address("localhost:10030")
133-
adminAddress("localhost:10033")
132+
address("localhost:10013")
133+
adminAddress("localhost:10023")
134134
}
135135
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
136136
}
137137

138138
node {
139139
name "O=Bob Hustle Records,L=Egypt,C=US"
140-
p2pPort 10008
141-
rpcSettings {
142-
address("localhost:10040")
143-
adminAddress("localhost:10044")
144-
}
145-
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
146-
}
147-
148-
node {
149-
name "O=Carl Chords,L=Greece,C=US"
150-
p2pPort 10008
140+
p2pPort 10004
151141
rpcSettings {
152-
address("localhost:10040")
153-
adminAddress("localhost:10044")
142+
address("localhost:10014")
143+
adminAddress("localhost:10024")
154144
}
155145
rpcUsers = [[ user: "user1", "password": "test", "permissions": ["ALL"]]]
156146
}

Features/contractsdk-recordplayers/contracts/src/main/java/net/corda/samples/contractsdk/states/RecordPlayerState.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ public RecordPlayerState(Party manufacturer, Party dealer, Needle needle, int ma
5959
}
6060

6161
/* Constructor for a CordaGraf with default */
62-
public RecordPlayerState(Party manufacturer, Party owner, Needle needle) {
63-
this(manufacturer, owner, needle, 100, 700, 10000, 0, new UniqueIdentifier());
62+
public RecordPlayerState(Party manufacturer, Party dealer, Needle needle) {
63+
this(manufacturer, dealer, needle, 100, 700, 10000, 0, new UniqueIdentifier());
6464
}
6565

6666
public Needle getNeedle() {
482 KB
Loading

Features/contractsdk-recordplayers/workflows/src/main/java/net/corda/samples/contractsdk/flows/IssueRecordPlayerFlow.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import net.corda.samples.contractsdk.states.RecordPlayerState;
1313

1414
import java.util.Arrays;
15+
import java.util.Collections;
1516
import java.util.List;
1617
import java.util.stream.Collectors;
1718

@@ -59,7 +60,7 @@ public SignedTransaction call() throws FlowException {
5960
n = Needle.ELLIPTICAL;
6061
}
6162

62-
RecordPlayerState output = new RecordPlayerState(manufacturer, dealer, n, 100, 700, 10000, 0, new UniqueIdentifier());
63+
RecordPlayerState output = new RecordPlayerState(this.manufacturer, this.dealer, n, 100, 700, 10000, 0, new UniqueIdentifier());
6364

6465
// Create a new TransactionBuilder object.
6566
final TransactionBuilder builder = new TransactionBuilder(notary);
@@ -77,8 +78,11 @@ public SignedTransaction call() throws FlowException {
7778
List<Party> otherParties = output.getParticipants().stream().map(el -> (Party) el).collect(Collectors.toList());
7879
otherParties.remove(getOurIdentity());
7980

80-
List<FlowSession> sessions = otherParties.stream().map(el -> initiateFlow(el)).collect(Collectors.toList());
81+
// FlowSession targetSession = initiateFlow(this.dealer);
82+
// return subFlow(new FinalityFlow(ptx, Collections.singletonList(targetSession)));
83+
8184

85+
List<FlowSession> sessions = otherParties.stream().map(el -> initiateFlow(el)).collect(Collectors.toList());
8286

8387
SignedTransaction stx = subFlow(new CollectSignaturesFlow(ptx, sessions));
8488

Features/contractsdk-recordplayers/workflows/src/test/java/net/corda/samples/contractsdk/flows/IssueRecordPlayerFlowTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import java.util.LinkedHashMap;
2626

2727
import static org.jgroups.util.Util.assertEquals;
28+
import static org.junit.Assert.assertNotEquals;
2829

2930

3031
/**
@@ -115,6 +116,7 @@ public void canCreateState() throws Exception {
115116
// get some random data from the output to verify
116117
assertEquals(st.getManufacturer(), output.getManufacturer());
117118
assertEquals(st.getDealer(), output.getDealer());
119+
assertNotEquals(st.getDealer(), output.getManufacturer());
118120
assertEquals(st.getNeedle(), output.getNeedle());
119121
}
120122

0 commit comments

Comments
 (0)