RatesFixProtocol: add progress tracking

This commit is contained in:
Mike Hearn 2016-03-09 14:38:03 +01:00
parent 4e15755883
commit b2f9aa64d5
3 changed files with 12 additions and 4 deletions

View File

@ -7,7 +7,9 @@ if [ ! -e ./gradlew ]; then
exit 1
fi
if [ ! -d build/install/r3prototyping/bin/get-rate-fix ]; then
bin="build/install/r3prototyping/bin/get-rate-fix"
if [ ! -e $bin ]; then
./gradlew installDist
fi
@ -19,4 +21,4 @@ fi
# Upload the rates to the buyer node
curl -F rates=@scripts/example.rates.txt http://localhost:31338/upload/interest-rates
build/install/r3prototyping/bin/get-rate-fix --network-address=localhost:31300 --oracle=localhost --oracle-identity-file=buyer/identity-public
$bin --network-address=localhost:31300 --oracle=localhost --oracle-identity-file=buyer/identity-public

View File

@ -79,12 +79,11 @@ fun main(args: Array<String>) {
val protocol = RatesFixProtocol(tx, oracleNode, fixOf, expectedRate, rateTolerance)
ANSIProgressRenderer.progressTracker = protocol.progressTracker
node.smm.add("demo.ratefix", protocol).get()
node.stop()
// Show the user the output.
println("Got rate fix")
println()
print(Emoji.renderIfSupported(tx.toWireTransaction()))
println(tx.toSignedTransaction().sigs)
node.stop()
}

View File

@ -14,6 +14,7 @@ import core.crypto.DigitalSignature
import core.messaging.LegallyIdentifiableNode
import core.messaging.SingleMessageRecipient
import core.protocols.ProtocolLogic
import core.utilities.ProgressTracker
import java.math.BigDecimal
import java.util.*
@ -34,8 +35,14 @@ open class RatesFixProtocol(protected val tx: TransactionBuilder,
private val rateTolerance: BigDecimal) : 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")
}
override val progressTracker = ProgressTracker(QUERYING(fixOf.name), WORKING, SIGNING)
class FixOutOfRange(val byAmount: BigDecimal) : Exception()
data class QueryRequest(val queries: List<FixOf>, val replyTo: SingleMessageRecipient, val sessionID: Long)