Minor: small changes to progress tracking in the IRS protocols

This commit is contained in:
Mike Hearn 2016-04-08 14:07:03 +02:00 committed by Mike Hearn
parent 24cc56334b
commit fc133de902
2 changed files with 15 additions and 10 deletions

View File

@ -24,16 +24,17 @@ open class RatesFixProtocol(protected val tx: TransactionBuilder,
private val oracle: NodeInfo,
private val fixOf: FixOf,
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 {
val TOPIC = "platform.rates.interest.fix"
class QUERYING(val name: String) : ProgressTracker.Step("Querying oracle for $name interest rate")
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()

View File

@ -59,8 +59,8 @@ object TwoPartyDealProtocol {
override val progressTracker: ProgressTracker = Primary.tracker()) : ProtocolLogic<SignedTransaction>() {
companion object {
object AWAITING_PROPOSAL : ProgressTracker.Step("Awaiting transaction proposal from other")
object VERIFYING : ProgressTracker.Step("Verifying transaction proposal from other")
object AWAITING_PROPOSAL : ProgressTracker.Step("Handshaking and awaiting transaction proposal")
object VERIFYING : ProgressTracker.Step("Verifying proposed transaction")
object SIGNING : ProgressTracker.Step("Signing transaction")
object TIMESTAMPING : ProgressTracker.Step("Timestamping transaction")
object SENDING_SIGS : ProgressTracker.Step("Sending transaction signatures to other party")
@ -158,7 +158,6 @@ object TwoPartyDealProtocol {
@Suspendable
private fun timestamp(partialTX: SignedTransaction): DigitalSignature.LegallyIdentifiable {
progressTracker.childrenFor[TIMESTAMPING] = TimestampingProtocol.tracker()
progressTracker.currentStep = TIMESTAMPING
return subProtocol(TimestampingProtocol(timestampingAuthority, partialTX.txBits, progressTracker.childrenFor[TIMESTAMPING]!!))
}
@ -333,7 +332,14 @@ object TwoPartyDealProtocol {
timestampingAuthority: Party,
val dealToFix: StateAndRef<T>,
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
override fun validateHandshake(handshake: Handshake<StateRef>): Handshake<StateRef> {
@ -369,7 +375,6 @@ object TwoPartyDealProtocol {
val ptx = TransactionBuilder()
val addFixing = object : RatesFixProtocol(ptx, serviceHub.networkMapCache.ratesOracleNodes[0], fixOf, BigDecimal.ZERO, BigDecimal.ONE) {
@Suspendable
override fun beforeSigning(fix: Fix) {
newDeal.generateFix(ptx, oldRef, fix)
@ -378,7 +383,6 @@ object TwoPartyDealProtocol {
// to have one.
ptx.setTime(serviceHub.clock.instant(), timestampingAuthority, 30.seconds)
}
}
subProtocol(addFixing)