From 6b7580c9778dcdfa049bec563b1f72373c7415d7 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Mon, 11 Jul 2016 16:27:42 +0200 Subject: [PATCH 1/5] Minor: fix compiler warnings. --- .../main/kotlin/com/r3corda/contracts/CommercialPaper.kt | 9 +++++---- contracts/src/main/kotlin/com/r3corda/contracts/IRS.kt | 1 + .../com/r3corda/core/contracts/TransactionTypes.kt | 1 - .../r3corda/core/contracts/TransactionVerification.kt | 9 ++++++--- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/contracts/src/main/kotlin/com/r3corda/contracts/CommercialPaper.kt b/contracts/src/main/kotlin/com/r3corda/contracts/CommercialPaper.kt index 90297b75ec..d14689fd7f 100644 --- a/contracts/src/main/kotlin/com/r3corda/contracts/CommercialPaper.kt +++ b/contracts/src/main/kotlin/com/r3corda/contracts/CommercialPaper.kt @@ -80,10 +80,11 @@ class CommercialPaper : Contract { // it for cash on or after the maturity date. val command = tx.commands.requireSingleCommand() // If it's an issue, we can't take notary from inputs, so it must be specified in the command - val timestamp: TimestampCommand? = if (command.value is Commands.Issue) - tx.getTimestampBy((command.value as Commands.Issue).notary) - else if (command.value is Commands.Redeem) - tx.getTimestampBy((command.value as Commands.Redeem).notary) + val cmdVal = command.value + val timestamp: TimestampCommand? = if (cmdVal is Commands.Issue) + tx.getTimestampBy(cmdVal.notary) + else if (cmdVal is Commands.Redeem) + tx.getTimestampBy(cmdVal.notary) else null diff --git a/contracts/src/main/kotlin/com/r3corda/contracts/IRS.kt b/contracts/src/main/kotlin/com/r3corda/contracts/IRS.kt index b36d935e92..2c4f3d584d 100644 --- a/contracts/src/main/kotlin/com/r3corda/contracts/IRS.kt +++ b/contracts/src/main/kotlin/com/r3corda/contracts/IRS.kt @@ -498,6 +498,7 @@ class InterestRateSwap() : Contract { val command = tx.commands.requireSingleCommand() // TODO: This needs to either be the notary used for the inputs, or otherwise // derived as the correct notary + @Suppress("DEPRECATION") val time = tx.commands.getTimestampByName("Mock Company 0", "Notary Service", "Bank A")?.midpoint if (time == null) throw IllegalArgumentException("must be timestamped") diff --git a/core/src/main/kotlin/com/r3corda/core/contracts/TransactionTypes.kt b/core/src/main/kotlin/com/r3corda/core/contracts/TransactionTypes.kt index 42cb37586a..d43e13cfd3 100644 --- a/core/src/main/kotlin/com/r3corda/core/contracts/TransactionTypes.kt +++ b/core/src/main/kotlin/com/r3corda/core/contracts/TransactionTypes.kt @@ -17,7 +17,6 @@ sealed class TransactionType { * Note: Presence of _signatures_ is not checked, only the public keys to be signed for. */ fun verify(tx: TransactionForVerification) { - val missing = verifySigners(tx) if (missing.isNotEmpty()) throw TransactionVerificationException.SignersMissing(tx, missing.toList()) diff --git a/core/src/main/kotlin/com/r3corda/core/contracts/TransactionVerification.kt b/core/src/main/kotlin/com/r3corda/core/contracts/TransactionVerification.kt index b732d2b6d1..7affb51685 100644 --- a/core/src/main/kotlin/com/r3corda/core/contracts/TransactionVerification.kt +++ b/core/src/main/kotlin/com/r3corda/core/contracts/TransactionVerification.kt @@ -2,6 +2,7 @@ package com.r3corda.core.contracts import com.r3corda.core.crypto.Party import com.r3corda.core.crypto.SecureHash +import com.r3corda.core.crypto.toStringShort import java.security.PublicKey import java.util.* @@ -158,7 +159,7 @@ data class TransactionForContract(val inputs: List, * up on both sides of the transaction, but the values must be summed independently per currency. Grouping can * be used to simplify this logic. */ - data class InOutGroup(val inputs: List, val outputs: List, val groupingKey: K) + data class InOutGroup(val inputs: List, val outputs: List, val groupingKey: K) /** Get the timestamp command for this transaction, using the notary from the input states. */ val timestamp: TimestampCommand? @@ -168,9 +169,9 @@ data class TransactionForContract(val inputs: List, fun getTimestampBy(timestampingAuthority: Party): TimestampCommand? = commands.getTimestampBy(timestampingAuthority) /** Simply calls [commands.getTimestampByName] as a shortcut to make code completion more intuitive. */ + @Suppress("DEPRECATION") @Deprecated(message = "Timestamping authority should always be notary for the transaction") fun getTimestampByName(vararg authorityName: String): TimestampCommand? = commands.getTimestampByName(*authorityName) - } class TransactionResolutionException(val hash: SecureHash) : Exception() @@ -179,6 +180,8 @@ class TransactionConflictException(val conflictRef: StateRef, val tx1: LedgerTra sealed class TransactionVerificationException(val tx: TransactionForVerification, cause: Throwable?) : Exception(cause) { class ContractRejection(tx: TransactionForVerification, val contract: Contract, cause: Throwable?) : TransactionVerificationException(tx, cause) class MoreThanOneNotary(tx: TransactionForVerification) : TransactionVerificationException(tx, null) - class SignersMissing(tx: TransactionForVerification, missing: List) : TransactionVerificationException(tx, null) + class SignersMissing(tx: TransactionForVerification, val missing: List) : TransactionVerificationException(tx, null) { + override fun toString() = "Signers missing: ${missing.map { it.toStringShort() }}" + } class InvalidNotaryChange(tx: TransactionForVerification) : TransactionVerificationException(tx, null) } From 41d092a16911f9688c41acdd608ec645a6e98dc8 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Mon, 11 Jul 2016 16:30:37 +0200 Subject: [PATCH 2/5] Minor: optimize imports --- contracts/isolated/build.gradle | 3 ++- .../core/node/DummyContractBackdoor.kt | 2 +- .../contracts/ICommercialPaperState.java | 7 ++--- .../contracts/JavaCommercialPaper.java | 26 +++++++------------ .../r3corda/contracts/asset/FungibleAsset.kt | 4 --- .../contracts/asset/FungibleAssetState.kt | 1 - .../contracts/asset/CashTestsJava.java | 10 +++---- .../contracts/asset/ObligationTests.kt | 6 +++-- .../core/node/services/NetworkMapCache.kt | 1 - .../r3corda/core/testing/DummyLinearState.kt | 1 - .../r3corda/protocols/FetchDataProtocol.kt | 2 ++ .../com/r3corda/protocols/RatesFixProtocol.kt | 1 + .../AbstractStateReplacementProtocol.kt | 2 ++ .../kotlin/protocols/NotaryChangeProtocol.kt | 2 ++ .../ProtocolLogicRefFromJavaTest.java | 9 +++---- .../contracts/TransactionGraphSearchTests.kt | 1 - .../core/contracts/TransactionGroupTests.kt | 1 - .../com/r3corda/core/crypto/Base58Test.kt | 4 +-- .../TransactionSerializationTests.kt | 1 - .../com/r3corda/node/internal/AbstractNode.kt | 3 --- .../kotlin/com/r3corda/node/internal/Node.kt | 2 -- .../network/InMemoryMessagingNetwork.kt | 1 + .../persistence/NodeAttachmentService.kt | 8 ++---- .../persistence/StorageServiceImpl.kt | 1 - .../node/servlets/DataUploadServlet.kt | 4 +-- .../node/utilities/ANSIProgressRenderer.kt | 1 + .../node/messaging/InMemoryMessagingTests.kt | 2 -- .../services/NodeAttachmentStorageTest.kt | 6 +---- .../node/services/WalletWithCashTest.kt | 2 +- .../node/visualiser/GroupToGraphConversion.kt | 4 ++- 30 files changed, 47 insertions(+), 71 deletions(-) diff --git a/contracts/isolated/build.gradle b/contracts/isolated/build.gradle index 37df6202ee..d9d9f852e4 100644 --- a/contracts/isolated/build.gradle +++ b/contracts/isolated/build.gradle @@ -1,11 +1,12 @@ import com.google.common.io.ByteStreams + import java.nio.file.Files import java.nio.file.Paths import java.nio.file.StandardCopyOption import java.nio.file.attribute.FileTime import java.util.zip.ZipEntry -import java.util.zip.ZipOutputStream import java.util.zip.ZipFile +import java.util.zip.ZipOutputStream buildscript { repositories { diff --git a/contracts/isolated/src/main/kotlin/com/r3corda/core/node/DummyContractBackdoor.kt b/contracts/isolated/src/main/kotlin/com/r3corda/core/node/DummyContractBackdoor.kt index a01d417df3..b54b87eb64 100644 --- a/contracts/isolated/src/main/kotlin/com/r3corda/core/node/DummyContractBackdoor.kt +++ b/contracts/isolated/src/main/kotlin/com/r3corda/core/node/DummyContractBackdoor.kt @@ -1,9 +1,9 @@ package com.r3corda.core.node import com.r3corda.core.contracts.ContractState -import com.r3corda.core.crypto.Party import com.r3corda.core.contracts.PartyAndReference import com.r3corda.core.contracts.TransactionBuilder +import com.r3corda.core.crypto.Party interface DummyContractBackdoor { fun generateInitial(owner: PartyAndReference, magicNumber: Int, notary: Party): TransactionBuilder diff --git a/contracts/src/main/java/com/r3corda/contracts/ICommercialPaperState.java b/contracts/src/main/java/com/r3corda/contracts/ICommercialPaperState.java index 40ffce6315..778dbd4a6f 100644 --- a/contracts/src/main/java/com/r3corda/contracts/ICommercialPaperState.java +++ b/contracts/src/main/java/com/r3corda/contracts/ICommercialPaperState.java @@ -1,13 +1,10 @@ package com.r3corda.contracts; -import com.r3corda.core.contracts.Amount; -import com.r3corda.core.contracts.ContractState; -import com.r3corda.core.contracts.PartyAndReference; -import com.r3corda.core.contracts.Issued; +import com.r3corda.core.contracts.*; import java.security.*; import java.time.*; -import java.util.Currency; +import java.util.*; /* This is an interface solely created to demonstrate that the same kotlin tests can be run against * either a Java implementation of the CommercialPaper or a kotlin implementation. diff --git a/contracts/src/main/java/com/r3corda/contracts/JavaCommercialPaper.java b/contracts/src/main/java/com/r3corda/contracts/JavaCommercialPaper.java index ec7ab3a1c7..c70d06bdd0 100644 --- a/contracts/src/main/java/com/r3corda/contracts/JavaCommercialPaper.java +++ b/contracts/src/main/java/com/r3corda/contracts/JavaCommercialPaper.java @@ -1,24 +1,18 @@ package com.r3corda.contracts; -import com.google.common.collect.ImmutableList; -import com.r3corda.contracts.asset.Cash; -import com.r3corda.contracts.asset.CashKt; -import com.r3corda.contracts.asset.InsufficientBalanceException; +import com.google.common.collect.*; +import com.r3corda.contracts.asset.*; import com.r3corda.core.contracts.*; -import com.r3corda.core.contracts.TransactionForContract.InOutGroup; -import com.r3corda.core.crypto.NullPublicKey; -import com.r3corda.core.crypto.Party; -import com.r3corda.core.crypto.SecureHash; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; +import com.r3corda.core.contracts.TransactionForContract.*; +import com.r3corda.core.crypto.*; +import org.jetbrains.annotations.*; -import java.security.PublicKey; -import java.time.Instant; -import java.util.Currency; -import java.util.List; +import java.security.*; +import java.time.*; +import java.util.*; -import static com.r3corda.core.contracts.ContractsDSL.requireSingleCommand; -import static kotlin.collections.CollectionsKt.single; +import static com.r3corda.core.contracts.ContractsDSL.*; +import static kotlin.collections.CollectionsKt.*; /** diff --git a/contracts/src/main/kotlin/com/r3corda/contracts/asset/FungibleAsset.kt b/contracts/src/main/kotlin/com/r3corda/contracts/asset/FungibleAsset.kt index 60a2638789..c935db7594 100644 --- a/contracts/src/main/kotlin/com/r3corda/contracts/asset/FungibleAsset.kt +++ b/contracts/src/main/kotlin/com/r3corda/contracts/asset/FungibleAsset.kt @@ -2,11 +2,7 @@ package com.r3corda.contracts.asset import com.r3corda.core.contracts.* import com.r3corda.core.crypto.Party -import com.r3corda.core.crypto.SecureHash -import com.r3corda.core.crypto.toStringShort -import com.r3corda.core.utilities.Emoji import java.security.PublicKey -import java.security.SecureRandom import java.util.* ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/contracts/src/main/kotlin/com/r3corda/contracts/asset/FungibleAssetState.kt b/contracts/src/main/kotlin/com/r3corda/contracts/asset/FungibleAssetState.kt index 436919b690..452ed85af5 100644 --- a/contracts/src/main/kotlin/com/r3corda/contracts/asset/FungibleAssetState.kt +++ b/contracts/src/main/kotlin/com/r3corda/contracts/asset/FungibleAssetState.kt @@ -1,7 +1,6 @@ package com.r3corda.contracts.asset import com.r3corda.core.contracts.Amount -import com.r3corda.core.contracts.Issued import com.r3corda.core.contracts.OwnableState import java.security.PublicKey diff --git a/contracts/src/test/java/com/r3corda/contracts/asset/CashTestsJava.java b/contracts/src/test/java/com/r3corda/contracts/asset/CashTestsJava.java index 0250935477..55c5fed4e3 100644 --- a/contracts/src/test/java/com/r3corda/contracts/asset/CashTestsJava.java +++ b/contracts/src/test/java/com/r3corda/contracts/asset/CashTestsJava.java @@ -1,12 +1,12 @@ package com.r3corda.contracts.asset; -import com.r3corda.core.contracts.PartyAndReference; -import com.r3corda.core.serialization.OpaqueBytes; -import kotlin.Unit; -import org.junit.Test; +import com.r3corda.core.contracts.*; +import com.r3corda.core.serialization.*; +import kotlin.*; +import org.junit.*; -import static com.r3corda.core.testing.CoreTestUtils.*; import static com.r3corda.core.contracts.ContractsDSL.*; +import static com.r3corda.core.testing.CoreTestUtils.*; /** * This is an incomplete Java replica of CashTests.kt to show how to use the Java test DSL diff --git a/contracts/src/test/kotlin/com/r3corda/contracts/asset/ObligationTests.kt b/contracts/src/test/kotlin/com/r3corda/contracts/asset/ObligationTests.kt index a37c250c6d..b69754004e 100644 --- a/contracts/src/test/kotlin/com/r3corda/contracts/asset/ObligationTests.kt +++ b/contracts/src/test/kotlin/com/r3corda/contracts/asset/ObligationTests.kt @@ -1,7 +1,6 @@ package com.r3corda.contracts.asset import com.r3corda.contracts.asset.Obligation.Lifecycle -import com.r3corda.contracts.testing.* import com.r3corda.core.contracts.* import com.r3corda.core.crypto.SecureHash import com.r3corda.core.testing.* @@ -11,7 +10,10 @@ import java.security.PublicKey import java.time.Duration import java.time.Instant import java.util.* -import kotlin.test.* +import kotlin.test.assertEquals +import kotlin.test.assertFailsWith +import kotlin.test.assertNotEquals +import kotlin.test.assertTrue class ObligationTests { val defaultIssuer = MEGA_CORP.ref(1) diff --git a/core/src/main/kotlin/com/r3corda/core/node/services/NetworkMapCache.kt b/core/src/main/kotlin/com/r3corda/core/node/services/NetworkMapCache.kt index fa86c2669c..5ffa78ae11 100644 --- a/core/src/main/kotlin/com/r3corda/core/node/services/NetworkMapCache.kt +++ b/core/src/main/kotlin/com/r3corda/core/node/services/NetworkMapCache.kt @@ -5,7 +5,6 @@ import com.r3corda.core.contracts.Contract import com.r3corda.core.crypto.Party import com.r3corda.core.messaging.MessagingService import com.r3corda.core.node.NodeInfo -import com.r3corda.core.node.services.ServiceType import org.slf4j.LoggerFactory import java.security.PublicKey diff --git a/core/src/main/kotlin/com/r3corda/core/testing/DummyLinearState.kt b/core/src/main/kotlin/com/r3corda/core/testing/DummyLinearState.kt index 756e1c4494..4868efcb59 100644 --- a/core/src/main/kotlin/com/r3corda/core/testing/DummyLinearState.kt +++ b/core/src/main/kotlin/com/r3corda/core/testing/DummyLinearState.kt @@ -4,7 +4,6 @@ import com.r3corda.core.contracts.Contract import com.r3corda.core.contracts.LinearState import com.r3corda.core.crypto.SecureHash import java.security.PublicKey -import java.util.* class DummyLinearState( override val thread: SecureHash = SecureHash.randomSHA256(), diff --git a/core/src/main/kotlin/com/r3corda/protocols/FetchDataProtocol.kt b/core/src/main/kotlin/com/r3corda/protocols/FetchDataProtocol.kt index f72aafbeb9..48197eb970 100644 --- a/core/src/main/kotlin/com/r3corda/protocols/FetchDataProtocol.kt +++ b/core/src/main/kotlin/com/r3corda/protocols/FetchDataProtocol.kt @@ -7,6 +7,8 @@ import com.r3corda.core.crypto.SecureHash import com.r3corda.core.protocols.ProtocolLogic import com.r3corda.core.random63BitValue import com.r3corda.core.utilities.UntrustworthyData +import com.r3corda.protocols.FetchDataProtocol.DownloadedVsRequestedDataMismatch +import com.r3corda.protocols.FetchDataProtocol.HashNotFound import java.util.* /** diff --git a/core/src/main/kotlin/com/r3corda/protocols/RatesFixProtocol.kt b/core/src/main/kotlin/com/r3corda/protocols/RatesFixProtocol.kt index d61ad3d968..048f1a8767 100644 --- a/core/src/main/kotlin/com/r3corda/protocols/RatesFixProtocol.kt +++ b/core/src/main/kotlin/com/r3corda/protocols/RatesFixProtocol.kt @@ -11,6 +11,7 @@ import com.r3corda.core.protocols.ProtocolLogic import com.r3corda.core.random63BitValue import com.r3corda.core.utilities.ProgressTracker import com.r3corda.core.utilities.suggestInterestRateAnnouncementTimeWindow +import com.r3corda.protocols.RatesFixProtocol.FixOutOfRange import java.math.BigDecimal import java.time.Duration import java.time.Instant diff --git a/core/src/main/kotlin/protocols/AbstractStateReplacementProtocol.kt b/core/src/main/kotlin/protocols/AbstractStateReplacementProtocol.kt index 1aafd6fed8..1ae3e98408 100644 --- a/core/src/main/kotlin/protocols/AbstractStateReplacementProtocol.kt +++ b/core/src/main/kotlin/protocols/AbstractStateReplacementProtocol.kt @@ -13,6 +13,8 @@ import com.r3corda.core.utilities.ProgressTracker import com.r3corda.protocols.NotaryProtocol import com.r3corda.protocols.PartyRequestMessage import com.r3corda.protocols.ResolveTransactionsProtocol +import protocols.AbstractStateReplacementProtocol.Acceptor +import protocols.AbstractStateReplacementProtocol.Instigator import java.security.PublicKey /** diff --git a/core/src/main/kotlin/protocols/NotaryChangeProtocol.kt b/core/src/main/kotlin/protocols/NotaryChangeProtocol.kt index 7ec371acc4..b0f6d13456 100644 --- a/core/src/main/kotlin/protocols/NotaryChangeProtocol.kt +++ b/core/src/main/kotlin/protocols/NotaryChangeProtocol.kt @@ -4,6 +4,8 @@ import co.paralleluniverse.fibers.Suspendable import com.r3corda.core.contracts.* import com.r3corda.core.crypto.Party import com.r3corda.core.utilities.ProgressTracker +import protocols.NotaryChangeProtocol.Acceptor +import protocols.NotaryChangeProtocol.Instigator import java.security.PublicKey /** diff --git a/core/src/test/java/com/r3corda/core/protocols/ProtocolLogicRefFromJavaTest.java b/core/src/test/java/com/r3corda/core/protocols/ProtocolLogicRefFromJavaTest.java index b17b1fde80..3af28e217f 100644 --- a/core/src/test/java/com/r3corda/core/protocols/ProtocolLogicRefFromJavaTest.java +++ b/core/src/test/java/com/r3corda/core/protocols/ProtocolLogicRefFromJavaTest.java @@ -1,13 +1,10 @@ package com.r3corda.core.protocols; -import org.jetbrains.annotations.NotNull; -import org.junit.Test; +import org.jetbrains.annotations.*; +import org.junit.*; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; +import java.util.*; public class ProtocolLogicRefFromJavaTest { diff --git a/core/src/test/kotlin/com/r3corda/core/contracts/TransactionGraphSearchTests.kt b/core/src/test/kotlin/com/r3corda/core/contracts/TransactionGraphSearchTests.kt index a6630302f3..e181996ce0 100644 --- a/core/src/test/kotlin/com/r3corda/core/contracts/TransactionGraphSearchTests.kt +++ b/core/src/test/kotlin/com/r3corda/core/contracts/TransactionGraphSearchTests.kt @@ -6,7 +6,6 @@ import com.r3corda.core.testing.DUMMY_NOTARY import com.r3corda.core.testing.MEGA_CORP_KEY import org.junit.Test import java.security.KeyPair -import java.security.SecureRandom import kotlin.test.assertEquals class TransactionGraphSearchTests { diff --git a/core/src/test/kotlin/com/r3corda/core/contracts/TransactionGroupTests.kt b/core/src/test/kotlin/com/r3corda/core/contracts/TransactionGroupTests.kt index 6fb59ef18c..97562c648b 100644 --- a/core/src/test/kotlin/com/r3corda/core/contracts/TransactionGroupTests.kt +++ b/core/src/test/kotlin/com/r3corda/core/contracts/TransactionGroupTests.kt @@ -7,7 +7,6 @@ import com.r3corda.core.node.services.testing.MockStorageService import com.r3corda.core.testing.* import org.junit.Test import java.security.PublicKey -import java.security.SecureRandom import java.util.* import kotlin.test.assertEquals import kotlin.test.assertFailsWith diff --git a/core/src/test/kotlin/com/r3corda/core/crypto/Base58Test.kt b/core/src/test/kotlin/com/r3corda/core/crypto/Base58Test.kt index 8911790c5a..b11017a1ce 100644 --- a/core/src/test/kotlin/com/r3corda/core/crypto/Base58Test.kt +++ b/core/src/test/kotlin/com/r3corda/core/crypto/Base58Test.kt @@ -1,8 +1,8 @@ package com.r3corda.core.crypto -import java.math.BigInteger -import java.util.Arrays import org.junit.Test +import java.math.BigInteger +import java.util.* import kotlin.test.assertEquals import kotlin.test.assertTrue import kotlin.test.fail diff --git a/core/src/test/kotlin/com/r3corda/core/serialization/TransactionSerializationTests.kt b/core/src/test/kotlin/com/r3corda/core/serialization/TransactionSerializationTests.kt index 021c6c3251..e335db44a0 100644 --- a/core/src/test/kotlin/com/r3corda/core/serialization/TransactionSerializationTests.kt +++ b/core/src/test/kotlin/com/r3corda/core/serialization/TransactionSerializationTests.kt @@ -9,7 +9,6 @@ import com.r3corda.core.testing.* import org.junit.Before import org.junit.Test import java.security.PublicKey -import java.security.SecureRandom import java.security.SignatureException import java.util.* import kotlin.test.assertEquals diff --git a/node/src/main/kotlin/com/r3corda/node/internal/AbstractNode.kt b/node/src/main/kotlin/com/r3corda/node/internal/AbstractNode.kt index ae4276cbeb..f21b8708be 100644 --- a/node/src/main/kotlin/com/r3corda/node/internal/AbstractNode.kt +++ b/node/src/main/kotlin/com/r3corda/node/internal/AbstractNode.kt @@ -5,7 +5,6 @@ import com.google.common.util.concurrent.ListenableFuture import com.google.common.util.concurrent.SettableFuture import com.r3corda.core.RunOnCallerThread import com.r3corda.core.contracts.SignedTransaction -import com.r3corda.core.contracts.StateRef import com.r3corda.core.crypto.Party import com.r3corda.core.messaging.MessagingService import com.r3corda.core.messaging.runOnNextMessage @@ -48,14 +47,12 @@ import com.r3corda.node.services.wallet.NodeWalletService import com.r3corda.node.utilities.ANSIProgressObserver import com.r3corda.node.utilities.AddOrRemove import com.r3corda.node.utilities.AffinityExecutor -import com.r3corda.protocols.TwoPartyDealProtocol import org.slf4j.Logger import java.nio.file.FileAlreadyExistsException import java.nio.file.Files import java.nio.file.Path import java.security.KeyPair import java.time.Clock -import java.time.Duration import java.util.* /** diff --git a/node/src/main/kotlin/com/r3corda/node/internal/Node.kt b/node/src/main/kotlin/com/r3corda/node/internal/Node.kt index 1c5c167b76..7646fa7aca 100644 --- a/node/src/main/kotlin/com/r3corda/node/internal/Node.kt +++ b/node/src/main/kotlin/com/r3corda/node/internal/Node.kt @@ -3,7 +3,6 @@ package com.r3corda.node.internal import com.codahale.metrics.JmxReporter import com.google.common.net.HostAndPort import com.r3corda.core.messaging.MessagingService -import com.r3corda.core.node.CordaPluginRegistry import com.r3corda.core.node.NodeInfo import com.r3corda.core.node.ServiceHub import com.r3corda.core.node.services.ServiceType @@ -30,7 +29,6 @@ import java.net.InetSocketAddress import java.nio.channels.FileLock import java.nio.file.Path import java.time.Clock -import java.util.* import javax.management.ObjectName class ConfigurationException(message: String) : Exception(message) diff --git a/node/src/main/kotlin/com/r3corda/node/services/network/InMemoryMessagingNetwork.kt b/node/src/main/kotlin/com/r3corda/node/services/network/InMemoryMessagingNetwork.kt index 65f22209f9..864b898e6c 100644 --- a/node/src/main/kotlin/com/r3corda/node/services/network/InMemoryMessagingNetwork.kt +++ b/node/src/main/kotlin/com/r3corda/node/services/network/InMemoryMessagingNetwork.kt @@ -10,6 +10,7 @@ import com.r3corda.core.messaging.* import com.r3corda.core.serialization.SingletonSerializeAsToken import com.r3corda.core.utilities.loggerFor import com.r3corda.core.utilities.trace +import com.r3corda.node.services.network.InMemoryMessagingNetwork.InMemoryMessaging import org.slf4j.LoggerFactory import rx.Observable import rx.subjects.PublishSubject diff --git a/node/src/main/kotlin/com/r3corda/node/services/persistence/NodeAttachmentService.kt b/node/src/main/kotlin/com/r3corda/node/services/persistence/NodeAttachmentService.kt index 74c7182fe2..2bf71ae512 100644 --- a/node/src/main/kotlin/com/r3corda/node/services/persistence/NodeAttachmentService.kt +++ b/node/src/main/kotlin/com/r3corda/node/services/persistence/NodeAttachmentService.kt @@ -8,16 +8,12 @@ import com.google.common.io.CountingInputStream import com.r3corda.core.contracts.Attachment import com.r3corda.core.crypto.SecureHash import com.r3corda.core.extractZipFile -import com.r3corda.node.services.api.AcceptsFileUpload import com.r3corda.core.node.services.AttachmentStorage import com.r3corda.core.utilities.loggerFor +import com.r3corda.node.services.api.AcceptsFileUpload import java.io.FilterInputStream import java.io.InputStream -import java.nio.file.FileAlreadyExistsException -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.Paths -import java.nio.file.StandardCopyOption +import java.nio.file.* import java.util.* import java.util.jar.JarInputStream import javax.annotation.concurrent.ThreadSafe diff --git a/node/src/main/kotlin/com/r3corda/node/services/persistence/StorageServiceImpl.kt b/node/src/main/kotlin/com/r3corda/node/services/persistence/StorageServiceImpl.kt index 3880832a57..f2f3ba918c 100644 --- a/node/src/main/kotlin/com/r3corda/node/services/persistence/StorageServiceImpl.kt +++ b/node/src/main/kotlin/com/r3corda/node/services/persistence/StorageServiceImpl.kt @@ -2,7 +2,6 @@ package com.r3corda.node.services.persistence import com.r3corda.core.crypto.Party import com.r3corda.core.node.services.AttachmentStorage -import com.r3corda.core.node.services.StorageService import com.r3corda.core.node.services.TransactionStorage import com.r3corda.core.node.services.TxWritableStorageService import com.r3corda.core.serialization.SingletonSerializeAsToken diff --git a/node/src/main/kotlin/com/r3corda/node/servlets/DataUploadServlet.kt b/node/src/main/kotlin/com/r3corda/node/servlets/DataUploadServlet.kt index 742061b22d..38754f72e5 100644 --- a/node/src/main/kotlin/com/r3corda/node/servlets/DataUploadServlet.kt +++ b/node/src/main/kotlin/com/r3corda/node/servlets/DataUploadServlet.kt @@ -1,8 +1,8 @@ package com.r3corda.node.servlets -import com.r3corda.node.services.api.AcceptsFileUpload -import com.r3corda.node.internal.Node import com.r3corda.core.utilities.loggerFor +import com.r3corda.node.internal.Node +import com.r3corda.node.services.api.AcceptsFileUpload import org.apache.commons.fileupload.servlet.ServletFileUpload import java.util.* import javax.servlet.http.HttpServlet diff --git a/node/src/main/kotlin/com/r3corda/node/utilities/ANSIProgressRenderer.kt b/node/src/main/kotlin/com/r3corda/node/utilities/ANSIProgressRenderer.kt index e9bcf5bf99..0ee7077e75 100644 --- a/node/src/main/kotlin/com/r3corda/node/utilities/ANSIProgressRenderer.kt +++ b/node/src/main/kotlin/com/r3corda/node/utilities/ANSIProgressRenderer.kt @@ -3,6 +3,7 @@ package com.r3corda.node.utilities import com.r3corda.core.utilities.BriefLogFormatter import com.r3corda.core.utilities.Emoji import com.r3corda.core.utilities.ProgressTracker +import com.r3corda.node.utilities.ANSIProgressRenderer.progressTracker import org.fusesource.jansi.Ansi import org.fusesource.jansi.AnsiConsole import org.fusesource.jansi.AnsiOutputStream diff --git a/node/src/test/kotlin/com/r3corda/node/messaging/InMemoryMessagingTests.kt b/node/src/test/kotlin/com/r3corda/node/messaging/InMemoryMessagingTests.kt index 16587fb479..a8337f40c4 100644 --- a/node/src/test/kotlin/com/r3corda/node/messaging/InMemoryMessagingTests.kt +++ b/node/src/test/kotlin/com/r3corda/node/messaging/InMemoryMessagingTests.kt @@ -4,8 +4,6 @@ package com.r3corda.node.messaging import com.r3corda.core.messaging.Message import com.r3corda.core.messaging.TopicStringValidator -import com.r3corda.core.messaging.send -import com.r3corda.core.serialization.deserialize import com.r3corda.node.internal.testing.MockNetwork import org.junit.Before import org.junit.Test diff --git a/node/src/test/kotlin/com/r3corda/node/services/NodeAttachmentStorageTest.kt b/node/src/test/kotlin/com/r3corda/node/services/NodeAttachmentStorageTest.kt index 45e06a6049..e2a258d1a0 100644 --- a/node/src/test/kotlin/com/r3corda/node/services/NodeAttachmentStorageTest.kt +++ b/node/src/test/kotlin/com/r3corda/node/services/NodeAttachmentStorageTest.kt @@ -9,11 +9,7 @@ import com.r3corda.node.services.persistence.NodeAttachmentService import org.junit.Before import org.junit.Test import java.nio.charset.Charset -import java.nio.file.FileAlreadyExistsException -import java.nio.file.FileSystem -import java.nio.file.Files -import java.nio.file.Path -import java.nio.file.StandardOpenOption +import java.nio.file.* import java.util.jar.JarEntry import java.util.jar.JarOutputStream import kotlin.test.assertEquals diff --git a/node/src/test/kotlin/com/r3corda/node/services/WalletWithCashTest.kt b/node/src/test/kotlin/com/r3corda/node/services/WalletWithCashTest.kt index ce48cae626..0270e7ffa9 100644 --- a/node/src/test/kotlin/com/r3corda/node/services/WalletWithCashTest.kt +++ b/node/src/test/kotlin/com/r3corda/node/services/WalletWithCashTest.kt @@ -12,10 +12,10 @@ import com.r3corda.core.serialization.OpaqueBytes import com.r3corda.core.testing.* import com.r3corda.core.utilities.BriefLogFormatter import com.r3corda.node.services.wallet.NodeWalletService +import org.assertj.core.api.Assertions.assertThatThrownBy import org.junit.After import org.junit.Before import org.junit.Test -import org.assertj.core.api.Assertions.assertThatThrownBy; import java.util.* import kotlin.test.assertEquals import kotlin.test.assertNull diff --git a/node/src/test/kotlin/com/r3corda/node/visualiser/GroupToGraphConversion.kt b/node/src/test/kotlin/com/r3corda/node/visualiser/GroupToGraphConversion.kt index e57cffe02d..4dc34b2f5d 100644 --- a/node/src/test/kotlin/com/r3corda/node/visualiser/GroupToGraphConversion.kt +++ b/node/src/test/kotlin/com/r3corda/node/visualiser/GroupToGraphConversion.kt @@ -3,7 +3,9 @@ package com.r3corda.node.visualiser import com.r3corda.core.contracts.CommandData import com.r3corda.core.contracts.ContractState import com.r3corda.core.crypto.SecureHash -import com.r3corda.core.testing.* +import com.r3corda.core.testing.LedgerDSL +import com.r3corda.core.testing.TestLedgerDSLInterpreter +import com.r3corda.core.testing.TestTransactionDSLInterpreter import org.graphstream.graph.Edge import org.graphstream.graph.Node import org.graphstream.graph.implementations.SingleGraph From 0a2f313d406b9b88dc570855e2fc02ad3ef1910d Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Mon, 11 Jul 2016 16:33:17 +0200 Subject: [PATCH 3/5] Minor: run IntelliJ 'code cleanup' --- .../kotlin/com/r3corda/core/crypto/CryptoUtilities.kt | 2 +- .../main/kotlin/com/r3corda/core/serialization/Kryo.kt | 2 +- .../test/kotlin/com/r3corda/core/crypto/Base58Test.kt | 2 +- .../kotlin/com/r3corda/core/utilities/NonEmptySetTest.kt | 4 ++-- docs/build/html/_static/js/theme.js | 9 ++++----- docs/build/html/_static/searchtools.js | 6 +++--- .../main/kotlin/com/r3corda/node/utilities/ClockUtils.kt | 2 +- .../kotlin/com/r3corda/node/utilities/JsonSupport.kt | 2 +- .../kotlin/com/r3corda/node/visualiser/GraphStream.kt | 2 +- .../kotlin/com/r3corda/core/testing/TraderDemoTest.kt | 2 +- .../com/r3corda/core/testing/utilities/JVMSpawner.kt | 2 +- src/main/kotlin/com/r3corda/demos/utilities/HttpUtils.kt | 6 +++--- 12 files changed, 20 insertions(+), 21 deletions(-) diff --git a/core/src/main/kotlin/com/r3corda/core/crypto/CryptoUtilities.kt b/core/src/main/kotlin/com/r3corda/core/crypto/CryptoUtilities.kt index 60c1417dd3..fc6169e5a0 100644 --- a/core/src/main/kotlin/com/r3corda/core/crypto/CryptoUtilities.kt +++ b/core/src/main/kotlin/com/r3corda/core/crypto/CryptoUtilities.kt @@ -19,7 +19,7 @@ fun newSecureRandom(): SecureRandom { } // "sealed" here means there can't be any subclasses other than the ones defined here. -sealed class SecureHash private constructor(bits: ByteArray) : OpaqueBytes(bits) { +sealed class SecureHash constructor(bits: ByteArray) : OpaqueBytes(bits) { class SHA256(bits: ByteArray) : SecureHash(bits) { init { require(bits.size == 32) diff --git a/core/src/main/kotlin/com/r3corda/core/serialization/Kryo.kt b/core/src/main/kotlin/com/r3corda/core/serialization/Kryo.kt index 904741d06a..09371124b4 100644 --- a/core/src/main/kotlin/com/r3corda/core/serialization/Kryo.kt +++ b/core/src/main/kotlin/com/r3corda/core/serialization/Kryo.kt @@ -326,7 +326,7 @@ fun createKryo(k: Kryo = Kryo()): Kryo { // no-arg constructor available. instantiatorStrategy = DefaultInstantiatorStrategy(StdInstantiatorStrategy()) - register(Arrays.asList("").javaClass, ArraysAsListSerializer()); + register(Arrays.asList("").javaClass, ArraysAsListSerializer()) // Because we like to stick a Kryo object in a ThreadLocal to speed things up a bit, we can end up trying to // serialise the Kryo object itself when suspending a fiber. That's dumb, useless AND can cause crashes, so diff --git a/core/src/test/kotlin/com/r3corda/core/crypto/Base58Test.kt b/core/src/test/kotlin/com/r3corda/core/crypto/Base58Test.kt index b11017a1ce..2800bbb32d 100644 --- a/core/src/test/kotlin/com/r3corda/core/crypto/Base58Test.kt +++ b/core/src/test/kotlin/com/r3corda/core/crypto/Base58Test.kt @@ -32,7 +32,7 @@ class Base58Test { @Test fun testDecode() { val testbytes = "Hello World".toByteArray() - val actualbytes = Base58.decode("JxF12TrwUP45BMd"); + val actualbytes = Base58.decode("JxF12TrwUP45BMd") assertTrue(String(actualbytes)) { Arrays.equals(testbytes, actualbytes) } assertTrue("1") { Arrays.equals(ByteArray(1), Base58.decode("1")) } diff --git a/core/src/test/kotlin/com/r3corda/core/utilities/NonEmptySetTest.kt b/core/src/test/kotlin/com/r3corda/core/utilities/NonEmptySetTest.kt index eb0567730a..292876e3ac 100644 --- a/core/src/test/kotlin/com/r3corda/core/utilities/NonEmptySetTest.kt +++ b/core/src/test/kotlin/com/r3corda/core/utilities/NonEmptySetTest.kt @@ -43,8 +43,8 @@ class NonEmptySetTest { .suppressing(CollectionAddAllTester::class.java.getMethod("testAddAll_nullCollectionReference")) // Disable tests that try to remove everything: .suppressing(CollectionRemoveAllTester::class.java.getMethod("testRemoveAll_nullCollectionReferenceNonEmptySubject")) - .suppressing(CollectionClearTester::class.java.getMethods().toList()) - .suppressing(CollectionRetainAllTester::class.java.getMethods().toList()) + .suppressing(CollectionClearTester::class.java.methods.toList()) + .suppressing(CollectionRetainAllTester::class.java.methods.toList()) .createTestSuite() } diff --git a/docs/build/html/_static/js/theme.js b/docs/build/html/_static/js/theme.js index 48a9f06b5b..176c0aded0 100644 --- a/docs/build/html/_static/js/theme.js +++ b/docs/build/html/_static/js/theme.js @@ -69,7 +69,7 @@ function ThemeNav () { }) .on('click', "[data-toggle='rst-current-version']", function() { $("[data-toggle='rst-versions']").toggleClass("shift-up"); - }) + }); // Make tables responsive $("table.docutils:not(.field-list)") @@ -139,12 +139,11 @@ function ThemeNav () { parent_li.siblings().find('li.current').removeClass('current'); parent_li.find('> ul li.current').removeClass('current'); parent_li.toggleClass('current'); - } + }; return nav; -}; - -module.exports.ThemeNav = ThemeNav(); +} + module.exports.ThemeNav = ThemeNav(); if (typeof(window) != 'undefined') { window.SphinxRtdTheme = { StickyNav: module.exports.ThemeNav }; diff --git a/docs/build/html/_static/searchtools.js b/docs/build/html/_static/searchtools.js index 066857ce21..5c54683650 100644 --- a/docs/build/html/_static/searchtools.js +++ b/docs/build/html/_static/searchtools.js @@ -191,7 +191,7 @@ var Stemmer = function() { w = firstch.toLowerCase() + w.substr(1); return w; } -} +}; @@ -564,7 +564,7 @@ var Search = { $u.each(_o, function(o) { var _files = o.files; if (_files === undefined) - return + return; if (_files.length === undefined) _files = [_files]; @@ -574,7 +574,7 @@ var Search = { for (j = 0; j < _files.length; j++) { file = _files[j]; if (!(file in scoreMap)) - scoreMap[file] = {} + scoreMap[file] = {}; scoreMap[file][word] = o.score; } }); diff --git a/node/src/main/kotlin/com/r3corda/node/utilities/ClockUtils.kt b/node/src/main/kotlin/com/r3corda/node/utilities/ClockUtils.kt index 695cf7a0a6..1b0790b4a2 100644 --- a/node/src/main/kotlin/com/r3corda/node/utilities/ClockUtils.kt +++ b/node/src/main/kotlin/com/r3corda/node/utilities/ClockUtils.kt @@ -49,7 +49,7 @@ abstract class MutableClock : Clock() { */ val mutations: Observable by lazy { Observable.create({ subscriber: Subscriber -> - if (!subscriber.isUnsubscribed()) { + if (!subscriber.isUnsubscribed) { mutationObservers.add(subscriber) // This is not very intuitive, but subscribing to a subscriber observes unsubscribes. subscriber.add(Subscriptions.create { mutationObservers.remove(subscriber) }) diff --git a/node/src/main/kotlin/com/r3corda/node/utilities/JsonSupport.kt b/node/src/main/kotlin/com/r3corda/node/utilities/JsonSupport.kt index 3c38165696..675429d5a5 100644 --- a/node/src/main/kotlin/com/r3corda/node/utilities/JsonSupport.kt +++ b/node/src/main/kotlin/com/r3corda/node/utilities/JsonSupport.kt @@ -29,7 +29,7 @@ object JsonSupport { fun createDefaultMapper(identities: IdentityService): ObjectMapper { val mapper = ServiceHubObjectMapper(identities) - mapper.enable(SerializationFeature.INDENT_OUTPUT); + mapper.enable(SerializationFeature.INDENT_OUTPUT) mapper.enable(DeserializationFeature.ACCEPT_SINGLE_VALUE_AS_ARRAY) mapper.enable(DeserializationFeature.USE_BIG_DECIMAL_FOR_FLOATS) diff --git a/node/src/test/kotlin/com/r3corda/node/visualiser/GraphStream.kt b/node/src/test/kotlin/com/r3corda/node/visualiser/GraphStream.kt index d05674ad2a..a53613afc0 100644 --- a/node/src/test/kotlin/com/r3corda/node/visualiser/GraphStream.kt +++ b/node/src/test/kotlin/com/r3corda/node/visualiser/GraphStream.kt @@ -32,7 +32,7 @@ var Node.styleClass: String get() = getAttribute("ui.class") fun createGraph(name: String, styles: String): SingleGraph { - System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer"); + System.setProperty("org.graphstream.ui.renderer", "org.graphstream.ui.j2dviewer.J2DGraphRenderer") return SingleGraph(name).apply { stylesheet = styles setAttribute("ui.quality") diff --git a/src/integration-test/kotlin/com/r3corda/core/testing/TraderDemoTest.kt b/src/integration-test/kotlin/com/r3corda/core/testing/TraderDemoTest.kt index 57d8d49ad2..cd8e15a2b0 100644 --- a/src/integration-test/kotlin/com/r3corda/core/testing/TraderDemoTest.kt +++ b/src/integration-test/kotlin/com/r3corda/core/testing/TraderDemoTest.kt @@ -51,7 +51,7 @@ class TraderDemoTest { "--base-directory", baseDirectory ) val proc = spawn("com.r3corda.demos.TraderDemoKt", args, "TradeDemoSeller") - assertExitOrKill(proc); + assertExitOrKill(proc) assertEquals(proc.exitValue(), 0) } diff --git a/src/integration-test/kotlin/com/r3corda/core/testing/utilities/JVMSpawner.kt b/src/integration-test/kotlin/com/r3corda/core/testing/utilities/JVMSpawner.kt index 2bd06445ca..438cd1ebf6 100644 --- a/src/integration-test/kotlin/com/r3corda/core/testing/utilities/JVMSpawner.kt +++ b/src/integration-test/kotlin/com/r3corda/core/testing/utilities/JVMSpawner.kt @@ -12,7 +12,7 @@ fun spawn(className: String, args: List, appName: String): Process { val builder = ProcessBuilder(javaArgs + args) builder.redirectError(Paths.get("error.$className.log").toFile()) builder.inheritIO() - val process = builder.start(); + val process = builder.start() return process } diff --git a/src/main/kotlin/com/r3corda/demos/utilities/HttpUtils.kt b/src/main/kotlin/com/r3corda/demos/utilities/HttpUtils.kt index 24d09b7b09..b1d60838e2 100644 --- a/src/main/kotlin/com/r3corda/demos/utilities/HttpUtils.kt +++ b/src/main/kotlin/com/r3corda/demos/utilities/HttpUtils.kt @@ -10,7 +10,7 @@ import java.util.concurrent.TimeUnit private val client by lazy { OkHttpClient.Builder() .connectTimeout(5, TimeUnit.SECONDS) - .readTimeout(60, TimeUnit.SECONDS).build(); + .readTimeout(60, TimeUnit.SECONDS).build() } fun putJson(url: URL, data: String) : Boolean { @@ -27,12 +27,12 @@ fun uploadFile(url: URL, file: String) : Boolean { val body = MultipartBody.Builder() .setType(MultipartBody.FORM) .addFormDataPart("rates", "example.rates.txt", RequestBody.create(MediaType.parse("text/plain"), file)) - .build(); + .build() return makeRequest(Request.Builder().url(url).post(body).build()) } private fun makeRequest(request: Request): Boolean { - val response = client.newCall(request).execute(); + val response = client.newCall(request).execute() if (!response.isSuccessful) { println("Could not fulfill HTTP request. Status Code: ${response.code()}. Message: ${response.body()}") From 2be91ff516d005bdab7c805942b7e941ae9d7eb1 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Mon, 11 Jul 2016 16:37:06 +0200 Subject: [PATCH 4/5] Minor: tighten variance when possible (via the Inspector) --- core/src/main/kotlin/com/r3corda/core/Utils.kt | 4 ++-- core/src/main/kotlin/com/r3corda/core/contracts/Structures.kt | 2 +- .../com/r3corda/core/contracts/clauses/GroupClauseVerifier.kt | 2 +- .../main/kotlin/com/r3corda/core/protocols/ProtocolLogic.kt | 2 +- .../src/main/kotlin/com/r3corda/core/utilities/NonEmptySet.kt | 2 +- .../main/kotlin/com/r3corda/core/utilities/RecordingMap.kt | 4 ++-- .../kotlin/com/r3corda/core/utilities/UntrustworthyData.kt | 2 +- .../main/kotlin/com/r3corda/protocols/FetchDataProtocol.kt | 4 ++-- .../main/kotlin/com/r3corda/protocols/TwoPartyDealProtocol.kt | 4 ++-- .../main/kotlin/protocols/AbstractStateReplacementProtocol.kt | 2 +- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/core/src/main/kotlin/com/r3corda/core/Utils.kt b/core/src/main/kotlin/com/r3corda/core/Utils.kt index 4598e15a2a..ba6edf8d29 100644 --- a/core/src/main/kotlin/com/r3corda/core/Utils.kt +++ b/core/src/main/kotlin/com/r3corda/core/Utils.kt @@ -142,7 +142,7 @@ inline fun logElapsedTime(label: String, logger: Logger? = null, body: () -> * * val ii = state.locked { i } */ -class ThreadBox(content: T, val lock: ReentrantLock = ReentrantLock()) { +class ThreadBox(content: T, val lock: ReentrantLock = ReentrantLock()) { val content = content inline fun locked(body: T.() -> R): R = lock.withLock { body(content) } inline fun alreadyLocked(body: T.() -> R): R { @@ -164,7 +164,7 @@ abstract class RetryableException(message: String) : Exception(message) * will not be serialized to disk, and if it's missing (or the first time it's accessed), the initializer will be * used to set it up. Note that the initializer will be called with the TransientProperty object locked. */ -class TransientProperty(private val initializer: () -> T) { +class TransientProperty(private val initializer: () -> T) { @Transient private var v: T? = null @Synchronized diff --git a/core/src/main/kotlin/com/r3corda/core/contracts/Structures.kt b/core/src/main/kotlin/com/r3corda/core/contracts/Structures.kt index 774f14487b..28b293512b 100644 --- a/core/src/main/kotlin/com/r3corda/core/contracts/Structures.kt +++ b/core/src/main/kotlin/com/r3corda/core/contracts/Structures.kt @@ -132,7 +132,7 @@ interface IssuanceDefinition * * @param P the type of product underlying the definition, for example [Currency]. */ -data class Issued

( +data class Issued( val issuer: PartyAndReference, val product: P ) diff --git a/core/src/main/kotlin/com/r3corda/core/contracts/clauses/GroupClauseVerifier.kt b/core/src/main/kotlin/com/r3corda/core/contracts/clauses/GroupClauseVerifier.kt index 38bcf37262..2cdaf61f2b 100644 --- a/core/src/main/kotlin/com/r3corda/core/contracts/clauses/GroupClauseVerifier.kt +++ b/core/src/main/kotlin/com/r3corda/core/contracts/clauses/GroupClauseVerifier.kt @@ -6,7 +6,7 @@ import com.r3corda.core.contracts.ContractState import com.r3corda.core.contracts.TransactionForContract import java.util.* -interface GroupVerify { +interface GroupVerify { /** * * @return the set of commands that are consumed IF this clause is matched, and cannot be used to match a diff --git a/core/src/main/kotlin/com/r3corda/core/protocols/ProtocolLogic.kt b/core/src/main/kotlin/com/r3corda/core/protocols/ProtocolLogic.kt index c07cf36d86..5a79a4f4ca 100644 --- a/core/src/main/kotlin/com/r3corda/core/protocols/ProtocolLogic.kt +++ b/core/src/main/kotlin/com/r3corda/core/protocols/ProtocolLogic.kt @@ -24,7 +24,7 @@ import org.slf4j.Logger * If you'd like to use another ProtocolLogic class as a component of your own, construct it on the fly and then pass * it to the [subProtocol] method. It will return the result of that protocol when it completes. */ -abstract class ProtocolLogic { +abstract class ProtocolLogic { /** Reference to the [Fiber] instance that is the top level controller for the entire flow. */ lateinit var psm: ProtocolStateMachine<*> diff --git a/core/src/main/kotlin/com/r3corda/core/utilities/NonEmptySet.kt b/core/src/main/kotlin/com/r3corda/core/utilities/NonEmptySet.kt index a12b5c49c7..1e961f7539 100644 --- a/core/src/main/kotlin/com/r3corda/core/utilities/NonEmptySet.kt +++ b/core/src/main/kotlin/com/r3corda/core/utilities/NonEmptySet.kt @@ -72,7 +72,7 @@ class NonEmptySet(initial: T) : MutableSet { override fun hashCode(): Int = set.hashCode() override fun toString(): String = set.toString() - inner class Iterator(val iterator: MutableIterator) : MutableIterator { + inner class Iterator(val iterator: MutableIterator) : MutableIterator { override fun hasNext(): Boolean = iterator.hasNext() override fun next(): T = iterator.next() override fun remove() = diff --git a/core/src/main/kotlin/com/r3corda/core/utilities/RecordingMap.kt b/core/src/main/kotlin/com/r3corda/core/utilities/RecordingMap.kt index 4688518656..35f5b2765c 100644 --- a/core/src/main/kotlin/com/r3corda/core/utilities/RecordingMap.kt +++ b/core/src/main/kotlin/com/r3corda/core/utilities/RecordingMap.kt @@ -16,8 +16,8 @@ class RecordingMap(private val wrappedMap: MutableMap, // If/when Kotlin supports data classes inside sealed classes, that would be preferable to this. interface Record - data class Get(val key: K) : Record - data class Put(val key: K, val value: V) : Record + data class Get(val key: K) : Record + data class Put(val key: K, val value: V) : Record private val _records = Collections.synchronizedList(ArrayList()) diff --git a/core/src/main/kotlin/com/r3corda/core/utilities/UntrustworthyData.kt b/core/src/main/kotlin/com/r3corda/core/utilities/UntrustworthyData.kt index 9b94d7722e..cb450b0ce6 100644 --- a/core/src/main/kotlin/com/r3corda/core/utilities/UntrustworthyData.kt +++ b/core/src/main/kotlin/com/r3corda/core/utilities/UntrustworthyData.kt @@ -11,7 +11,7 @@ package com.r3corda.core.utilities * - Are any objects *reachable* from this object mismatched or not what you expected? * - Is it suspiciously large or small? */ -class UntrustworthyData(private val fromUntrustedWorld: T) { +class UntrustworthyData(private val fromUntrustedWorld: T) { val data: T @Deprecated("Accessing the untrustworthy data directly without validating it first is a bad idea") get() = fromUntrustedWorld diff --git a/core/src/main/kotlin/com/r3corda/protocols/FetchDataProtocol.kt b/core/src/main/kotlin/com/r3corda/protocols/FetchDataProtocol.kt index 48197eb970..f2269ae491 100644 --- a/core/src/main/kotlin/com/r3corda/protocols/FetchDataProtocol.kt +++ b/core/src/main/kotlin/com/r3corda/protocols/FetchDataProtocol.kt @@ -27,7 +27,7 @@ import java.util.* * @param T The ultimate type of the data being fetched. * @param W The wire type of the data being fetched, for when it isn't the same as the ultimate type. */ -abstract class FetchDataProtocol( +abstract class FetchDataProtocol( protected val requests: Set, protected val otherSide: Party) : ProtocolLogic>() { @@ -36,7 +36,7 @@ abstract class FetchDataProtocol( class DownloadedVsRequestedDataMismatch(val requested: SecureHash, val got: SecureHash) : BadAnswer() data class Request(val hashes: List, override val replyToParty: Party, override val sessionID: Long) : PartyRequestMessage - data class Result(val fromDisk: List, val downloaded: List) + data class Result(val fromDisk: List, val downloaded: List) @Suspendable override fun call(): Result { diff --git a/core/src/main/kotlin/com/r3corda/protocols/TwoPartyDealProtocol.kt b/core/src/main/kotlin/com/r3corda/protocols/TwoPartyDealProtocol.kt index b81cefa4f7..3429807fed 100644 --- a/core/src/main/kotlin/com/r3corda/protocols/TwoPartyDealProtocol.kt +++ b/core/src/main/kotlin/com/r3corda/protocols/TwoPartyDealProtocol.kt @@ -44,7 +44,7 @@ object TwoPartyDealProtocol { } // This object is serialised to the network and is the first protocol message the seller sends to the buyer. - data class Handshake( + data class Handshake( val payload: T, val publicKey: PublicKey, val sessionID: Long @@ -58,7 +58,7 @@ object TwoPartyDealProtocol { * There's a good chance we can push at least some of this logic down into core protocol logic * and helper methods etc. */ - abstract class Primary(override val progressTracker: ProgressTracker = Primary.tracker()) : ProtocolLogic() { + abstract class Primary(override val progressTracker: ProgressTracker = Primary.tracker()) : ProtocolLogic() { companion object { object AWAITING_PROPOSAL : ProgressTracker.Step("Handshaking and awaiting transaction proposal") diff --git a/core/src/main/kotlin/protocols/AbstractStateReplacementProtocol.kt b/core/src/main/kotlin/protocols/AbstractStateReplacementProtocol.kt index 1ae3e98408..a2a52e2d80 100644 --- a/core/src/main/kotlin/protocols/AbstractStateReplacementProtocol.kt +++ b/core/src/main/kotlin/protocols/AbstractStateReplacementProtocol.kt @@ -28,7 +28,7 @@ import java.security.PublicKey * use the new updated state for future transactions. */ abstract class AbstractStateReplacementProtocol { - interface Proposal { + interface Proposal { val stateRef: StateRef val modification: T val stx: SignedTransaction From e28ecae8c0eba7895f3591f74c2faadfdd7643c6 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Mon, 11 Jul 2016 18:47:24 +0200 Subject: [PATCH 5/5] Address review comments --- .../kotlin/com/r3corda/contracts/CommercialPaper.kt | 11 +++++------ .../kotlin/com/r3corda/core/crypto/CryptoUtilities.kt | 2 +- .../kotlin/com/r3corda/protocols/FetchDataProtocol.kt | 2 -- .../kotlin/com/r3corda/protocols/RatesFixProtocol.kt | 1 - .../protocols/AbstractStateReplacementProtocol.kt | 2 -- .../src/main/kotlin/protocols/NotaryChangeProtocol.kt | 2 -- .../node/services/network/InMemoryMessagingNetwork.kt | 1 - .../r3corda/node/utilities/ANSIProgressRenderer.kt | 1 - 8 files changed, 6 insertions(+), 16 deletions(-) diff --git a/contracts/src/main/kotlin/com/r3corda/contracts/CommercialPaper.kt b/contracts/src/main/kotlin/com/r3corda/contracts/CommercialPaper.kt index d14689fd7f..139f7db55c 100644 --- a/contracts/src/main/kotlin/com/r3corda/contracts/CommercialPaper.kt +++ b/contracts/src/main/kotlin/com/r3corda/contracts/CommercialPaper.kt @@ -81,12 +81,11 @@ class CommercialPaper : Contract { val command = tx.commands.requireSingleCommand() // If it's an issue, we can't take notary from inputs, so it must be specified in the command val cmdVal = command.value - val timestamp: TimestampCommand? = if (cmdVal is Commands.Issue) - tx.getTimestampBy(cmdVal.notary) - else if (cmdVal is Commands.Redeem) - tx.getTimestampBy(cmdVal.notary) - else - null + val timestamp: TimestampCommand? = when (cmdVal) { + is Commands.Issue -> tx.getTimestampBy(cmdVal.notary) + is Commands.Redeem -> tx.getTimestampBy(cmdVal.notary) + else -> null + } for ((inputs, outputs, key) in groups) { when (command.value) { diff --git a/core/src/main/kotlin/com/r3corda/core/crypto/CryptoUtilities.kt b/core/src/main/kotlin/com/r3corda/core/crypto/CryptoUtilities.kt index fc6169e5a0..45b545153e 100644 --- a/core/src/main/kotlin/com/r3corda/core/crypto/CryptoUtilities.kt +++ b/core/src/main/kotlin/com/r3corda/core/crypto/CryptoUtilities.kt @@ -19,7 +19,7 @@ fun newSecureRandom(): SecureRandom { } // "sealed" here means there can't be any subclasses other than the ones defined here. -sealed class SecureHash constructor(bits: ByteArray) : OpaqueBytes(bits) { +sealed class SecureHash(bits: ByteArray) : OpaqueBytes(bits) { class SHA256(bits: ByteArray) : SecureHash(bits) { init { require(bits.size == 32) diff --git a/core/src/main/kotlin/com/r3corda/protocols/FetchDataProtocol.kt b/core/src/main/kotlin/com/r3corda/protocols/FetchDataProtocol.kt index f2269ae491..25d50ae6a9 100644 --- a/core/src/main/kotlin/com/r3corda/protocols/FetchDataProtocol.kt +++ b/core/src/main/kotlin/com/r3corda/protocols/FetchDataProtocol.kt @@ -7,8 +7,6 @@ import com.r3corda.core.crypto.SecureHash import com.r3corda.core.protocols.ProtocolLogic import com.r3corda.core.random63BitValue import com.r3corda.core.utilities.UntrustworthyData -import com.r3corda.protocols.FetchDataProtocol.DownloadedVsRequestedDataMismatch -import com.r3corda.protocols.FetchDataProtocol.HashNotFound import java.util.* /** diff --git a/core/src/main/kotlin/com/r3corda/protocols/RatesFixProtocol.kt b/core/src/main/kotlin/com/r3corda/protocols/RatesFixProtocol.kt index 048f1a8767..d61ad3d968 100644 --- a/core/src/main/kotlin/com/r3corda/protocols/RatesFixProtocol.kt +++ b/core/src/main/kotlin/com/r3corda/protocols/RatesFixProtocol.kt @@ -11,7 +11,6 @@ import com.r3corda.core.protocols.ProtocolLogic import com.r3corda.core.random63BitValue import com.r3corda.core.utilities.ProgressTracker import com.r3corda.core.utilities.suggestInterestRateAnnouncementTimeWindow -import com.r3corda.protocols.RatesFixProtocol.FixOutOfRange import java.math.BigDecimal import java.time.Duration import java.time.Instant diff --git a/core/src/main/kotlin/protocols/AbstractStateReplacementProtocol.kt b/core/src/main/kotlin/protocols/AbstractStateReplacementProtocol.kt index a2a52e2d80..02b9f9ae4d 100644 --- a/core/src/main/kotlin/protocols/AbstractStateReplacementProtocol.kt +++ b/core/src/main/kotlin/protocols/AbstractStateReplacementProtocol.kt @@ -13,8 +13,6 @@ import com.r3corda.core.utilities.ProgressTracker import com.r3corda.protocols.NotaryProtocol import com.r3corda.protocols.PartyRequestMessage import com.r3corda.protocols.ResolveTransactionsProtocol -import protocols.AbstractStateReplacementProtocol.Acceptor -import protocols.AbstractStateReplacementProtocol.Instigator import java.security.PublicKey /** diff --git a/core/src/main/kotlin/protocols/NotaryChangeProtocol.kt b/core/src/main/kotlin/protocols/NotaryChangeProtocol.kt index b0f6d13456..7ec371acc4 100644 --- a/core/src/main/kotlin/protocols/NotaryChangeProtocol.kt +++ b/core/src/main/kotlin/protocols/NotaryChangeProtocol.kt @@ -4,8 +4,6 @@ import co.paralleluniverse.fibers.Suspendable import com.r3corda.core.contracts.* import com.r3corda.core.crypto.Party import com.r3corda.core.utilities.ProgressTracker -import protocols.NotaryChangeProtocol.Acceptor -import protocols.NotaryChangeProtocol.Instigator import java.security.PublicKey /** diff --git a/node/src/main/kotlin/com/r3corda/node/services/network/InMemoryMessagingNetwork.kt b/node/src/main/kotlin/com/r3corda/node/services/network/InMemoryMessagingNetwork.kt index 864b898e6c..65f22209f9 100644 --- a/node/src/main/kotlin/com/r3corda/node/services/network/InMemoryMessagingNetwork.kt +++ b/node/src/main/kotlin/com/r3corda/node/services/network/InMemoryMessagingNetwork.kt @@ -10,7 +10,6 @@ import com.r3corda.core.messaging.* import com.r3corda.core.serialization.SingletonSerializeAsToken import com.r3corda.core.utilities.loggerFor import com.r3corda.core.utilities.trace -import com.r3corda.node.services.network.InMemoryMessagingNetwork.InMemoryMessaging import org.slf4j.LoggerFactory import rx.Observable import rx.subjects.PublishSubject diff --git a/node/src/main/kotlin/com/r3corda/node/utilities/ANSIProgressRenderer.kt b/node/src/main/kotlin/com/r3corda/node/utilities/ANSIProgressRenderer.kt index 0ee7077e75..e9bcf5bf99 100644 --- a/node/src/main/kotlin/com/r3corda/node/utilities/ANSIProgressRenderer.kt +++ b/node/src/main/kotlin/com/r3corda/node/utilities/ANSIProgressRenderer.kt @@ -3,7 +3,6 @@ package com.r3corda.node.utilities import com.r3corda.core.utilities.BriefLogFormatter import com.r3corda.core.utilities.Emoji import com.r3corda.core.utilities.ProgressTracker -import com.r3corda.node.utilities.ANSIProgressRenderer.progressTracker import org.fusesource.jansi.Ansi import org.fusesource.jansi.AnsiConsole import org.fusesource.jansi.AnsiOutputStream