Remove NotaryChangeTxBuilder from examples - it's being deprecated

This commit is contained in:
Andrius Dagys 2017-07-18 16:22:20 +01:00
parent f571aeb6a7
commit 5501d74d29
2 changed files with 20 additions and 28 deletions

View File

@ -6,7 +6,6 @@ import com.google.common.collect.ImmutableSet;
import net.corda.contracts.asset.Cash; import net.corda.contracts.asset.Cash;
import net.corda.core.contracts.*; import net.corda.core.contracts.*;
import net.corda.core.contracts.TransactionType.General; import net.corda.core.contracts.TransactionType.General;
import net.corda.core.contracts.TransactionType.NotaryChange;
import net.corda.core.crypto.DigitalSignature; import net.corda.core.crypto.DigitalSignature;
import net.corda.core.crypto.SecureHash; import net.corda.core.crypto.SecureHash;
import net.corda.core.flows.*; import net.corda.core.flows.*;
@ -311,16 +310,13 @@ public class FlowCookbookJava {
------------------------*/ ------------------------*/
progressTracker.setCurrentStep(TX_BUILDING); progressTracker.setCurrentStep(TX_BUILDING);
// There are two types of transaction (notary-change and general),
// and therefore two types of transaction builder:
// DOCSTART 19 // DOCSTART 19
TransactionBuilder notaryChangeTxBuilder = new TransactionBuilder(NotaryChange.INSTANCE, specificNotary); TransactionBuilder txBuilder = new TransactionBuilder(General.INSTANCE, specificNotary);
TransactionBuilder regTxBuilder = new TransactionBuilder(General.INSTANCE, specificNotary);
// DOCEND 19 // DOCEND 19
// We add items to the transaction builder using ``TransactionBuilder.withItems``: // We add items to the transaction builder using ``TransactionBuilder.withItems``:
// DOCSTART 27 // DOCSTART 27
regTxBuilder.withItems( txBuilder.withItems(
// Inputs, as ``StateRef``s that reference to the outputs of previous transactions // Inputs, as ``StateRef``s that reference to the outputs of previous transactions
ourStateAndRef, ourStateAndRef,
// Outputs, as ``ContractState``s // Outputs, as ``ContractState``s
@ -332,20 +328,20 @@ public class FlowCookbookJava {
// We can also add items using methods for the individual components: // We can also add items using methods for the individual components:
// DOCSTART 28 // DOCSTART 28
regTxBuilder.addInputState(ourStateAndRef); txBuilder.addInputState(ourStateAndRef);
regTxBuilder.addOutputState(ourOutput); txBuilder.addOutputState(ourOutput);
regTxBuilder.addCommand(ourCommand); txBuilder.addCommand(ourCommand);
regTxBuilder.addAttachment(ourAttachment); txBuilder.addAttachment(ourAttachment);
// DOCEND 28 // DOCEND 28
// There are several ways of setting the transaction's time-window. // There are several ways of setting the transaction's time-window.
// We can set a time-window directly: // We can set a time-window directly:
// DOCSTART 44 // DOCSTART 44
regTxBuilder.setTimeWindow(ourTimeWindow); txBuilder.setTimeWindow(ourTimeWindow);
// DOCEND 44 // DOCEND 44
// Or as a start time plus a duration (e.g. 45 seconds): // Or as a start time plus a duration (e.g. 45 seconds):
// DOCSTART 45 // DOCSTART 45
regTxBuilder.setTimeWindow(Instant.now(), Duration.ofSeconds(45)); txBuilder.setTimeWindow(Instant.now(), Duration.ofSeconds(45));
// DOCEND 45 // DOCEND 45
/*----------------------- /*-----------------------
@ -356,12 +352,12 @@ public class FlowCookbookJava {
// We finalise the transaction by signing it, // We finalise the transaction by signing it,
// converting it into a ``SignedTransaction``. // converting it into a ``SignedTransaction``.
// DOCSTART 29 // DOCSTART 29
SignedTransaction onceSignedTx = getServiceHub().signInitialTransaction(regTxBuilder); SignedTransaction onceSignedTx = getServiceHub().signInitialTransaction(txBuilder);
// DOCEND 29 // DOCEND 29
// We can also sign the transaction using a different public key: // We can also sign the transaction using a different public key:
// DOCSTART 30 // DOCSTART 30
PublicKey otherKey = getServiceHub().getKeyManagementService().freshKey(); PublicKey otherKey = getServiceHub().getKeyManagementService().freshKey();
SignedTransaction onceSignedTx2 = getServiceHub().signInitialTransaction(regTxBuilder, otherKey); SignedTransaction onceSignedTx2 = getServiceHub().signInitialTransaction(txBuilder, otherKey);
// DOCEND 30 // DOCEND 30
// If instead this was a ``SignedTransaction`` that we'd received // If instead this was a ``SignedTransaction`` that we'd received

View File

@ -4,7 +4,6 @@ import co.paralleluniverse.fibers.Suspendable
import net.corda.contracts.asset.Cash import net.corda.contracts.asset.Cash
import net.corda.core.contracts.* import net.corda.core.contracts.*
import net.corda.core.contracts.TransactionType.General import net.corda.core.contracts.TransactionType.General
import net.corda.core.contracts.TransactionType.NotaryChange
import net.corda.core.crypto.DigitalSignature import net.corda.core.crypto.DigitalSignature
import net.corda.core.crypto.SecureHash import net.corda.core.crypto.SecureHash
import net.corda.core.flows.* import net.corda.core.flows.*
@ -292,16 +291,13 @@ object FlowCookbook {
-----------------------**/ -----------------------**/
progressTracker.currentStep = TX_BUILDING progressTracker.currentStep = TX_BUILDING
// There are two types of transaction (notary-change and general),
// and therefore two types of transaction builder:
// DOCSTART 19 // DOCSTART 19
val notaryChangeTxBuilder: TransactionBuilder = TransactionBuilder(NotaryChange, specificNotary) val txBuilder: TransactionBuilder = TransactionBuilder(General, specificNotary)
val regTxBuilder: TransactionBuilder = TransactionBuilder(General, specificNotary)
// DOCEND 19 // DOCEND 19
// We add items to the transaction builder using ``TransactionBuilder.withItems``: // We add items to the transaction builder using ``TransactionBuilder.withItems``:
// DOCSTART 27 // DOCSTART 27
regTxBuilder.withItems( txBuilder.withItems(
// Inputs, as ``StateRef``s that reference the outputs of previous transactions // Inputs, as ``StateRef``s that reference the outputs of previous transactions
ourStateAndRef, ourStateAndRef,
// Outputs, as ``ContractState``s // Outputs, as ``ContractState``s
@ -313,20 +309,20 @@ object FlowCookbook {
// We can also add items using methods for the individual components: // We can also add items using methods for the individual components:
// DOCSTART 28 // DOCSTART 28
regTxBuilder.addInputState(ourStateAndRef) txBuilder.addInputState(ourStateAndRef)
regTxBuilder.addOutputState(ourOutput) txBuilder.addOutputState(ourOutput)
regTxBuilder.addCommand(ourCommand) txBuilder.addCommand(ourCommand)
regTxBuilder.addAttachment(ourAttachment) txBuilder.addAttachment(ourAttachment)
// DOCEND 28 // DOCEND 28
// There are several ways of setting the transaction's time-window. // There are several ways of setting the transaction's time-window.
// We can set a time-window directly: // We can set a time-window directly:
// DOCSTART 44 // DOCSTART 44
regTxBuilder.setTimeWindow(ourTimeWindow) txBuilder.setTimeWindow(ourTimeWindow)
// DOCEND 44 // DOCEND 44
// Or as a start time plus a duration (e.g. 45 seconds): // Or as a start time plus a duration (e.g. 45 seconds):
// DOCSTART 45 // DOCSTART 45
regTxBuilder.setTimeWindow(serviceHub.clock.instant(), 45.seconds) txBuilder.setTimeWindow(serviceHub.clock.instant(), 45.seconds)
// DOCEND 45 // DOCEND 45
/**---------------------- /**----------------------
@ -337,12 +333,12 @@ object FlowCookbook {
// We finalise the transaction by signing it, converting it into a // We finalise the transaction by signing it, converting it into a
// ``SignedTransaction``. // ``SignedTransaction``.
// DOCSTART 29 // DOCSTART 29
val onceSignedTx: SignedTransaction = serviceHub.signInitialTransaction(regTxBuilder) val onceSignedTx: SignedTransaction = serviceHub.signInitialTransaction(txBuilder)
// DOCEND 29 // DOCEND 29
// We can also sign the transaction using a different public key: // We can also sign the transaction using a different public key:
// DOCSTART 30 // DOCSTART 30
val otherKey: PublicKey = serviceHub.keyManagementService.freshKey() val otherKey: PublicKey = serviceHub.keyManagementService.freshKey()
val onceSignedTx2: SignedTransaction = serviceHub.signInitialTransaction(regTxBuilder, otherKey) val onceSignedTx2: SignedTransaction = serviceHub.signInitialTransaction(txBuilder, otherKey)
// DOCEND 30 // DOCEND 30
// If instead this was a ``SignedTransaction`` that we'd received // If instead this was a ``SignedTransaction`` that we'd received