diff --git a/client/rpc/src/smoke-test/java/net/corda/java/rpc/StandaloneCordaRPCJavaClientTest.java b/client/rpc/src/smoke-test/java/net/corda/java/rpc/StandaloneCordaRPCJavaClientTest.java index 4d5a250ef6..6c18e31053 100644 --- a/client/rpc/src/smoke-test/java/net/corda/java/rpc/StandaloneCordaRPCJavaClientTest.java +++ b/client/rpc/src/smoke-test/java/net/corda/java/rpc/StandaloneCordaRPCJavaClientTest.java @@ -65,8 +65,8 @@ public class StandaloneCordaRPCJavaClientTest { } private NodeInfo fetchNotaryIdentity() { - DataFeed, NetworkMapCache.MapChange> nodeDataFeed = rpcProxy.networkMapFeed(); - return nodeDataFeed.getSnapshot().get(0); + List nodeDataSnapshot = rpcProxy.networkMapSnapshot(); + return nodeDataSnapshot.get(0); } @Test diff --git a/client/rpc/src/smoke-test/kotlin/net/corda/kotlin/rpc/StandaloneCordaRPClientTest.kt b/client/rpc/src/smoke-test/kotlin/net/corda/kotlin/rpc/StandaloneCordaRPClientTest.kt index f26ea31ff8..064db6fc7d 100644 --- a/client/rpc/src/smoke-test/kotlin/net/corda/kotlin/rpc/StandaloneCordaRPClientTest.kt +++ b/client/rpc/src/smoke-test/kotlin/net/corda/kotlin/rpc/StandaloneCordaRPClientTest.kt @@ -202,8 +202,7 @@ class StandaloneCordaRPClientTest { } private fun fetchNotaryIdentity(): NodeInfo { - val (nodeInfo, nodeUpdates) = rpcProxy.networkMapFeed() - nodeUpdates.notUsed() + val nodeInfo = rpcProxy.networkMapSnapshot() assertEquals(1, nodeInfo.size) return nodeInfo[0] } diff --git a/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt b/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt index 84e30e9140..601e8c6b11 100644 --- a/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt +++ b/core/src/main/kotlin/net/corda/core/messaging/CordaRPCOps.kt @@ -60,6 +60,11 @@ interface CordaRPCOps : RPCOps { */ override val protocolVersion: Int get() = nodeIdentity().platformVersion + /** + * Returns a list of currently in-progress state machine infos. + */ + fun stateMachinesSnapshot(): List + /** * Returns a data feed of currently in-progress state machine infos and an observable of future state machine adds/removes. */ @@ -151,12 +156,22 @@ interface CordaRPCOps : RPCOps { } // DOCEND VaultTrackAPIHelpers + /** + * Returns a list of all recorded transactions. + */ + fun verifiedTransactionsSnapshot(): List + /** * Returns a data feed of all recorded transactions and an observable of future recorded ones. */ @RPCReturnsObservables fun verifiedTransactionsFeed(): DataFeed, SignedTransaction> + /** + * Returns a snapshot list of existing state machine id - recorded transaction hash mappings. + */ + fun stateMachineRecordedTransactionMappingSnapshot(): List + /** * Returns a snapshot list of existing state machine id - recorded transaction hash mappings, and a stream of future * such mappings as well. @@ -164,6 +179,11 @@ interface CordaRPCOps : RPCOps { @RPCReturnsObservables fun stateMachineRecordedTransactionMappingFeed(): DataFeed, StateMachineTransactionMapping> + /** + * Returns all parties currently visible on the network with their advertised services. + */ + fun networkMapSnapshot(): List + /** * Returns all parties currently visible on the network with their advertised services and an observable of future updates to the network. */ diff --git a/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt b/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt index ddf115389d..fe2255b3e7 100644 --- a/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt +++ b/docs/source/example-code/src/main/kotlin/net/corda/docs/ClientRpcTutorial.kt @@ -112,8 +112,7 @@ fun generateTransactions(proxy: CordaRPCOps) { sum + state.state.data.amount.quantity } val issueRef = OpaqueBytes.of(0) - val (parties, partyUpdates) = proxy.networkMapFeed() - partyUpdates.notUsed() + val parties = proxy.networkMapSnapshot() val notary = parties.first { it.advertisedServices.any { it.info.type.isNotary() } }.notaryIdentity val me = proxy.nodeIdentity().legalIdentity while (true) { diff --git a/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt b/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt index d934483095..8b604c0940 100644 --- a/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt +++ b/node/src/main/kotlin/net/corda/node/internal/CordaRPCOpsImpl.kt @@ -1,5 +1,6 @@ package net.corda.node.internal +import net.corda.client.rpc.notUsed import net.corda.core.contracts.ContractState import net.corda.core.contracts.StateAndRef import net.corda.core.contracts.UpgradedContract @@ -39,6 +40,12 @@ class CordaRPCOpsImpl( private val smm: StateMachineManager, private val database: CordaPersistence ) : CordaRPCOps { + override fun networkMapSnapshot(): List { + val (snapshot, updates) = networkMapFeed() + updates.notUsed() + return snapshot + } + override fun networkMapFeed(): DataFeed, NetworkMapCache.MapChange> { return database.transaction { services.networkMapCache.track() @@ -64,12 +71,24 @@ class CordaRPCOpsImpl( } } + override fun verifiedTransactionsSnapshot(): List { + val (snapshot, updates) = verifiedTransactionsFeed() + updates.notUsed() + return snapshot + } + override fun verifiedTransactionsFeed(): DataFeed, SignedTransaction> { return database.transaction { services.validatedTransactions.track() } } + override fun stateMachinesSnapshot(): List { + val (snapshot, updates) = stateMachinesFeed() + updates.notUsed() + return snapshot + } + override fun stateMachinesFeed(): DataFeed, StateMachineUpdate> { return database.transaction { val (allStateMachines, changes) = smm.track() @@ -80,6 +99,12 @@ class CordaRPCOpsImpl( } } + override fun stateMachineRecordedTransactionMappingSnapshot(): List { + val (snapshot, updates) = stateMachineRecordedTransactionMappingFeed() + updates.notUsed() + return snapshot + } + override fun stateMachineRecordedTransactionMappingFeed(): DataFeed, StateMachineTransactionMapping> { return database.transaction { services.stateMachineRecordedTransactionMapping.track() diff --git a/samples/notary-demo/src/main/kotlin/net/corda/notarydemo/Notarise.kt b/samples/notary-demo/src/main/kotlin/net/corda/notarydemo/Notarise.kt index 8c7d7afd61..d648ce6d71 100644 --- a/samples/notary-demo/src/main/kotlin/net/corda/notarydemo/Notarise.kt +++ b/samples/notary-demo/src/main/kotlin/net/corda/notarydemo/Notarise.kt @@ -27,15 +27,13 @@ fun main(args: Array) { /** Interface for using the notary demo API from a client. */ private class NotaryDemoClientApi(val rpc: CordaRPCOps) { private val notary by lazy { - val (parties, partyUpdates) = rpc.networkMapFeed() - partyUpdates.notUsed() + val parties = rpc.networkMapSnapshot() val id = parties.stream().filter { it.advertisedServices.any { it.info.type.isNotary() } }.map { it.notaryIdentity }.distinct().asSequence().singleOrNull() checkNotNull(id) { "No unique notary identity, try cleaning the node directories." } } private val counterpartyNode by lazy { - val (parties, partyUpdates) = rpc.networkMapFeed() - partyUpdates.notUsed() + val parties = rpc.networkMapSnapshot() parties.single { it.legalIdentity.name == BOB.name } } diff --git a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/PortfolioApi.kt b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/PortfolioApi.kt index 001f57261f..2dcb81f3fb 100644 --- a/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/PortfolioApi.kt +++ b/samples/simm-valuation-demo/src/main/kotlin/net/corda/vega/api/PortfolioApi.kt @@ -253,8 +253,7 @@ class PortfolioApi(val rpc: CordaRPCOps) { @Path("whoami") @Produces(MediaType.APPLICATION_JSON) fun getWhoAmI(): AvailableParties { - val (parties, partyUpdates) = rpc.networkMapFeed() - partyUpdates.notUsed() + val parties = rpc.networkMapSnapshot() val counterParties = parties.filterNot { it.advertisedServices.any { it.info.type in setOf(ServiceType.networkMap, ServiceType.notary) } || it.legalIdentity == ownParty diff --git a/tools/loadtest/src/main/kotlin/net/corda/loadtest/LoadTest.kt b/tools/loadtest/src/main/kotlin/net/corda/loadtest/LoadTest.kt index 1a31342c1e..7ae88f528f 100644 --- a/tools/loadtest/src/main/kotlin/net/corda/loadtest/LoadTest.kt +++ b/tools/loadtest/src/main/kotlin/net/corda/loadtest/LoadTest.kt @@ -181,8 +181,7 @@ fun runLoadTests(configuration: LoadTestConfiguration, tests: List