mirror of
https://github.com/corda/corda.git
synced 2025-06-13 04:38:19 +00:00
Remove advertised services from NodeInfo (#1521)
* Remove advertisedServices from NodeInfo. Introduce notaryIdentities in NetworkMapCache, that will be filled in later from NetworkParameters. Clean up NetworkMapCache API. Expose notaryIdentities through RPC. For now we assume as temporary solution that notaries in NetworkMap have to contain "notary" in name. * Further clean up of NetworkMapCache API Remve partyNodes. Introduce getAllNodeInfos function * Remove notaryIdentity from ServiceHub * Address Shams review comments * Address Andrius review comments * Add comments, cleanup * Fixes * Address comments * Yet another commit with comments addressed * Move ServiceType and ServiceInfo to node-api Add changelog entry. Address rest of comments. * Minor comments
This commit is contained in:
committed by
josecoll
parent
6887947a4d
commit
fd57cf1c0c
@ -3,7 +3,6 @@ package net.corda.docs
|
||||
import net.corda.core.internal.concurrent.transpose
|
||||
import net.corda.core.messaging.startFlow
|
||||
import net.corda.core.messaging.vaultTrackBy
|
||||
import net.corda.core.node.services.ServiceInfo
|
||||
import net.corda.core.node.services.Vault
|
||||
import net.corda.core.utilities.OpaqueBytes
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
@ -12,6 +11,7 @@ import net.corda.finance.contracts.asset.Cash
|
||||
import net.corda.finance.flows.CashIssueFlow
|
||||
import net.corda.finance.flows.CashPaymentFlow
|
||||
import net.corda.node.services.FlowPermissions.Companion.startFlowPermission
|
||||
import net.corda.nodeapi.ServiceInfo
|
||||
import net.corda.node.services.transactions.ValidatingNotaryService
|
||||
import net.corda.nodeapi.User
|
||||
import net.corda.testing.*
|
||||
@ -56,11 +56,12 @@ class IntegrationTestingTutorial {
|
||||
|
||||
// START 4
|
||||
val issueRef = OpaqueBytes.of(0)
|
||||
val notaryParty = aliceProxy.notaryIdentities().first().party
|
||||
(1..10).map { i ->
|
||||
aliceProxy.startFlow(::CashIssueFlow,
|
||||
i.DOLLARS,
|
||||
issueRef,
|
||||
notary.nodeInfo.notaryIdentity
|
||||
notaryParty
|
||||
).returnValue
|
||||
}.transpose().getOrThrow()
|
||||
// We wait for all of the issuances to run before we start making payments
|
||||
|
@ -10,7 +10,6 @@ import net.corda.core.flows.*;
|
||||
import net.corda.core.identity.CordaX500Name;
|
||||
import net.corda.core.identity.Party;
|
||||
import net.corda.core.internal.FetchDataFlow;
|
||||
import net.corda.core.node.services.ServiceType;
|
||||
import net.corda.core.node.services.Vault;
|
||||
import net.corda.core.node.services.Vault.Page;
|
||||
import net.corda.core.node.services.vault.QueryCriteria.VaultQueryCriteria;
|
||||
@ -54,11 +53,13 @@ public class FlowCookbookJava {
|
||||
private final boolean arg1;
|
||||
private final int arg2;
|
||||
private final Party counterparty;
|
||||
private final Party regulator;
|
||||
|
||||
public InitiatorFlow(boolean arg1, int arg2, Party counterparty) {
|
||||
public InitiatorFlow(boolean arg1, int arg2, Party counterparty, Party regulator) {
|
||||
this.arg1 = arg1;
|
||||
this.arg2 = arg2;
|
||||
this.counterparty = counterparty;
|
||||
this.regulator = regulator;
|
||||
}
|
||||
|
||||
/*----------------------------------
|
||||
@ -124,11 +125,11 @@ public class FlowCookbookJava {
|
||||
// We retrieve a notary from the network map.
|
||||
// DOCSTART 1
|
||||
Party specificNotary = getServiceHub().getNetworkMapCache().getNotary(new CordaX500Name("Notary Service", "London", "UK"));
|
||||
Party anyNotary = getServiceHub().getNetworkMapCache().getAnyNotary(null);
|
||||
Party anyNotary = getServiceHub().getNetworkMapCache().getAnyNotary();
|
||||
// Unlike the first two methods, ``getNotaryNodes`` returns a
|
||||
// ``List<NodeInfo>``. We have to extract the notary identity of
|
||||
// the node we want.
|
||||
Party firstNotary = getServiceHub().getNetworkMapCache().getNotaryNodes().get(0).getNotaryIdentity();
|
||||
Party firstNotary = getServiceHub().getNetworkMapCache().getNotaryIdentities().get(0).getParty();
|
||||
// DOCEND 1
|
||||
|
||||
// We may also need to identify a specific counterparty.
|
||||
@ -138,12 +139,6 @@ public class FlowCookbookJava {
|
||||
Party keyedCounterparty = getServiceHub().getIdentityService().partyFromKey(dummyPubKey);
|
||||
// DOCEND 2
|
||||
|
||||
// Finally, we can use the map to identify nodes providing a
|
||||
// specific service (e.g. a regulator or an oracle).
|
||||
// DOCSTART 3
|
||||
Party regulator = getServiceHub().getNetworkMapCache().getPeersWithService(ServiceType.Companion.getRegulator()).get(0).getIdentity().getParty();
|
||||
// DOCEND 3
|
||||
|
||||
/*------------------------------
|
||||
* SENDING AND RECEIVING DATA *
|
||||
------------------------------*/
|
||||
@ -528,7 +523,7 @@ public class FlowCookbookJava {
|
||||
// We can also choose to send it to additional parties who aren't one
|
||||
// of the state's participants.
|
||||
// DOCSTART 10
|
||||
Set<Party> additionalParties = ImmutableSet.of(regulator, regulator);
|
||||
Set<Party> additionalParties = ImmutableSet.of(regulator);
|
||||
SignedTransaction notarisedTx2 = subFlow(new FinalityFlow(ImmutableList.of(fullySignedTx), additionalParties, FINALISATION.childProgressTracker())).get(0);
|
||||
// DOCEND 10
|
||||
|
||||
|
@ -5,17 +5,18 @@ import net.corda.core.messaging.CordaRPCOps
|
||||
import net.corda.core.messaging.startFlow
|
||||
import net.corda.core.messaging.vaultQueryBy
|
||||
import net.corda.core.node.CordaPluginRegistry
|
||||
import net.corda.core.node.services.ServiceInfo
|
||||
import net.corda.core.serialization.CordaSerializable
|
||||
import net.corda.core.serialization.SerializationCustomization
|
||||
import net.corda.core.transactions.SignedTransaction
|
||||
import net.corda.core.utilities.OpaqueBytes
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import net.corda.finance.USD
|
||||
import net.corda.finance.contracts.asset.Cash
|
||||
import net.corda.finance.flows.CashExitFlow
|
||||
import net.corda.finance.flows.CashIssueFlow
|
||||
import net.corda.finance.flows.CashPaymentFlow
|
||||
import net.corda.node.services.FlowPermissions.Companion.startFlowPermission
|
||||
import net.corda.nodeapi.ServiceInfo
|
||||
import net.corda.node.services.transactions.ValidatingNotaryService
|
||||
import net.corda.nodeapi.User
|
||||
import net.corda.testing.ALICE
|
||||
@ -56,6 +57,7 @@ fun main(args: Array<String>) {
|
||||
// START 2
|
||||
val client = node.rpcClientToNode()
|
||||
val proxy = client.start("user", "password").proxy
|
||||
proxy.waitUntilNetworkReady().getOrThrow()
|
||||
|
||||
thread {
|
||||
generateTransactions(proxy)
|
||||
@ -111,8 +113,7 @@ fun generateTransactions(proxy: CordaRPCOps) {
|
||||
sum + state.state.data.amount.quantity
|
||||
}
|
||||
val issueRef = OpaqueBytes.of(0)
|
||||
val parties = proxy.networkMapSnapshot()
|
||||
val notary = parties.first { it.advertisedServices.any { it.info.type.isNotary() } }.notaryIdentity
|
||||
val notary = proxy.notaryIdentities().first().party
|
||||
val me = proxy.nodeInfo().legalIdentities.first()
|
||||
while (true) {
|
||||
Thread.sleep(1000)
|
||||
|
@ -49,7 +49,7 @@ class MyValidatingNotaryFlow(otherSide: Party, service: MyCustomValidatingNotary
|
||||
|
||||
private fun checkSignatures(stx: SignedTransaction) {
|
||||
try {
|
||||
stx.verifySignaturesExcept(serviceHub.myInfo.notaryIdentity.owningKey)
|
||||
stx.verifySignaturesExcept(serviceHub.notaryIdentityKey)
|
||||
} catch (e: SignatureException) {
|
||||
throw NotaryException(NotaryError.TransactionInvalid(e))
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import net.corda.finance.flows.AbstractCashFlow
|
||||
import net.corda.finance.flows.CashException
|
||||
import net.corda.finance.flows.CashIssueFlow
|
||||
import net.corda.finance.flows.CashPaymentFlow
|
||||
import net.corda.testing.getDefaultNotary
|
||||
import java.util.*
|
||||
|
||||
// DOCSTART CustomVaultQuery
|
||||
@ -132,7 +133,7 @@ object TopupIssuerFlow {
|
||||
issueTo: Party,
|
||||
issuerPartyRef: OpaqueBytes): AbstractCashFlow.Result {
|
||||
// TODO: pass notary in as request parameter
|
||||
val notaryParty = serviceHub.networkMapCache.notaryNodes[0].notaryIdentity
|
||||
val notaryParty = serviceHub.networkMapCache.getAnyNotary() ?: throw IllegalArgumentException("Couldn't find any notary in NetworkMapCache")
|
||||
// invoke Cash subflow to issue Asset
|
||||
progressTracker.currentStep = ISSUING
|
||||
val issueCashFlow = CashIssueFlow(amount, issuerPartyRef, notaryParty)
|
||||
|
@ -10,7 +10,6 @@ import net.corda.core.flows.*
|
||||
import net.corda.core.identity.CordaX500Name
|
||||
import net.corda.core.identity.Party
|
||||
import net.corda.core.internal.FetchDataFlow
|
||||
import net.corda.core.node.services.ServiceType
|
||||
import net.corda.core.node.services.Vault.Page
|
||||
import net.corda.core.node.services.queryBy
|
||||
import net.corda.core.node.services.vault.QueryCriteria.VaultQueryCriteria
|
||||
@ -40,7 +39,7 @@ object FlowCookbook {
|
||||
@StartableByRPC
|
||||
// Every flow must subclass ``FlowLogic``. The generic indicates the
|
||||
// flow's return type.
|
||||
class InitiatorFlow(val arg1: Boolean, val arg2: Int, val counterparty: Party) : FlowLogic<Unit>() {
|
||||
class InitiatorFlow(val arg1: Boolean, val arg2: Int, val counterparty: Party, val regulator: Party) : FlowLogic<Unit>() {
|
||||
|
||||
/**---------------------------------
|
||||
* WIRING UP THE PROGRESS TRACKER *
|
||||
@ -109,22 +108,18 @@ object FlowCookbook {
|
||||
// Unlike the first two methods, ``getNotaryNodes`` returns a
|
||||
// ``List<NodeInfo>``. We have to extract the notary identity of
|
||||
// the node we want.
|
||||
val firstNotary: Party = serviceHub.networkMapCache.notaryNodes[0].notaryIdentity
|
||||
val firstNotary: Party = serviceHub.networkMapCache.notaryIdentities[0].party
|
||||
// DOCEND 1
|
||||
|
||||
// We may also need to identify a specific counterparty. We
|
||||
// do so using identity service.
|
||||
// DOCSTART 2
|
||||
val namedCounterparty: Party? = serviceHub.identityService.partyFromX500Name(CordaX500Name(organisation = "NodeA", locality = "London", country = "UK"))
|
||||
val keyedCounterparty: Party? = serviceHub.identityService.partyFromKey(dummyPubKey)
|
||||
val namedCounterparty: Party = serviceHub.identityService.partyFromX500Name(CordaX500Name(organisation = "NodeA", locality = "London", country = "UK")) ?:
|
||||
throw IllegalArgumentException("Couldn't find counterparty for NodeA in identity service")
|
||||
val keyedCounterparty: Party = serviceHub.identityService.partyFromKey(dummyPubKey) ?:
|
||||
throw IllegalArgumentException("Couldn't find counterparty with key: $dummyPubKey in identity service")
|
||||
// DOCEND 2
|
||||
|
||||
// Finally, we can use the map to identify nodes providing a
|
||||
// specific service (e.g. a regulator or an oracle).
|
||||
// DOCSTART 3
|
||||
val regulator: Party = serviceHub.networkMapCache.getPeersWithService(ServiceType.regulator)[0].identity.party
|
||||
// DOCEND 3
|
||||
|
||||
/**-----------------------------
|
||||
* SENDING AND RECEIVING DATA *
|
||||
-----------------------------**/
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.corda.docs
|
||||
|
||||
import net.corda.core.contracts.Amount
|
||||
import net.corda.core.node.services.ServiceInfo
|
||||
import net.corda.core.identity.Party
|
||||
import net.corda.core.utilities.OpaqueBytes
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import net.corda.finance.*
|
||||
@ -9,11 +9,13 @@ import net.corda.finance.contracts.getCashBalances
|
||||
import net.corda.finance.flows.CashIssueFlow
|
||||
import net.corda.node.internal.StartedNode
|
||||
import net.corda.finance.schemas.CashSchemaV1
|
||||
import net.corda.nodeapi.ServiceInfo
|
||||
import net.corda.node.services.network.NetworkMapService
|
||||
import net.corda.node.services.transactions.ValidatingNotaryService
|
||||
import net.corda.testing.DUMMY_NOTARY
|
||||
import net.corda.testing.DUMMY_NOTARY_KEY
|
||||
import net.corda.testing.chooseIdentity
|
||||
import net.corda.testing.getDefaultNotary
|
||||
import net.corda.testing.node.MockNetwork
|
||||
import org.junit.After
|
||||
import org.junit.Assert
|
||||
@ -27,6 +29,7 @@ class CustomVaultQueryTest {
|
||||
lateinit var notaryNode: StartedNode<MockNetwork.MockNode>
|
||||
lateinit var nodeA: StartedNode<MockNetwork.MockNode>
|
||||
lateinit var nodeB: StartedNode<MockNetwork.MockNode>
|
||||
lateinit var notary: Party
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
@ -43,6 +46,7 @@ class CustomVaultQueryTest {
|
||||
nodeA.internals.installCordaService(CustomVaultQuery.Service::class.java)
|
||||
nodeA.internals.registerCustomSchemas(setOf(CashSchemaV1))
|
||||
nodeB.internals.registerCustomSchemas(setOf(CashSchemaV1))
|
||||
notary = nodeA.services.getDefaultNotary()
|
||||
}
|
||||
|
||||
@After
|
||||
@ -71,7 +75,7 @@ class CustomVaultQueryTest {
|
||||
// Use NodeA as issuer and create some dollars
|
||||
val flowHandle1 = nodeA.services.startFlow(CashIssueFlow(amountToIssue,
|
||||
OpaqueBytes.of(0x01),
|
||||
notaryNode.info.notaryIdentity))
|
||||
notary))
|
||||
// Wait for the flow to stop and print
|
||||
flowHandle1.resultFuture.getOrThrow()
|
||||
}
|
||||
@ -81,7 +85,7 @@ class CustomVaultQueryTest {
|
||||
nodeA.info.chooseIdentity(),
|
||||
OpaqueBytes.of(0x01),
|
||||
nodeA.info.chooseIdentity(),
|
||||
notaryNode.info.notaryIdentity))
|
||||
notary))
|
||||
flowHandle1.resultFuture.getOrThrow()
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
package net.corda.docs
|
||||
|
||||
import net.corda.core.node.services.ServiceInfo
|
||||
import net.corda.core.identity.Party
|
||||
import net.corda.core.toFuture
|
||||
import net.corda.core.utilities.OpaqueBytes
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
@ -9,11 +9,13 @@ import net.corda.finance.contracts.getCashBalances
|
||||
import net.corda.finance.flows.CashIssueFlow
|
||||
import net.corda.node.internal.StartedNode
|
||||
import net.corda.finance.schemas.CashSchemaV1
|
||||
import net.corda.nodeapi.ServiceInfo
|
||||
import net.corda.node.services.network.NetworkMapService
|
||||
import net.corda.node.services.transactions.ValidatingNotaryService
|
||||
import net.corda.testing.DUMMY_NOTARY
|
||||
import net.corda.testing.DUMMY_NOTARY_KEY
|
||||
import net.corda.testing.chooseIdentity
|
||||
import net.corda.testing.getDefaultNotary
|
||||
import net.corda.testing.node.MockNetwork
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
@ -25,6 +27,7 @@ class FxTransactionBuildTutorialTest {
|
||||
lateinit var notaryNode: StartedNode<MockNetwork.MockNode>
|
||||
lateinit var nodeA: StartedNode<MockNetwork.MockNode>
|
||||
lateinit var nodeB: StartedNode<MockNetwork.MockNode>
|
||||
lateinit var notary: Party
|
||||
|
||||
@Before
|
||||
fun setup() {
|
||||
@ -39,6 +42,7 @@ class FxTransactionBuildTutorialTest {
|
||||
nodeA.internals.registerCustomSchemas(setOf(CashSchemaV1))
|
||||
nodeB.internals.registerCustomSchemas(setOf(CashSchemaV1))
|
||||
nodeB.internals.registerInitiatedFlow(ForeignExchangeRemoteFlow::class.java)
|
||||
notary = nodeA.services.getDefaultNotary()
|
||||
}
|
||||
|
||||
@After
|
||||
@ -51,7 +55,7 @@ class FxTransactionBuildTutorialTest {
|
||||
// Use NodeA as issuer and create some dollars
|
||||
val flowHandle1 = nodeA.services.startFlow(CashIssueFlow(DOLLARS(1000),
|
||||
OpaqueBytes.of(0x01),
|
||||
notaryNode.info.notaryIdentity))
|
||||
notary))
|
||||
// Wait for the flow to stop and print
|
||||
flowHandle1.resultFuture.getOrThrow()
|
||||
printBalances()
|
||||
@ -59,7 +63,7 @@ class FxTransactionBuildTutorialTest {
|
||||
// Using NodeB as Issuer create some pounds.
|
||||
val flowHandle2 = nodeB.services.startFlow(CashIssueFlow(POUNDS(1000),
|
||||
OpaqueBytes.of(0x01),
|
||||
notaryNode.info.notaryIdentity))
|
||||
notary))
|
||||
// Wait for flow to come to an end and print
|
||||
flowHandle2.resultFuture.getOrThrow()
|
||||
printBalances()
|
||||
|
@ -4,12 +4,12 @@ import net.corda.core.contracts.LinearState
|
||||
import net.corda.core.contracts.StateAndRef
|
||||
import net.corda.core.contracts.UniqueIdentifier
|
||||
import net.corda.core.node.ServiceHub
|
||||
import net.corda.core.node.services.ServiceInfo
|
||||
import net.corda.core.node.services.queryBy
|
||||
import net.corda.core.node.services.vault.QueryCriteria
|
||||
import net.corda.core.toFuture
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import net.corda.node.internal.StartedNode
|
||||
import net.corda.nodeapi.ServiceInfo
|
||||
import net.corda.node.services.network.NetworkMapService
|
||||
import net.corda.node.services.transactions.ValidatingNotaryService
|
||||
import net.corda.testing.DUMMY_NOTARY
|
||||
|
Reference in New Issue
Block a user