mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
Moved the various extension methods for creating Durations from Utils.kt to KotlinUtils.kt
This commit is contained in:
@ -20,13 +20,13 @@ import net.corda.core.transactions.WireTransaction
|
||||
import net.corda.core.utilities.ProgressTracker
|
||||
import net.corda.core.utilities.ProgressTracker.Step
|
||||
import net.corda.core.utilities.UntrustworthyData
|
||||
import net.corda.core.utilities.seconds
|
||||
import net.corda.core.utilities.unwrap
|
||||
import net.corda.testing.DUMMY_PUBKEY_1
|
||||
import net.corda.testing.contracts.DummyContract
|
||||
import net.corda.testing.contracts.DummyState
|
||||
import org.bouncycastle.asn1.x500.X500Name
|
||||
import java.security.PublicKey
|
||||
import java.time.Duration
|
||||
import java.time.Instant
|
||||
|
||||
// We group our two flows inside a singleton object to indicate that they work
|
||||
@ -280,11 +280,11 @@ object FlowCookbook {
|
||||
// We can also define a time window as an ``Instant`` +/- a time
|
||||
// tolerance (e.g. 30 seconds):
|
||||
// DOCSTART 42
|
||||
val ourTimeWindow2: TimeWindow = TimeWindow.withTolerance(Instant.now(), Duration.ofSeconds(30))
|
||||
val ourTimeWindow2: TimeWindow = TimeWindow.withTolerance(Instant.now(), 30.seconds)
|
||||
// DOCEND 42
|
||||
// Or as a start-time plus a duration:
|
||||
// DOCSTART 43
|
||||
val ourTimeWindow3: TimeWindow = TimeWindow.fromStartAndDuration(Instant.now(), Duration.ofSeconds(30))
|
||||
val ourTimeWindow3: TimeWindow = TimeWindow.fromStartAndDuration(Instant.now(), 30.seconds)
|
||||
// DOCEND 43
|
||||
|
||||
/**-----------------------
|
||||
@ -326,7 +326,7 @@ object FlowCookbook {
|
||||
// DOCEND 44
|
||||
// Or as a start time plus a duration (e.g. 45 seconds):
|
||||
// DOCSTART 45
|
||||
regTxBuilder.setTimeWindow(serviceHub.clock.instant(), Duration.ofSeconds(45))
|
||||
regTxBuilder.setTimeWindow(serviceHub.clock.instant(), 45.seconds)
|
||||
// DOCEND 45
|
||||
|
||||
/**----------------------
|
||||
|
@ -15,9 +15,9 @@ import net.corda.core.node.ServiceHub
|
||||
import net.corda.core.node.services.linearHeadsOfType
|
||||
import net.corda.core.serialization.CordaSerializable
|
||||
import net.corda.core.transactions.SignedTransaction
|
||||
import net.corda.core.utilities.seconds
|
||||
import net.corda.core.utilities.unwrap
|
||||
import java.security.PublicKey
|
||||
import java.time.Duration
|
||||
|
||||
// DOCSTART 1
|
||||
// Helper method to locate the latest Vault version of a LinearState from a possibly out of date StateRef
|
||||
@ -123,7 +123,7 @@ class SubmitTradeApprovalFlow(val tradeId: String,
|
||||
// Create the TransactionBuilder and populate with the new state.
|
||||
val tx = TransactionType.General.Builder(notary)
|
||||
.withItems(tradeProposal, Command(TradeApprovalContract.Commands.Issue(), listOf(tradeProposal.source.owningKey)))
|
||||
tx.setTimeWindow(serviceHub.clock.instant(), Duration.ofSeconds(60))
|
||||
tx.setTimeWindow(serviceHub.clock.instant(), 60.seconds)
|
||||
// We can automatically sign as there is no untrusted data.
|
||||
val signedTx = serviceHub.signInitialTransaction(tx)
|
||||
// Notarise and distribute.
|
||||
@ -184,7 +184,7 @@ class SubmitCompletionFlow(val ref: StateRef, val verdict: WorkflowState) : Flow
|
||||
newState,
|
||||
Command(TradeApprovalContract.Commands.Completed(),
|
||||
listOf(serviceHub.myInfo.legalIdentity.owningKey, latestRecord.state.data.source.owningKey)))
|
||||
tx.setTimeWindow(serviceHub.clock.instant(), Duration.ofSeconds(60))
|
||||
tx.setTimeWindow(serviceHub.clock.instant(), 60.seconds)
|
||||
// We can sign this transaction immediately as we have already checked all the fields and the decision
|
||||
// is ultimately a manual one from the caller.
|
||||
// As a SignedTransaction we can pass the data around certain that it cannot be modified,
|
||||
|
Reference in New Issue
Block a user