From 75473e2782d261820237107fa9de719de0f5486a Mon Sep 17 00:00:00 2001 From: Chris Rankin Date: Thu, 13 Jul 2017 15:47:06 +0100 Subject: [PATCH] Update DemoBench to use the new Vault APIs. (#1008) * Update to use the new Vault API. * Add a page specification for the Vault query. * Query vault for all contract states, not just cash states. Also only request one item per page from the vault because we're not interested in them anyway. * The first VaultQuery page is now page 1. --- .../corda/demobench/views/NodeTerminalView.kt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTerminalView.kt b/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTerminalView.kt index d2d81031c6..62ec8e0ae7 100644 --- a/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTerminalView.kt +++ b/tools/demobench/src/main/kotlin/net/corda/demobench/views/NodeTerminalView.kt @@ -17,10 +17,13 @@ import javafx.scene.layout.StackPane import javafx.scene.layout.HBox import javafx.scene.layout.VBox import javafx.util.Duration +import net.corda.core.contracts.ContractState import net.corda.core.crypto.commonName import net.corda.core.match import net.corda.core.then import net.corda.core.messaging.CordaRPCOps +import net.corda.core.messaging.vaultTrackBy +import net.corda.core.node.services.vault.PageSpecification import net.corda.demobench.explorer.ExplorerController import net.corda.demobench.model.NodeConfig import net.corda.demobench.model.NodeController @@ -37,6 +40,10 @@ import tornadofx.* class NodeTerminalView : Fragment() { override val root by fxml() + private companion object { + val pageSpecification = PageSpecification(1, 1) + } + private val nodeController by inject() private val explorerController by inject() private val webServerController by inject() @@ -53,7 +60,7 @@ class NodeTerminalView : Fragment() { private val subscriptions: MutableList = mutableListOf() private var txCount: Int = 0 - private var stateCount: Int = 0 + private var stateCount: Long = 0 private var isDestroyed: Boolean = false private val explorer = explorerController.explorer() private val webServer = webServerController.webServer() @@ -182,11 +189,11 @@ class NodeTerminalView : Fragment() { private fun initialise(config: NodeConfig, ops: CordaRPCOps) { try { - val (txInit, txNext) = ops.verifiedTransactions() - val (stateInit, stateNext) = ops.vaultAndUpdates() + val (txInit, txNext) = ops.verifiedTransactionsFeed() + val (stateInit, stateNext) = ops.vaultTrackBy(paging = pageSpecification) txCount = txInit.size - stateCount = stateInit.size + stateCount = stateInit.totalStatesAvailable Platform.runLater { logo.opacityProperty().animate(1.0, Duration.seconds(2.5)) @@ -194,7 +201,7 @@ class NodeTerminalView : Fragment() { states.value = stateCount.toString() } - val fxScheduler = Schedulers.from({ Platform.runLater(it) }) + val fxScheduler = Schedulers.from(Platform::runLater) subscriptions.add(txNext.observeOn(fxScheduler).subscribe { transactions.value = (++txCount).toString() })