Minor: auto-format of module: samples

This commit is contained in:
Mike Hearn
2017-04-11 12:48:15 +02:00
parent eec8b9e4da
commit 9948815df1
19 changed files with 47 additions and 43 deletions

View File

@ -52,14 +52,14 @@ dependencies {
} }
task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) { task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
ext.rpcUsers = [ ['username' : "demo", 'password' : "demo", 'permissions' : ["StartFlow.net.corda.flows.FinalityFlow"]] ] ext.rpcUsers = [['username': "demo", 'password': "demo", 'permissions': ["StartFlow.net.corda.flows.FinalityFlow"]]]
directory "./build/nodes" directory "./build/nodes"
networkMap "Controller" networkMap "Controller"
node { node {
name "Controller" name "Controller"
nearestCity "London" nearestCity "London"
advertisedServices ["corda.notary.validating"] advertisedServices["corda.notary.validating"]
p2pPort 10002 p2pPort 10002
rpcPort 10003 rpcPort 10003
cordapps = [] cordapps = []

View File

@ -25,9 +25,9 @@ class AttachmentDemoTest {
driver(dsl = { driver(dsl = {
val demoUser = listOf(User("demo", "demo", setOf("StartFlow.net.corda.flows.FinalityFlow"))) val demoUser = listOf(User("demo", "demo", setOf("StartFlow.net.corda.flows.FinalityFlow")))
val (nodeA, nodeB) = Futures.allAsList( val (nodeA, nodeB) = Futures.allAsList(
startNode("Bank A", rpcUsers = demoUser), startNode("Bank A", rpcUsers = demoUser),
startNode("Bank B", rpcUsers = demoUser), startNode("Bank B", rpcUsers = demoUser),
startNode("Notary", setOf(ServiceInfo(SimpleNotaryService.Companion.type))) startNode("Notary", setOf(ServiceInfo(SimpleNotaryService.Companion.type)))
).getOrThrow() ).getOrThrow()
val senderThread = CompletableFuture.supplyAsync { val senderThread = CompletableFuture.supplyAsync {
@ -36,7 +36,7 @@ class AttachmentDemoTest {
} }
}.exceptionally { it.printStackTrace() } }.exceptionally { it.printStackTrace() }
val recipientThread = CompletableFuture.supplyAsync{ val recipientThread = CompletableFuture.supplyAsync {
nodeB.rpcClientToNode().use(demoUser[0].username, demoUser[0].password) { nodeB.rpcClientToNode().use(demoUser[0].username, demoUser[0].password) {
recipient(this) recipient(this)
} }

View File

@ -10,16 +10,16 @@ import net.corda.core.div
import net.corda.core.getOrThrow import net.corda.core.getOrThrow
import net.corda.core.messaging.CordaRPCOps import net.corda.core.messaging.CordaRPCOps
import net.corda.core.messaging.startFlow import net.corda.core.messaging.startFlow
import net.corda.core.sizedInputStreamAndHash
import net.corda.core.utilities.Emoji import net.corda.core.utilities.Emoji
import net.corda.flows.FinalityFlow import net.corda.flows.FinalityFlow
import net.corda.nodeapi.config.SSLConfiguration import net.corda.nodeapi.config.SSLConfiguration
import net.corda.testing.ALICE_KEY import net.corda.testing.ALICE_KEY
import java.io.InputStream
import java.nio.file.Path import java.nio.file.Path
import java.nio.file.Paths import java.nio.file.Paths
import kotlin.system.exitProcess import kotlin.system.exitProcess
import kotlin.test.assertEquals import kotlin.test.assertEquals
import java.io.*
import net.corda.core.sizedInputStreamAndHash
internal enum class Role { internal enum class Role {
SENDER, SENDER,

View File

@ -70,10 +70,10 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
webPort 10007 webPort 10007
cordapps = [] cordapps = []
rpcUsers = [ rpcUsers = [
['username' : "bankUser", ['username' : "bankUser",
'password' : "test", 'password' : "test",
'permissions' : ["StartFlow.net.corda.flows.CashPaymentFlow", 'permissions': ["StartFlow.net.corda.flows.CashPaymentFlow",
"StartFlow.net.corda.flows.IssuerFlow\$IssuanceRequester"]] "StartFlow.net.corda.flows.IssuerFlow\$IssuanceRequester"]]
] ]
} }
node { node {
@ -85,9 +85,9 @@ task deployNodes(type: net.corda.plugins.Cordform, dependsOn: ['jar']) {
webPort 10010 webPort 10010
cordapps = [] cordapps = []
rpcUsers = [ rpcUsers = [
['username' : "bigCorpUser", ['username' : "bigCorpUser",
'password' : "test", 'password' : "test",
'permissions' : ["StartFlow.net.corda.flows.CashPaymentFlow"]] 'permissions': ["StartFlow.net.corda.flows.CashPaymentFlow"]]
] ]
} }
} }

View File

@ -14,8 +14,8 @@ class BankOfCordaHttpAPITest {
fun `issuer flow via Http`() { fun `issuer flow via Http`() {
driver(dsl = { driver(dsl = {
val (nodeBankOfCorda) = Futures.allAsList( val (nodeBankOfCorda) = Futures.allAsList(
startNode("BankOfCorda", setOf(ServiceInfo(SimpleNotaryService.type))), startNode("BankOfCorda", setOf(ServiceInfo(SimpleNotaryService.type))),
startNode("BigCorporation") startNode("BigCorporation")
).getOrThrow() ).getOrThrow()
val nodeBankOfCordaApiAddr = startWebserver(nodeBankOfCorda).getOrThrow() val nodeBankOfCordaApiAddr = startWebserver(nodeBankOfCorda).getOrThrow()
assert(BankOfCordaClientApi(nodeBankOfCordaApiAddr).requestWebIssue(IssueRequestParams(1000, "USD", "BigCorporation", "1", "BankOfCorda"))) assert(BankOfCordaClientApi(nodeBankOfCordaApiAddr).requestWebIssue(IssueRequestParams(1000, "USD", "BigCorporation", "1", "BankOfCorda")))

View File

@ -4,11 +4,11 @@ import com.google.common.net.HostAndPort
import joptsimple.OptionParser import joptsimple.OptionParser
import net.corda.bank.api.BankOfCordaClientApi import net.corda.bank.api.BankOfCordaClientApi
import net.corda.bank.api.BankOfCordaWebApi.IssueRequestParams import net.corda.bank.api.BankOfCordaWebApi.IssueRequestParams
import net.corda.flows.IssuerFlow
import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceInfo
import net.corda.core.node.services.ServiceType import net.corda.core.node.services.ServiceType
import net.corda.core.transactions.SignedTransaction import net.corda.core.transactions.SignedTransaction
import net.corda.flows.CashPaymentFlow import net.corda.flows.CashPaymentFlow
import net.corda.flows.IssuerFlow
import net.corda.node.driver.driver import net.corda.node.driver.driver
import net.corda.node.services.startFlowPermission import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
@ -59,8 +59,7 @@ private class BankOfCordaDriver {
startWebserver(bankOfCorda.get()) startWebserver(bankOfCorda.get())
waitForAllNodesToFinish() waitForAllNodesToFinish()
}, isDebug = true) }, isDebug = true)
} } else {
else {
try { try {
val requestParams = IssueRequestParams(options.valueOf(quantity), options.valueOf(currency), "BigCorporation", "1", "BankOfCorda") val requestParams = IssueRequestParams(options.valueOf(quantity), options.valueOf(currency), "BigCorporation", "1", "BankOfCorda")
when (role) { when (role) {
@ -76,10 +75,10 @@ private class BankOfCordaDriver {
if (result) if (result)
println("Successfully processed Cash Issue request") println("Successfully processed Cash Issue request")
} }
Role.ISSUER -> {} Role.ISSUER -> {
}
} }
} } catch (e: Exception) {
catch (e: Exception) {
println("Exception occurred: $e \n ${e.printStackTrace()}") println("Exception occurred: $e \n ${e.printStackTrace()}")
exitProcess(1) exitProcess(1)
} }

View File

@ -20,15 +20,18 @@ class BankOfCordaWebApi(val rpc: CordaRPCOps) {
data class IssueRequestParams(val amount: Long, val currency: String, data class IssueRequestParams(val amount: Long, val currency: String,
val issueToPartyName: String, val issueToPartyRefAsString: String, val issueToPartyName: String, val issueToPartyRefAsString: String,
val issuerBankName: String) val issuerBankName: String)
private companion object { private companion object {
val logger = loggerFor<BankOfCordaWebApi>() val logger = loggerFor<BankOfCordaWebApi>()
} }
@GET @GET
@Path("date") @Path("date")
@Produces(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON)
fun getCurrentDate(): Any { fun getCurrentDate(): Any {
return mapOf("date" to LocalDateTime.now().toLocalDate()) return mapOf("date" to LocalDateTime.now().toLocalDate())
} }
/** /**
* Request asset issuance * Request asset issuance
*/ */

View File

@ -1,11 +1,11 @@
package net.corda.bank.plugin package net.corda.bank.plugin
import net.corda.bank.api.BankOfCordaWebApi import net.corda.bank.api.BankOfCordaWebApi
import net.corda.flows.IssuerFlow
import net.corda.core.contracts.Amount import net.corda.core.contracts.Amount
import net.corda.core.crypto.Party import net.corda.core.crypto.Party
import net.corda.core.node.CordaPluginRegistry import net.corda.core.node.CordaPluginRegistry
import net.corda.core.serialization.OpaqueBytes import net.corda.core.serialization.OpaqueBytes
import net.corda.flows.IssuerFlow
import java.util.function.Function import java.util.function.Function
class BankOfCordaPlugin : CordaPluginRegistry() { class BankOfCordaPlugin : CordaPluginRegistry() {
@ -13,7 +13,7 @@ class BankOfCordaPlugin : CordaPluginRegistry() {
override val webApis = listOf(Function(::BankOfCordaWebApi)) override val webApis = listOf(Function(::BankOfCordaWebApi))
// A list of flow that are required for this cordapp // A list of flow that are required for this cordapp
override val requiredFlows: Map<String, Set<String>> = override val requiredFlows: Map<String, Set<String>> =
mapOf(IssuerFlow.IssuanceRequester::class.java.name to setOf(Amount::class.java.name, Party::class.java.name, OpaqueBytes::class.java.name, Party::class.java.name) mapOf(IssuerFlow.IssuanceRequester::class.java.name to setOf(Amount::class.java.name, Party::class.java.name, OpaqueBytes::class.java.name, Party::class.java.name)
) )
override val servicePlugins = listOf(Function(IssuerFlow.Issuer::Service)) override val servicePlugins = listOf(Function(IssuerFlow.Issuer::Service))
} }

View File

@ -1,7 +1,6 @@
package net.corda.irs.api package net.corda.irs.api
import net.corda.core.contracts.filterStatesOfType import net.corda.core.contracts.filterStatesOfType
import net.corda.core.crypto.AnonymousParty
import net.corda.core.crypto.Party import net.corda.core.crypto.Party
import net.corda.core.getOrThrow import net.corda.core.getOrThrow
import net.corda.core.messaging.CordaRPCOps import net.corda.core.messaging.CordaRPCOps

View File

@ -213,6 +213,7 @@ object NodeInterestRates {
else -> throw IllegalArgumentException("Oracle received data of different type than expected.") else -> throw IllegalArgumentException("Oracle received data of different type than expected.")
} }
} }
val leaves = ftx.filteredLeaves val leaves = ftx.filteredLeaves
if (!leaves.checkWithFun(::check)) if (!leaves.checkWithFun(::check))
throw IllegalArgumentException() throw IllegalArgumentException()

View File

@ -304,7 +304,7 @@ class InterestRateSwap : Contract {
} }
@CordaSerializable @CordaSerializable
open class FixedLeg<P: AbstractParty>( open class FixedLeg<P : AbstractParty>(
var fixedRatePayer: P, var fixedRatePayer: P,
notional: Amount<Currency>, notional: Amount<Currency>,
paymentFrequency: Frequency, paymentFrequency: Frequency,
@ -362,6 +362,7 @@ class InterestRateSwap : Contract {
fixedRatePayer, notional, paymentFrequency, effectiveDate, effectiveDateAdjustment, terminationDate, fixedRatePayer, notional, paymentFrequency, effectiveDate, effectiveDateAdjustment, terminationDate,
terminationDateAdjustment, dayCountBasisDay, dayCountBasisYear, dayInMonth, paymentRule, paymentDelay, terminationDateAdjustment, dayCountBasisDay, dayCountBasisYear, dayInMonth, paymentRule, paymentDelay,
paymentCalendar, interestPeriodAdjustment, fixedRate, rollConvention) paymentCalendar, interestPeriodAdjustment, fixedRate, rollConvention)
fun toAnonymous(): FixedLeg<AnonymousParty> { fun toAnonymous(): FixedLeg<AnonymousParty> {
return FixedLeg(fixedRatePayer.toAnonymous(), notional, paymentFrequency, effectiveDate, effectiveDateAdjustment, terminationDate, terminationDateAdjustment, return FixedLeg(fixedRatePayer.toAnonymous(), notional, paymentFrequency, effectiveDate, effectiveDateAdjustment, terminationDate, terminationDateAdjustment,
dayCountBasisDay, dayCountBasisYear, dayInMonth, paymentRule, paymentDelay, paymentCalendar, interestPeriodAdjustment, dayCountBasisDay, dayCountBasisYear, dayInMonth, paymentRule, paymentDelay, paymentCalendar, interestPeriodAdjustment,
@ -370,7 +371,7 @@ class InterestRateSwap : Contract {
} }
@CordaSerializable @CordaSerializable
open class FloatingLeg<P: AbstractParty>( open class FloatingLeg<P : AbstractParty>(
var floatingRatePayer: P, var floatingRatePayer: P,
notional: Amount<Currency>, notional: Amount<Currency>,
paymentFrequency: Frequency, paymentFrequency: Frequency,
@ -458,6 +459,7 @@ class InterestRateSwap : Contract {
paymentRule, paymentDelay, paymentCalendar, interestPeriodAdjustment, rollConvention, paymentRule, paymentDelay, paymentCalendar, interestPeriodAdjustment, rollConvention,
fixingRollConvention, resetDayInMonth, fixingPeriod, resetRule, fixingsPerPayment, fixingRollConvention, resetDayInMonth, fixingPeriod, resetRule, fixingsPerPayment,
fixingCalendar, index, indexSource, indexTenor) fixingCalendar, index, indexSource, indexTenor)
fun toAnonymous(): FloatingLeg<AnonymousParty> { fun toAnonymous(): FloatingLeg<AnonymousParty> {
return FloatingLeg(floatingRatePayer.toAnonymous(), notional, paymentFrequency, effectiveDate, effectiveDateAdjustment, terminationDate, terminationDateAdjustment, return FloatingLeg(floatingRatePayer.toAnonymous(), notional, paymentFrequency, effectiveDate, effectiveDateAdjustment, terminationDate, terminationDateAdjustment,
dayCountBasisDay, dayCountBasisYear, dayInMonth, paymentRule, paymentDelay, paymentCalendar, interestPeriodAdjustment, dayCountBasisDay, dayCountBasisYear, dayInMonth, paymentRule, paymentDelay, paymentCalendar, interestPeriodAdjustment,
@ -662,7 +664,7 @@ class InterestRateSwap : Contract {
/** /**
* The state class contains the 4 major data classes. * The state class contains the 4 major data classes.
*/ */
data class State<P: AbstractParty>( data class State<P : AbstractParty>(
val fixedLeg: FixedLeg<P>, val fixedLeg: FixedLeg<P>,
val floatingLeg: FloatingLeg<P>, val floatingLeg: FloatingLeg<P>,
val calculation: Calculation, val calculation: Calculation,

View File

@ -73,7 +73,7 @@ object AutoOfferFlow {
return stx return stx
} }
private fun <T: AbstractParty> notUs(parties: List<T>): List<T> { private fun <T : AbstractParty> notUs(parties: List<T>): List<T> {
val notUsParties: MutableList<T> = arrayListOf() val notUsParties: MutableList<T> = arrayListOf()
for (party in parties) { for (party in parties) {
if (serviceHub.myInfo.legalIdentity != party) { if (serviceHub.myInfo.legalIdentity != party) {

View File

@ -135,7 +135,7 @@ object FixingFlow {
* TODO: Replace [FixingSession] and [FixingSessionInitiationHandler] with generic session initiation logic once it exists. * TODO: Replace [FixingSession] and [FixingSessionInitiationHandler] with generic session initiation logic once it exists.
*/ */
class FixingRoleDecider(val ref: StateRef, override val progressTracker: ProgressTracker) : FlowLogic<Unit>() { class FixingRoleDecider(val ref: StateRef, override val progressTracker: ProgressTracker) : FlowLogic<Unit>() {
@Suppress("unused") // Used via reflection. @Suppress("unused") // Used via reflection.
constructor(ref: StateRef) : this(ref, tracker()) constructor(ref: StateRef) : this(ref, tracker())
companion object { companion object {

View File

@ -136,6 +136,7 @@ class NodeInterestRatesTest {
else -> false else -> false
} }
} }
val ftx1 = wtx1.buildFilteredTransaction(::filterAllOutputs) val ftx1 = wtx1.buildFilteredTransaction(::filterAllOutputs)
assertFailsWith<IllegalArgumentException> { oracle.sign(ftx1) } assertFailsWith<IllegalArgumentException> { oracle.sign(ftx1) }
tx.addCommand(Cash.Commands.Move(), ALICE_PUBKEY) tx.addCommand(Cash.Commands.Move(), ALICE_PUBKEY)
@ -231,10 +232,10 @@ class NodeInterestRatesTest {
rateTolerance: BigDecimal, rateTolerance: BigDecimal,
progressTracker: ProgressTracker = RatesFixFlow.tracker(fixOf.name)) : RatesFixFlow(tx, oracle, fixOf, expectedRate, rateTolerance, progressTracker) { progressTracker: ProgressTracker = RatesFixFlow.tracker(fixOf.name)) : RatesFixFlow(tx, oracle, fixOf, expectedRate, rateTolerance, progressTracker) {
override fun filtering(elem: Any): Boolean { override fun filtering(elem: Any): Boolean {
return when (elem) { return when (elem) {
is Command -> oracle.owningKey in elem.signers && elem.value is Fix is Command -> oracle.owningKey in elem.signers && elem.value is Fix
else -> false else -> false
} }
} }
} }

View File

@ -23,7 +23,7 @@ class DummyIssueAndMove(private val notary: Party, private val counterpartyNode:
val moveTx = DummyContract.move(asset, counterPartyKey).apply { val moveTx = DummyContract.move(asset, counterPartyKey).apply {
signWith(myKeyPair) signWith(myKeyPair)
} }
// We don't check signatures because we know that the notary's signature is missing // We don't check signatures because we know that the notary's signature is missing
return moveTx.toSignedTransaction(checkSufficientSignatures = false) return moveTx.toSignedTransaction(checkSufficientSignatures = false)
} }
} }

View File

@ -54,7 +54,7 @@ object SimmFlow {
class Requester(val otherParty: Party, class Requester(val otherParty: Party,
val valuationDate: LocalDate, val valuationDate: LocalDate,
val existing: StateAndRef<PortfolioState>?) val existing: StateAndRef<PortfolioState>?)
: FlowLogic<RevisionedState<PortfolioState.Update>>() { : FlowLogic<RevisionedState<PortfolioState.Update>>() {
constructor(otherParty: Party, valuationDate: LocalDate) : this(otherParty, valuationDate, null) constructor(otherParty: Party, valuationDate: LocalDate) : this(otherParty, valuationDate, null)
lateinit var myIdentity: Party lateinit var myIdentity: Party

View File

@ -20,7 +20,7 @@ object SimmRevaluation {
val myIdentity = serviceHub.myInfo.legalIdentity.toAnonymous() val myIdentity = serviceHub.myInfo.legalIdentity.toAnonymous()
if (myIdentity == curState.parties[0]) { if (myIdentity == curState.parties[0]) {
val otherParty = serviceHub.identityService.partyFromAnonymous(curState.parties[1]) val otherParty = serviceHub.identityService.partyFromAnonymous(curState.parties[1])
require (otherParty != null) { "Other party must be known by this node" } require(otherParty != null) { "Other party must be known by this node" }
subFlow(SimmFlow.Requester(otherParty!!, valuationDate, stateAndRef)) subFlow(SimmFlow.Requester(otherParty!!, valuationDate, stateAndRef))
} }
} }

View File

@ -1,14 +1,14 @@
package net.corda.traderdemo package net.corda.traderdemo
import net.corda.flows.IssuerFlow import net.corda.core.div
import net.corda.core.node.services.ServiceInfo import net.corda.core.node.services.ServiceInfo
import net.corda.flows.IssuerFlow
import net.corda.node.driver.driver import net.corda.node.driver.driver
import net.corda.node.services.startFlowPermission import net.corda.node.services.startFlowPermission
import net.corda.node.services.transactions.SimpleNotaryService import net.corda.node.services.transactions.SimpleNotaryService
import net.corda.nodeapi.User
import net.corda.testing.BOC import net.corda.testing.BOC
import java.nio.file.Paths import java.nio.file.Paths
import net.corda.core.div
import net.corda.nodeapi.User
/** /**
* This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes) * This file is exclusively for being able to run your nodes through an IDE (as opposed to running deployNodes)

View File

@ -4,7 +4,6 @@ import com.google.common.util.concurrent.Futures
import net.corda.contracts.testing.calculateRandomlySizedAmounts import net.corda.contracts.testing.calculateRandomlySizedAmounts
import net.corda.core.contracts.Amount import net.corda.core.contracts.Amount
import net.corda.core.contracts.DOLLARS import net.corda.core.contracts.DOLLARS
import net.corda.core.contracts.Issued
import net.corda.core.getOrThrow import net.corda.core.getOrThrow
import net.corda.core.messaging.CordaRPCOps import net.corda.core.messaging.CordaRPCOps
import net.corda.core.messaging.startFlow import net.corda.core.messaging.startFlow