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.
This commit is contained in:
Chris Rankin 2017-07-13 15:47:06 +01:00 committed by GitHub
parent e93cdf29f8
commit 75473e2782

View File

@ -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<VBox>()
private companion object {
val pageSpecification = PageSpecification(1, 1)
}
private val nodeController by inject<NodeController>()
private val explorerController by inject<ExplorerController>()
private val webServerController by inject<WebServerController>()
@ -53,7 +60,7 @@ class NodeTerminalView : Fragment() {
private val subscriptions: MutableList<Subscription> = 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<ContractState>(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()
})