mirror of
https://github.com/corda/corda.git
synced 2025-05-03 01:03:18 +00:00
Minor: small changes to progress tracking in the IRS protocols
This commit is contained in:
parent
24cc56334b
commit
fc133de902
@ -24,16 +24,17 @@ open class RatesFixProtocol(protected val tx: TransactionBuilder,
|
|||||||
private val oracle: NodeInfo,
|
private val oracle: NodeInfo,
|
||||||
private val fixOf: FixOf,
|
private val fixOf: FixOf,
|
||||||
private val expectedRate: BigDecimal,
|
private val expectedRate: BigDecimal,
|
||||||
private val rateTolerance: BigDecimal) : ProtocolLogic<Unit>() {
|
private val rateTolerance: BigDecimal,
|
||||||
|
override val progressTracker: ProgressTracker = RatesFixProtocol.tracker(fixOf.name)) : ProtocolLogic<Unit>() {
|
||||||
companion object {
|
companion object {
|
||||||
val TOPIC = "platform.rates.interest.fix"
|
val TOPIC = "platform.rates.interest.fix"
|
||||||
|
|
||||||
class QUERYING(val name: String) : ProgressTracker.Step("Querying oracle for $name interest rate")
|
class QUERYING(val name: String) : ProgressTracker.Step("Querying oracle for $name interest rate")
|
||||||
object WORKING : ProgressTracker.Step("Working with data returned by oracle")
|
object WORKING : ProgressTracker.Step("Working with data returned by oracle")
|
||||||
object SIGNING : ProgressTracker.Step("Requesting transaction signature from interest rate oracle")
|
object SIGNING : ProgressTracker.Step("Requesting confirmation signature from interest rate oracle")
|
||||||
}
|
|
||||||
|
|
||||||
override val progressTracker = ProgressTracker(QUERYING(fixOf.name), WORKING, SIGNING)
|
fun tracker(fixName: String) = ProgressTracker(QUERYING(fixName), WORKING, SIGNING)
|
||||||
|
}
|
||||||
|
|
||||||
class FixOutOfRange(val byAmount: BigDecimal) : Exception()
|
class FixOutOfRange(val byAmount: BigDecimal) : Exception()
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@ object TwoPartyDealProtocol {
|
|||||||
override val progressTracker: ProgressTracker = Primary.tracker()) : ProtocolLogic<SignedTransaction>() {
|
override val progressTracker: ProgressTracker = Primary.tracker()) : ProtocolLogic<SignedTransaction>() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
object AWAITING_PROPOSAL : ProgressTracker.Step("Awaiting transaction proposal from other")
|
object AWAITING_PROPOSAL : ProgressTracker.Step("Handshaking and awaiting transaction proposal")
|
||||||
object VERIFYING : ProgressTracker.Step("Verifying transaction proposal from other")
|
object VERIFYING : ProgressTracker.Step("Verifying proposed transaction")
|
||||||
object SIGNING : ProgressTracker.Step("Signing transaction")
|
object SIGNING : ProgressTracker.Step("Signing transaction")
|
||||||
object TIMESTAMPING : ProgressTracker.Step("Timestamping transaction")
|
object TIMESTAMPING : ProgressTracker.Step("Timestamping transaction")
|
||||||
object SENDING_SIGS : ProgressTracker.Step("Sending transaction signatures to other party")
|
object SENDING_SIGS : ProgressTracker.Step("Sending transaction signatures to other party")
|
||||||
@ -158,7 +158,6 @@ object TwoPartyDealProtocol {
|
|||||||
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
private fun timestamp(partialTX: SignedTransaction): DigitalSignature.LegallyIdentifiable {
|
private fun timestamp(partialTX: SignedTransaction): DigitalSignature.LegallyIdentifiable {
|
||||||
progressTracker.childrenFor[TIMESTAMPING] = TimestampingProtocol.tracker()
|
|
||||||
progressTracker.currentStep = TIMESTAMPING
|
progressTracker.currentStep = TIMESTAMPING
|
||||||
return subProtocol(TimestampingProtocol(timestampingAuthority, partialTX.txBits, progressTracker.childrenFor[TIMESTAMPING]!!))
|
return subProtocol(TimestampingProtocol(timestampingAuthority, partialTX.txBits, progressTracker.childrenFor[TIMESTAMPING]!!))
|
||||||
}
|
}
|
||||||
@ -333,7 +332,14 @@ object TwoPartyDealProtocol {
|
|||||||
timestampingAuthority: Party,
|
timestampingAuthority: Party,
|
||||||
val dealToFix: StateAndRef<T>,
|
val dealToFix: StateAndRef<T>,
|
||||||
sessionID: Long,
|
sessionID: Long,
|
||||||
override val progressTracker: ProgressTracker = Secondary.tracker()) : Secondary<StateRef>(otherSide, timestampingAuthority, sessionID) {
|
val replacementProgressTracker: ProgressTracker? = null) : Secondary<StateRef>(otherSide, timestampingAuthority, sessionID) {
|
||||||
|
private val ratesFixTracker = RatesFixProtocol.tracker(dealToFix.state.nextFixingOf()!!.name)
|
||||||
|
|
||||||
|
override val progressTracker: ProgressTracker = replacementProgressTracker ?: createTracker()
|
||||||
|
|
||||||
|
fun createTracker(): ProgressTracker = Secondary.tracker().apply {
|
||||||
|
childrenFor[SIGNING] = ratesFixTracker
|
||||||
|
}
|
||||||
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
override fun validateHandshake(handshake: Handshake<StateRef>): Handshake<StateRef> {
|
override fun validateHandshake(handshake: Handshake<StateRef>): Handshake<StateRef> {
|
||||||
@ -369,7 +375,6 @@ object TwoPartyDealProtocol {
|
|||||||
|
|
||||||
val ptx = TransactionBuilder()
|
val ptx = TransactionBuilder()
|
||||||
val addFixing = object : RatesFixProtocol(ptx, serviceHub.networkMapCache.ratesOracleNodes[0], fixOf, BigDecimal.ZERO, BigDecimal.ONE) {
|
val addFixing = object : RatesFixProtocol(ptx, serviceHub.networkMapCache.ratesOracleNodes[0], fixOf, BigDecimal.ZERO, BigDecimal.ONE) {
|
||||||
|
|
||||||
@Suspendable
|
@Suspendable
|
||||||
override fun beforeSigning(fix: Fix) {
|
override fun beforeSigning(fix: Fix) {
|
||||||
newDeal.generateFix(ptx, oldRef, fix)
|
newDeal.generateFix(ptx, oldRef, fix)
|
||||||
@ -378,7 +383,6 @@ object TwoPartyDealProtocol {
|
|||||||
// to have one.
|
// to have one.
|
||||||
ptx.setTime(serviceHub.clock.instant(), timestampingAuthority, 30.seconds)
|
ptx.setTime(serviceHub.clock.instant(), timestampingAuthority, 30.seconds)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
subProtocol(addFixing)
|
subProtocol(addFixing)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user