mirror of
https://github.com/corda/corda.git
synced 2024-12-20 21:43:14 +00:00
Merge pull request #851 from corda/mnesbit-delete-ambigious-timewindow
Remove ambiguous TimeWindow class
This commit is contained in:
commit
a970bc1bb1
@ -436,12 +436,16 @@ class TimeWindow private constructor(
|
|||||||
return TimeWindow(fromTime, untilTime)
|
return TimeWindow(fromTime, untilTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Use when we have a start time and a period of validity. */
|
||||||
|
@JvmStatic
|
||||||
|
fun fromStartAndDuration(fromTime: Instant, duration: Duration): TimeWindow = between(fromTime, fromTime + duration)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When we need to create a [TimeWindow] based on a specific time [Instant] and some tolerance in both sides of this instant.
|
* When we need to create a [TimeWindow] based on a specific time [Instant] and some tolerance in both sides of this instant.
|
||||||
* The result will be the following time-window: ([time] - [tolerance], [time] + [tolerance]).
|
* The result will be the following time-window: ([time] - [tolerance], [time] + [tolerance]).
|
||||||
*/
|
*/
|
||||||
@JvmStatic
|
@JvmStatic
|
||||||
fun withTolerance(time: Instant, tolerance: Duration) = TimeWindow(time - tolerance, time + tolerance)
|
fun withTolerance(time: Instant, tolerance: Duration) = between(time - tolerance, time + tolerance)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The midpoint is calculated as fromTime + (untilTime - fromTime)/2. Note that it can only be computed if both sides are set. */
|
/** The midpoint is calculated as fromTime + (untilTime - fromTime)/2. Note that it can only be computed if both sides are set. */
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
package net.corda.core.utilities
|
|
||||||
|
|
||||||
import java.time.Duration
|
|
||||||
import java.time.Instant
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A class representing a window in time from a particular instant, lasting a specified duration.
|
|
||||||
*/
|
|
||||||
data class TimeWindow(val start: Instant, val duration: Duration) {
|
|
||||||
val end: Instant
|
|
||||||
get() = start + duration
|
|
||||||
}
|
|
@ -683,7 +683,7 @@ class InterestRateSwap : Contract {
|
|||||||
val nextFixingOf = nextFixingOf() ?: return null
|
val nextFixingOf = nextFixingOf() ?: return null
|
||||||
|
|
||||||
// This is perhaps not how we should determine the time point in the business day, but instead expect the schedule to detail some of these aspects
|
// This is perhaps not how we should determine the time point in the business day, but instead expect the schedule to detail some of these aspects
|
||||||
val instant = suggestInterestRateAnnouncementTimeWindow(index = nextFixingOf.name, source = floatingLeg.indexSource, date = nextFixingOf.forDay).start
|
val instant = suggestInterestRateAnnouncementTimeWindow(index = nextFixingOf.name, source = floatingLeg.indexSource, date = nextFixingOf.forDay).fromTime!!
|
||||||
return ScheduledActivity(flowLogicRefFactory.create(FixingFlow.FixingRoleDecider::class.java, thisStateRef), instant)
|
return ScheduledActivity(flowLogicRefFactory.create(FixingFlow.FixingRoleDecider::class.java, thisStateRef), instant)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ open class RatesFixFlow(protected val tx: TransactionBuilder,
|
|||||||
class FixQueryFlow(val fixOf: FixOf, val oracle: Party) : FlowLogic<Fix>() {
|
class FixQueryFlow(val fixOf: FixOf, val oracle: Party) : FlowLogic<Fix>() {
|
||||||
@Suspendable
|
@Suspendable
|
||||||
override fun call(): Fix {
|
override fun call(): Fix {
|
||||||
val deadline = suggestInterestRateAnnouncementTimeWindow(fixOf.name, oracle.name.toString(), fixOf.forDay).end
|
val deadline = suggestInterestRateAnnouncementTimeWindow(fixOf.name, oracle.name.toString(), fixOf.forDay).untilTime!!
|
||||||
// TODO: add deadline to receive
|
// TODO: add deadline to receive
|
||||||
val resp = sendAndReceive<ArrayList<Fix>>(oracle, QueryRequest(listOf(fixOf), deadline))
|
val resp = sendAndReceive<ArrayList<Fix>>(oracle, QueryRequest(listOf(fixOf), deadline))
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package net.corda.irs.utilities
|
package net.corda.irs.utilities
|
||||||
|
|
||||||
import net.corda.core.utilities.TimeWindow
|
import net.corda.core.contracts.TimeWindow
|
||||||
import java.time.*
|
import java.time.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -16,5 +16,5 @@ fun suggestInterestRateAnnouncementTimeWindow(index: String, source: String, dat
|
|||||||
// Here we apply a blanket announcement time of 11:45 London irrespective of source or index
|
// Here we apply a blanket announcement time of 11:45 London irrespective of source or index
|
||||||
val time = LocalTime.of(11, 45)
|
val time = LocalTime.of(11, 45)
|
||||||
val zoneId = ZoneId.of("Europe/London")
|
val zoneId = ZoneId.of("Europe/London")
|
||||||
return TimeWindow(ZonedDateTime.of(date, time, zoneId).toInstant(), Duration.ofHours(24))
|
return TimeWindow.fromStartAndDuration(ZonedDateTime.of(date, time, zoneId).toInstant(), Duration.ofHours(24))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user