From 5863d489bc614c945482a2450998ff7639c79bb7 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Tue, 15 Dec 2015 18:54:22 +0100 Subject: [PATCH] Minor: misc comment/whitespace fixes. --- src/main/kotlin/contracts/Cash.kt | 9 +++++---- src/main/kotlin/contracts/CommercialPaper.kt | 9 +++++++-- src/main/kotlin/core/ContractsDSL.kt | 1 - src/main/kotlin/core/Services.kt | 4 ++-- src/main/kotlin/core/Structures.kt | 12 ++++++------ 5 files changed, 20 insertions(+), 15 deletions(-) diff --git a/src/main/kotlin/contracts/Cash.kt b/src/main/kotlin/contracts/Cash.kt index 3779033614..a34aba3ca1 100644 --- a/src/main/kotlin/contracts/Cash.kt +++ b/src/main/kotlin/contracts/Cash.kt @@ -41,10 +41,11 @@ class Cash : Contract { * TODO: * 1) hash should be of the contents, not the URI * 2) allow the content to be specified at time of instance creation? - * Motivation: it's the difference between a state object referencing a programRef, which references a - * legalContractReference and a state object which directly references both. The latter allows the legal wording - * to evolve without requiring code changes. But creates a risk that users create objects governed by a program - * that is inconsistent with the legal contract + * + * Motivation: it's the difference between a state object referencing a programRef, which references a + * legalContractReference and a state object which directly references both. The latter allows the legal wording + * to evolve without requiring code changes. But creates a risk that users create objects governed by a program + * that is inconsistent with the legal contract */ override val legalContractReference: SecureHash = SecureHash.sha256("https://www.big-book-of-banking-law.gov/cash-claims.html"); diff --git a/src/main/kotlin/contracts/CommercialPaper.kt b/src/main/kotlin/contracts/CommercialPaper.kt index fd74e8b79e..b0addb8386 100644 --- a/src/main/kotlin/contracts/CommercialPaper.kt +++ b/src/main/kotlin/contracts/CommercialPaper.kt @@ -16,8 +16,8 @@ import java.time.Instant * This is an ultra-trivial implementation of commercial paper, which is essentially a simpler version of a corporate * bond. It can be seen as a company-specific currency. A company issues CP with a particular face value, say $100, * but sells it for less, say $90. The paper can be redeemed for cash at a given date in the future. Thus this example - * would have a 10% interest rate with a single repayment. Commercial paper is often rolled over (redeemed and the - * money used to immediately rebuy). + * would have a 10% interest rate with a single repayment. Commercial paper is often rolled over (the maturity date + * is adjusted as if the paper was redeemed and immediately repurchased, but without having to front the cash). * * This contract is not intended to realistically model CP. It is here only to act as a next step up above cash in * the prototyping phase. It is thus very incomplete. @@ -27,6 +27,11 @@ import java.time.Instant * of cash, or reuse some of the cash code? Waiting on response from Ayoub and Rajar about whether CP can always * be split/merged or only in secondary markets. Even if current systems can't do this, would it be a desirable * feature to have anyway? + * - The funding steps of CP is totally ignored in this model. + * - No attention is paid to the existing roles of custodians, funding banks, etc. + * - There are regional variations on the CP concept, for instance, American CP requires a special "CUSIP number" + * which may need to be tracked. That, in turn, requires validation logic (there is a bean validator that knows how + * to do this in the Apache BVal project). */ val CP_PROGRAM_ID = SecureHash.sha256("replace-me-later-with-bytecode-hash") diff --git a/src/main/kotlin/core/ContractsDSL.kt b/src/main/kotlin/core/ContractsDSL.kt index b6753d2a4a..1b077e44d5 100644 --- a/src/main/kotlin/core/ContractsDSL.kt +++ b/src/main/kotlin/core/ContractsDSL.kt @@ -99,7 +99,6 @@ data class Amount(val pennies: Long, val currency: Currency) : Comparable.sumOrNull() = if (!iterator().hasNext()) null else sumOrThrow() fun Iterable.sumOrThrow() = reduce { left, right -> left + right } fun Iterable.sumOrZero(currency: Currency) = if (iterator().hasNext()) sumOrThrow() else Amount(0, currency) diff --git a/src/main/kotlin/core/Services.kt b/src/main/kotlin/core/Services.kt index eee9ff96f3..4160565aba 100644 --- a/src/main/kotlin/core/Services.kt +++ b/src/main/kotlin/core/Services.kt @@ -23,7 +23,7 @@ import java.time.Instant * A wallet (name may be temporary) wraps a set of states that are useful for us to keep track of, for instance, * because we own them. This class represents an immutable, stable state of a wallet: it is guaranteed not to * change out from underneath you, even though the canonical currently-best-known wallet may change as we learn - * about new transactions from our peers and generate new transactiont that consume states ourselves. + * about new transactions from our peers and generate new transactions that consume states ourselves. */ data class Wallet(val states: List>) { @Suppress("UNCHECKED_CAST") @@ -101,5 +101,5 @@ interface ServiceHub { val identityService: IdentityService val timestampingService: TimestamperService val storageService: StorageService - val networkService: MessagingService // TODO: Rename class to be consistent. + val networkService: MessagingService } \ No newline at end of file diff --git a/src/main/kotlin/core/Structures.kt b/src/main/kotlin/core/Structures.kt index 4115350ee6..a6ddb4e2db 100644 --- a/src/main/kotlin/core/Structures.kt +++ b/src/main/kotlin/core/Structures.kt @@ -40,10 +40,10 @@ fun ContractState.hash(): SecureHash = SecureHash.sha256((serialize())) * A stateref is a pointer to a state, this is an equivalent of an "outpoint" in Bitcoin. It records which transaction * defined the state and where in that transaction it was. */ -data class ContractStateRef(val txhash: SecureHash, val index: Int) +data class ContractStateRef(val txhash: SecureHash, val index: Int) /** A StateAndRef is simply a (state, ref) pair. For instance, a wallet (which holds available assets) contains these. */ -data class StateAndRef(val state: T, val ref: ContractStateRef) +data class StateAndRef(val state: T, val ref: ContractStateRef) /** A [Party] is well known (name, pubkey) pair. In a real system this would probably be an X.509 certificate. */ data class Party(val name: String, val owningKey: PublicKey) { @@ -62,7 +62,7 @@ data class PartyReference(val party: Party, val reference: OpaqueBytes) { } /** Marker interface for classes that represent commands */ -interface Command +interface Command /** Commands that inherit from this are intended to have no data items: it's only their presence that matters. */ abstract class TypeOnlyCommand : Command { @@ -72,10 +72,10 @@ abstract class TypeOnlyCommand : Command { /** Wraps an object that was signed by a public key, which may be a well known/recognised institutional key. */ data class AuthenticatedObject( - val signers: List, - /** If any public keys were recognised, the looked up institutions are available here */ + val signers: List, + /** If any public keys were recognised, the looked up institutions are available here */ val signingParties: List, - val value: T + val value: T ) /**