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
@ -1,7 +1,6 @@
|
||||
package net.corda.traderdemo
|
||||
|
||||
import net.corda.client.rpc.CordaRPCClient
|
||||
import net.corda.core.node.services.ServiceInfo
|
||||
import net.corda.core.utilities.getOrThrow
|
||||
import net.corda.core.utilities.millis
|
||||
import net.corda.finance.DOLLARS
|
||||
@ -10,6 +9,7 @@ import net.corda.finance.flows.CashPaymentFlow
|
||||
import net.corda.finance.schemas.CashSchemaV1
|
||||
import net.corda.finance.schemas.CommercialPaperSchemaV1
|
||||
import net.corda.node.services.FlowPermissions.Companion.startFlowPermission
|
||||
import net.corda.nodeapi.ServiceInfo
|
||||
import net.corda.node.services.transactions.SimpleNotaryService
|
||||
import net.corda.nodeapi.User
|
||||
import net.corda.testing.BOC
|
||||
|
@ -46,12 +46,10 @@ class TraderDemoClientApi(val rpc: CordaRPCOps) {
|
||||
val ref = OpaqueBytes.of(1)
|
||||
val buyer = rpc.partyFromX500Name(buyerName) ?: throw IllegalStateException("Don't know $buyerName")
|
||||
val seller = rpc.partyFromX500Name(sellerName) ?: throw IllegalStateException("Don't know $sellerName")
|
||||
val notaryLegalIdentity = rpc.partyFromX500Name(DUMMY_NOTARY.name)
|
||||
?: throw IllegalStateException("Unable to locate ${DUMMY_NOTARY.name} in Network Map Service")
|
||||
val notaryNode = rpc.nodeIdentityFromParty(notaryLegalIdentity)
|
||||
?: throw IllegalStateException("Unable to locate notary node in network map cache")
|
||||
val notaryIdentity = rpc.notaryIdentities().first().party
|
||||
|
||||
val amounts = calculateRandomlySizedAmounts(amount, 3, 10, Random())
|
||||
rpc.startFlow(::CashIssueFlow, amount, OpaqueBytes.of(1), notaryNode.notaryIdentity).returnValue.getOrThrow()
|
||||
rpc.startFlow(::CashIssueFlow, amount, OpaqueBytes.of(1), notaryIdentity).returnValue.getOrThrow()
|
||||
// Pay random amounts of currency up to the requested amount
|
||||
amounts.forEach { pennies ->
|
||||
// TODO This can't be done in parallel, perhaps due to soft-locking issues?
|
||||
@ -71,7 +69,7 @@ class TraderDemoClientApi(val rpc: CordaRPCOps) {
|
||||
}
|
||||
|
||||
// The line below blocks and waits for the future to resolve.
|
||||
rpc.startFlow(::CommercialPaperIssueFlow, amount, ref, seller, notaryNode.notaryIdentity).returnValue.getOrThrow()
|
||||
rpc.startFlow(::CommercialPaperIssueFlow, amount, ref, seller, notaryIdentity).returnValue.getOrThrow()
|
||||
println("Commercial paper issued to seller")
|
||||
}
|
||||
|
||||
|
@ -29,10 +29,11 @@ class BuyerFlow(val otherParty: Party) : FlowLogic<Unit>() {
|
||||
|
||||
// Receive the offered amount and automatically agree to it (in reality this would be a longer negotiation)
|
||||
val amount = receive<Amount<Currency>>(otherParty).unwrap { it }
|
||||
val notary: NodeInfo = serviceHub.networkMapCache.notaryNodes[0]
|
||||
require(serviceHub.networkMapCache.notaryIdentities.isNotEmpty()) { "No notary nodes registered" }
|
||||
val notary: Party = serviceHub.networkMapCache.notaryIdentities[0].party
|
||||
val buyer = TwoPartyTradeFlow.Buyer(
|
||||
otherParty,
|
||||
notary.notaryIdentity,
|
||||
notary,
|
||||
amount,
|
||||
CommercialPaper.State::class.java)
|
||||
|
||||
|
@ -40,7 +40,7 @@ class SellerFlow(private val otherParty: Party,
|
||||
override fun call(): SignedTransaction {
|
||||
progressTracker.currentStep = SELF_ISSUING
|
||||
|
||||
val notary: NodeInfo = serviceHub.networkMapCache.notaryNodes[0]
|
||||
val notary: Party = serviceHub.networkMapCache.notaryIdentities[0].party
|
||||
val cpOwner = serviceHub.keyManagementService.freshKeyAndCert(ourIdentityAndCert, false)
|
||||
val commercialPaper = serviceHub.vaultQueryService.queryBy(CommercialPaper.State::class.java).states.first()
|
||||
|
||||
@ -50,7 +50,6 @@ class SellerFlow(private val otherParty: Party,
|
||||
send(otherParty, amount)
|
||||
val seller = TwoPartyTradeFlow.Seller(
|
||||
otherParty,
|
||||
notary,
|
||||
commercialPaper,
|
||||
amount,
|
||||
cpOwner,
|
||||
|
@ -1,9 +1,9 @@
|
||||
package net.corda.traderdemo
|
||||
|
||||
import net.corda.core.internal.div
|
||||
import net.corda.core.node.services.ServiceInfo
|
||||
import net.corda.finance.flows.CashIssueFlow
|
||||
import net.corda.node.services.FlowPermissions.Companion.startFlowPermission
|
||||
import net.corda.nodeapi.ServiceInfo
|
||||
import net.corda.node.services.transactions.SimpleNotaryService
|
||||
import net.corda.nodeapi.User
|
||||
import net.corda.testing.BOC
|
||||
|
Reference in New Issue
Block a user