Clean up API for selecting notaries (#1573)

* Remove getAnyNotary() from network map API.
Change notaryIdentities() signature to return a Party instead of PartyAndCertificate.
Some API doc updates.

* Minor API doc formatting and typo fix

* Update changelog

* Address comments

* Address comments
This commit is contained in:
Andrius Dagys
2017-09-21 10:28:18 +01:00
committed by josecoll
parent fd9c79659d
commit 0314e650a4
39 changed files with 118 additions and 144 deletions

View File

@ -18,7 +18,6 @@ import net.corda.finance.contracts.getCashBalance
import net.corda.finance.flows.CashIssueFlow
import net.corda.finance.flows.CashPaymentFlow
import net.corda.node.services.vault.VaultSchemaV1
import net.corda.testing.DUMMY_NOTARY
import net.corda.testing.contracts.calculateRandomlySizedAmounts
import net.corda.traderdemo.flow.CommercialPaperIssueFlow
import net.corda.traderdemo.flow.SellerFlow
@ -46,7 +45,7 @@ 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 notaryIdentity = rpc.notaryIdentities().first().party
val notaryIdentity = rpc.notaryIdentities().first()
val amounts = calculateRandomlySizedAmounts(amount, 3, 10, Random())
rpc.startFlow(::CashIssueFlow, amount, OpaqueBytes.of(1), notaryIdentity).returnValue.getOrThrow()

View File

@ -6,7 +6,6 @@ import net.corda.core.flows.FlowLogic
import net.corda.core.flows.InitiatedBy
import net.corda.core.identity.Party
import net.corda.core.internal.Emoji
import net.corda.core.node.NodeInfo
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.ProgressTracker
import net.corda.core.utilities.unwrap
@ -30,7 +29,7 @@ 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 }
require(serviceHub.networkMapCache.notaryIdentities.isNotEmpty()) { "No notary nodes registered" }
val notary: Party = serviceHub.networkMapCache.notaryIdentities[0].party
val notary: Party = serviceHub.networkMapCache.notaryIdentities.first()
val buyer = TwoPartyTradeFlow.Buyer(
otherParty,
notary,
@ -59,7 +58,7 @@ class BuyerFlow(val otherParty: Party) : FlowLogic<Unit>() {
// the state.
val search = TransactionGraphSearch(serviceHub.validatedTransactions, listOf(tradeTX.tx),
TransactionGraphSearch.Query(withCommandOfType = CommercialPaper.Commands.Issue::class.java,
followInputsOfType = CommercialPaper.State::class.java))
followInputsOfType = CommercialPaper.State::class.java))
val cpIssuance = search.call().single()
// Buyer will fetch the attachment from the seller automatically when it resolves the transaction.

View File

@ -7,7 +7,6 @@ import net.corda.core.flows.FlowLogic
import net.corda.core.flows.InitiatingFlow
import net.corda.core.flows.StartableByRPC
import net.corda.core.identity.Party
import net.corda.core.node.NodeInfo
import net.corda.core.transactions.SignedTransaction
import net.corda.core.utilities.ProgressTracker
import net.corda.finance.contracts.CommercialPaper
@ -40,7 +39,6 @@ class SellerFlow(private val otherParty: Party,
override fun call(): SignedTransaction {
progressTracker.currentStep = SELF_ISSUING
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()