Format code snippets in quickstart-build.rst

This commit is contained in:
LankyDan 2019-07-08 12:25:01 +01:00 committed by Mike Hearn
parent 66794e27a5
commit 1378321e1f

View File

@ -95,7 +95,8 @@ Since the CorDapp models a car dealership network, a state must be created to re
// *********
@BelongsToContract(CarContract::class)
data class CarState(val owningBank: Party,
data class CarState(
val owningBank: Party,
val holdingDealer: Party,
val manufacturer: Party,
val vin: String,
@ -103,7 +104,8 @@ Since the CorDapp models a car dealership network, a state must be created to re
val make: String,
val model: String,
val dealershipLocation: String,
val linearId: UniqueIdentifier) : ContractState {
val linearId: UniqueIdentifier
) : ContractState {
override val participants: List<AbstractParty> = listOf(owningBank, holdingDealer, manufacturer)
}
@ -264,14 +266,16 @@ Step Four: Creating a flow
@InitiatingFlow
@StartableByRPC
class CarIssueInitiator(val owningBank: Party,
class CarIssueInitiator(
val owningBank: Party,
val holdingDealer: Party,
val manufacturer: Party,
val vin: String,
val licensePlateNumber: String,
val make: String,
val model: String,
val dealershipLocation: String) : FlowLogic<Unit>() {
val dealershipLocation: String
) : FlowLogic<Unit>() {
@Suspendable
override fun call() {
@ -310,14 +314,16 @@ Step Four: Creating a flow
@InitiatingFlow
@StartableByRPC
class CarIssueInitiator(val owningBank: Party,
class CarIssueInitiator(
val owningBank: Party,
val holdingDealer: Party,
val manufacturer: Party,
val vin: String,
val licensePlateNumber: String,
val make: String,
val model: String,
val dealershipLocation: String) : FlowLogic<SignedTransaction>() {
val dealershipLocation: String
) : FlowLogic<SignedTransaction>() {
override val progressTracker = ProgressTracker()
@Suspendable
@ -325,7 +331,17 @@ Step Four: Creating a flow
val notary = serviceHub.networkMapCache.notaryIdentities.single()
val command = Command(CarContract.Commands.Issue(), listOf(owningBank, holdingDealer, manufacturer).map { it.owningKey })
val carState = CarState(owningBank, holdingDealer, manufacturer, vin, licensePlateNumber, make, model, dealershipLocation, UniqueIdentifier())
val carState = CarState(
owningBank,
holdingDealer,
manufacturer,
vin,
licensePlateNumber,
make,
model,
dealershipLocation,
UniqueIdentifier()
)
val txBuilder = TransactionBuilder(notary)
.addOutputState(carState, CarContract.ID)
@ -397,20 +413,32 @@ Step Four: Creating a flow
@InitiatingFlow
@StartableByRPC
class CarIssueInitiator(val owningBank: Party,
class CarIssueInitiator(
val owningBank: Party,
val holdingDealer: Party,
val manufacturer: Party,
val vin: String,
val licensePlateNumber: String,
val make: String,
val model: String,
val dealershipLocation: String) : FlowLogic<SignedTransaction>() {
val dealershipLocation: String
) : FlowLogic<SignedTransaction>() {
@Suspendable
override fun call(): SignedTransaction {
val notary = serviceHub.networkMapCache.notaryIdentities.single()
val command = Command(CarContract.Commands.Issue(), listOf(owningBank, holdingDealer, manufacturer).map { it.owningKey })
val carState = CarState(owningBank, holdingDealer, manufacturer, vin, licensePlateNumber, make, model, dealershipLocation, UniqueIdentifier())
val carState = CarState(
owningBank,
holdingDealer,
manufacturer,
vin,
licensePlateNumber,
make,
model,
dealershipLocation,
UniqueIdentifier()
)
val txBuilder = TransactionBuilder(notary)
.addOutputState(carState, CarContract.ID)