mirror of
https://github.com/corda/corda.git
synced 2025-01-31 16:35:43 +00:00
commit
3325758113
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,3 @@
|
||||
TODO
|
||||
|
||||
# Eclipse, ctags, Mac metadata, log files
|
||||
.classpath
|
||||
.project
|
||||
|
@ -158,7 +158,7 @@ class CommercialPaper : Contract {
|
||||
* to redeem the paper. We must therefore send enough money to the key that owns the paper to satisfy the face
|
||||
* value, and then ensure the paper is removed from the ledger.
|
||||
*
|
||||
* @throws InsufficientBalanceException if the wallet doesn't contain enough money to pay the redeemer
|
||||
* @throws InsufficientBalanceException if the wallet doesn't contain enough money to pay the redeemer.
|
||||
*/
|
||||
@Throws(InsufficientBalanceException::class)
|
||||
fun generateRedeem(tx: TransactionBuilder, paper: StateAndRef<State>, wallet: List<StateAndRef<Cash.State>>) {
|
||||
|
@ -98,7 +98,7 @@ abstract class RatePaymentEvent(date: LocalDate,
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic class for the Fixed Rate Payments on the fixed leg - see [RatePaymentEvent]
|
||||
* Basic class for the Fixed Rate Payments on the fixed leg - see [RatePaymentEvent].
|
||||
* Assumes that the rate is valid.
|
||||
*/
|
||||
class FixedRatePaymentEvent(date: LocalDate,
|
||||
@ -121,7 +121,7 @@ class FixedRatePaymentEvent(date: LocalDate,
|
||||
}
|
||||
|
||||
/**
|
||||
* Basic class for the Floating Rate Payments on the floating leg - see [RatePaymentEvent]
|
||||
* Basic class for the Floating Rate Payments on the floating leg - see [RatePaymentEvent].
|
||||
* If the rate is null returns a zero payment. // TODO: Is this the desired behaviour?
|
||||
*/
|
||||
class FloatingRatePaymentEvent(date: LocalDate,
|
||||
@ -148,7 +148,7 @@ class FloatingRatePaymentEvent(date: LocalDate,
|
||||
override fun asCSV(): String = "$accrualStartDate,$accrualEndDate,$dayCountFactor,$days,$date,${notional.token},${notional},$fixingDate,$rate,$flow"
|
||||
|
||||
/**
|
||||
* Used for making immutables
|
||||
* Used for making immutables.
|
||||
*/
|
||||
fun withNewRate(newRate: Rate): FloatingRatePaymentEvent =
|
||||
FloatingRatePaymentEvent(date, accrualStartDate, accrualEndDate, dayCountBasisDay,
|
||||
@ -177,8 +177,8 @@ class FloatingRatePaymentEvent(date: LocalDate,
|
||||
|
||||
|
||||
/**
|
||||
* The Interest Rate Swap class. For a quick overview of what an IRS is, see here - http://www.pimco.co.uk/EN/Education/Pages/InterestRateSwapsBasics1-08.aspx (no endorsement)
|
||||
* This contract has 4 significant data classes within it, the "Common", "Calculation", "FixedLeg" and "FloatingLeg"
|
||||
* The Interest Rate Swap class. For a quick overview of what an IRS is, see here - http://www.pimco.co.uk/EN/Education/Pages/InterestRateSwapsBasics1-08.aspx (no endorsement).
|
||||
* This contract has 4 significant data classes within it, the "Common", "Calculation", "FixedLeg" and "FloatingLeg".
|
||||
* It also has 4 commands, "Agree", "Fix", "Pay" and "Mature".
|
||||
* Currently, we are not interested (excuse pun) in valuing the swap, calculating the PVs, DFs and all that good stuff (soon though).
|
||||
* This is just a representation of a vanilla Fixed vs Floating (same currency) IRS in the R3 prototype model.
|
||||
@ -212,7 +212,7 @@ class InterestRateSwap() : Contract {
|
||||
/**
|
||||
* The Calculation data class is "mutable" through out the life of the swap, as in, it's the only thing that contains
|
||||
* data that will changed from state to state (Recall that the design insists that everything is immutable, so we actually
|
||||
* copy / update for each transition)
|
||||
* copy / update for each transition).
|
||||
*/
|
||||
data class Calculation(
|
||||
val expression: Expression,
|
||||
@ -230,7 +230,7 @@ class InterestRateSwap() : Contract {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the fixing for that date
|
||||
* Returns the fixing for that date.
|
||||
*/
|
||||
fun getFixing(date: LocalDate): FloatingRatePaymentEvent =
|
||||
floatingLegPaymentSchedule.values.single { it.fixingDate == date }
|
||||
@ -587,7 +587,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(
|
||||
val fixedLeg: FixedLeg,
|
||||
@ -650,7 +650,7 @@ class InterestRateSwap() : Contract {
|
||||
}
|
||||
|
||||
/**
|
||||
* For evaluating arbitrary java on the platform
|
||||
* For evaluating arbitrary java on the platform.
|
||||
*/
|
||||
|
||||
fun evaluateCalculation(businessDate: LocalDate, expression: Expression = calculation.expression): Any {
|
||||
|
@ -43,7 +43,7 @@ open class PercentageRatioUnit(percentageAsString: String) : RatioUnit(BigDecima
|
||||
val String.percent: PercentageRatioUnit get() = PercentageRatioUnit(this)
|
||||
|
||||
/**
|
||||
* Parent of the Rate family. Used to denote fixed rates, floating rates, reference rates etc
|
||||
* Parent of the Rate family. Used to denote fixed rates, floating rates, reference rates etc.
|
||||
*/
|
||||
open class Rate(val ratioUnit: RatioUnit? = null) {
|
||||
override fun equals(other: Any?): Boolean {
|
||||
@ -82,7 +82,7 @@ class FixedRate(ratioUnit: RatioUnit) : Rate(ratioUnit) {
|
||||
}
|
||||
|
||||
/**
|
||||
* The parent class of the Floating rate classes
|
||||
* The parent class of the Floating rate classes.
|
||||
*/
|
||||
open class FloatingRate : Rate(null)
|
||||
|
||||
|
@ -37,7 +37,7 @@ class Cash : FungibleAsset<Currency>() {
|
||||
* 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
|
||||
* that is inconsistent with the legal contract.
|
||||
*/
|
||||
override val legalContractReference: SecureHash = SecureHash.sha256("https://www.big-book-of-banking-law.gov/cash-claims.html")
|
||||
|
||||
@ -258,4 +258,4 @@ val DUMMY_CASH_ISSUER by lazy { Party("Snake Oil Issuer", DUMMY_CASH_ISSUER_KEY.
|
||||
/** An extension property that lets you write 100.DOLLARS.CASH */
|
||||
val Amount<Currency>.CASH: Cash.State get() = Cash.State(Amount(quantity, Issued(DUMMY_CASH_ISSUER, token)), NullPublicKey)
|
||||
/** An extension property that lets you get a cash state from an issued token, under the [NullPublicKey] */
|
||||
val Amount<Issued<Currency>>.STATE: Cash.State get() = Cash.State(this, NullPublicKey)
|
||||
val Amount<Issued<Currency>>.STATE: Cash.State get() = Cash.State(this, NullPublicKey)
|
||||
|
@ -23,7 +23,7 @@ class InsufficientBalanceException(val amountMissing: Amount<Currency>) : Except
|
||||
* See [Cash] for an example subclass that implements currency.
|
||||
*
|
||||
* @param T a type that represents the asset in question. This should describe the basic type of the asset
|
||||
* (GBP, USD, oil, shares in company <X>, etc.) and any additional metadata (issuer, grade, class, etc.)
|
||||
* (GBP, USD, oil, shares in company <X>, etc.) and any additional metadata (issuer, grade, class, etc.).
|
||||
*/
|
||||
abstract class FungibleAsset<T> : Contract {
|
||||
/** A state representing a cash claim against some party */
|
||||
@ -139,4 +139,4 @@ fun <T> Iterable<ContractState>.sumFungible() = filterIsInstance<FungibleAsset.S
|
||||
fun <T> Iterable<ContractState>.sumFungibleOrNull() = filterIsInstance<FungibleAsset.State<T>>().map { it.amount }.sumOrNull()
|
||||
|
||||
/** Sums the asset states in the list, returning zero of the given token if there are none. */
|
||||
fun <T> Iterable<ContractState>.sumFungibleOrZero(token: Issued<T>) = filterIsInstance<FungibleAsset.State<T>>().map { it.amount }.sumOrZero(token)
|
||||
fun <T> Iterable<ContractState>.sumFungibleOrZero(token: Issued<T>) = filterIsInstance<FungibleAsset.State<T>>().map { it.amount }.sumOrZero(token)
|
||||
|
@ -39,7 +39,7 @@ class Obligation<P> : 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
|
||||
* that is inconsistent with the legal contract.
|
||||
*/
|
||||
override val legalContractReference: SecureHash = SecureHash.sha256("https://www.big-book-of-banking-law.example.gov/cash-settlement.html")
|
||||
|
||||
@ -224,7 +224,7 @@ class Obligation<P> : Contract {
|
||||
/**
|
||||
* A command stating that the obligor is settling some or all of the amount owed by transferring a suitable
|
||||
* state object to the beneficiary. If this reduces the balance to zero, the state object is destroyed.
|
||||
* @see [MoveCommand]
|
||||
* @see [MoveCommand].
|
||||
*/
|
||||
data class Settle<P>(override val aggregateState: IssuanceDefinition<P>,
|
||||
val amount: Amount<P>) : Commands, IssuanceCommands<P>
|
||||
|
@ -24,7 +24,7 @@ import java.util.*
|
||||
*
|
||||
* The service hub needs to provide at least a key management service and a storage service.
|
||||
*
|
||||
* @return a wallet object that represents the generated states (it will NOT be the full wallet from the service hub!)
|
||||
* @return a wallet object that represents the generated states (it will NOT be the full wallet from the service hub!).
|
||||
*/
|
||||
fun ServiceHub.fillWithSomeTestCash(howMuch: Amount<Currency>,
|
||||
notary: Party = DUMMY_NOTARY,
|
||||
@ -81,4 +81,4 @@ private fun calculateRandomlySizedAmounts(howMuch: Amount<Currency>, min: Int, m
|
||||
}
|
||||
check(amounts.sum() == howMuch.quantity)
|
||||
return amounts
|
||||
}
|
||||
}
|
||||
|
@ -240,7 +240,7 @@ class IRSTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility so I don't have to keep typing this
|
||||
* Utility so I don't have to keep typing this.
|
||||
*/
|
||||
fun singleIRS(irsSelector: Int = 1): InterestRateSwap.State {
|
||||
return generateIRSTxn(irsSelector).outputs.map { it.data }.filterIsInstance<InterestRateSwap.State>().single()
|
||||
@ -256,7 +256,7 @@ class IRSTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing a simple IRS, add a few fixings and then display as CSV
|
||||
* Testing a simple IRS, add a few fixings and then display as CSV.
|
||||
*/
|
||||
@Test
|
||||
fun `IRS Export test`() {
|
||||
@ -280,7 +280,7 @@ class IRSTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* Make sure it has a schedule and the schedule has some unfixed rates
|
||||
* Make sure it has a schedule and the schedule has some unfixed rates.
|
||||
*/
|
||||
@Test
|
||||
fun `next fixing date`() {
|
||||
@ -289,7 +289,7 @@ class IRSTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate through all the fix dates and add something
|
||||
* Iterate through all the fix dates and add something.
|
||||
*/
|
||||
@Test
|
||||
fun generateIRSandFixSome() {
|
||||
@ -472,7 +472,7 @@ class IRSTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* This will be modified once we adapt the IRS to be cross currency
|
||||
* This will be modified once we adapt the IRS to be cross currency.
|
||||
*/
|
||||
@Test
|
||||
fun `ensure same currency notionals`() {
|
||||
|
@ -105,7 +105,7 @@ fun List<AuthenticatedObject<CommandData>>.getTimestampByName(vararg names: Stri
|
||||
/**
|
||||
* Simple functionality for verifying a move command. Verifies that each input has a signature from its owning key.
|
||||
*
|
||||
* @param T the type of the move command
|
||||
* @param T the type of the move command.
|
||||
*/
|
||||
@Throws(IllegalArgumentException::class)
|
||||
// TODO: Can we have a common Move command for all contracts and avoid the reified type parameter here?
|
||||
@ -117,7 +117,7 @@ inline fun <reified T : MoveCommand> verifyMoveCommand(inputs: List<OwnableState
|
||||
/**
|
||||
* Simple functionality for verifying a move command. Verifies that each input has a signature from its owning key.
|
||||
*
|
||||
* @param T the type of the move command
|
||||
* @param T the type of the move command.
|
||||
*/
|
||||
@Throws(IllegalArgumentException::class)
|
||||
inline fun <reified T : MoveCommand> verifyMoveCommand(inputs: List<OwnableState>,
|
||||
|
@ -28,7 +28,7 @@ import java.util.*
|
||||
* TODO: It may make sense to replace this with convenience extensions over the JSR 354 MonetaryAmount interface,
|
||||
* in particular for use during calculations. This may also resolve...
|
||||
* TODO: Think about how positive-only vs positive-or-negative amounts can be represented in the type system.
|
||||
* TODO: Add either a scaling factor, or a variant for use in calculations
|
||||
* TODO: Add either a scaling factor, or a variant for use in calculations.
|
||||
*
|
||||
* @param T the type of the token, for example [Currency].
|
||||
*/
|
||||
@ -153,14 +153,14 @@ enum class AccrualAdjustment {
|
||||
|
||||
/**
|
||||
* This is utilised in the [DateRollConvention] class to determine which way we should initially step when
|
||||
* finding a business day
|
||||
* finding a business day.
|
||||
*/
|
||||
enum class DateRollDirection(val value: Long) { FORWARD(1), BACKWARD(-1) }
|
||||
|
||||
/**
|
||||
* This reflects what happens if a date on which a business event is supposed to happen actually falls upon a non-working day
|
||||
* Depending on the accounting requirement, we can move forward until we get to a business day, or backwards
|
||||
* There are some additional rules which are explained in the individual cases below
|
||||
* This reflects what happens if a date on which a business event is supposed to happen actually falls upon a non-working day.
|
||||
* Depending on the accounting requirement, we can move forward until we get to a business day, or backwards.
|
||||
* There are some additional rules which are explained in the individual cases below.
|
||||
*/
|
||||
enum class DateRollConvention {
|
||||
// direction() cannot be a val due to the throw in the Actual instance
|
||||
@ -419,4 +419,4 @@ enum class NetType {
|
||||
* can be a multilateral netting transaction, and may be created by a central clearing service.
|
||||
*/
|
||||
PAYMENT
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ data class TransactionState<out T : ContractState>(
|
||||
|
||||
/**
|
||||
* Copies the underlying state, replacing the notary field with the new value.
|
||||
* To replace the notary, we need an approval (signature) from _all_ participants of the [ContractState]
|
||||
* To replace the notary, we need an approval (signature) from _all_ participants of the [ContractState].
|
||||
*/
|
||||
fun withNotary(newNotary: Party) = TransactionState(this.data, newNotary)
|
||||
}
|
||||
@ -164,7 +164,7 @@ data class ScheduledStateRef(val ref: StateRef, override val scheduledAt: Instan
|
||||
|
||||
/**
|
||||
* This class represents the lifecycle activity that a contract state of type [LinearState] would like to perform at a given point in time.
|
||||
* e.g. run a fixing protocol
|
||||
* e.g. run a fixing protocol.
|
||||
*
|
||||
* Note the use of [ProtocolLogicRef] to represent a safe way to transport a [ProtocolLogic] out of the contract sandbox.
|
||||
*
|
||||
@ -176,9 +176,9 @@ data class ScheduledStateRef(val ref: StateRef, override val scheduledAt: Instan
|
||||
data class ScheduledActivity(val logicRef: ProtocolLogicRef, override val scheduledAt: Instant) : Scheduled
|
||||
|
||||
/**
|
||||
* A state that evolves by superseding itself, all of which share the common "thread"
|
||||
* A state that evolves by superseding itself, all of which share the common "thread".
|
||||
*
|
||||
* This simplifies the job of tracking the current version of certain types of state in e.g. a wallet
|
||||
* This simplifies the job of tracking the current version of certain types of state in e.g. a wallet.
|
||||
*/
|
||||
interface LinearState : ContractState {
|
||||
/** Unique thread id within the wallets of all parties */
|
||||
@ -196,7 +196,7 @@ interface SchedulableState : ContractState {
|
||||
*
|
||||
* The state has no reference to it's own StateRef, so supply that for use as input to any ProtocolLogic constructed.
|
||||
*
|
||||
* @return null if there is no activity to schedule
|
||||
* @return null if there is no activity to schedule.
|
||||
*/
|
||||
fun nextScheduledActivity(thisStateRef: StateRef, protocolLogicRefFactory: ProtocolLogicRefFactory): ScheduledActivity?
|
||||
}
|
||||
@ -217,18 +217,18 @@ interface DealState : LinearState {
|
||||
|
||||
/**
|
||||
* Generate a partial transaction representing an agreement (command) to this deal, allowing a general
|
||||
* deal/agreement protocol to generate the necessary transaction for potential implementations
|
||||
* deal/agreement protocol to generate the necessary transaction for potential implementations.
|
||||
*
|
||||
* TODO: Currently this is the "inception" transaction but in future an offer of some description might be an input state ref
|
||||
*
|
||||
* TODO: This should more likely be a method on the Contract (on a common interface) and the changes to reference a
|
||||
* Contract instance from a ContractState are imminent, at which point we can move this out of here
|
||||
* Contract instance from a ContractState are imminent, at which point we can move this out of here.
|
||||
*/
|
||||
fun generateAgreement(notary: Party): TransactionBuilder
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface adding fixing specific methods
|
||||
* Interface adding fixing specific methods.
|
||||
*/
|
||||
interface FixableDealState : DealState {
|
||||
/**
|
||||
@ -237,10 +237,10 @@ interface FixableDealState : DealState {
|
||||
fun nextFixingOf(): FixOf?
|
||||
|
||||
/**
|
||||
* Generate a fixing command for this deal and fix
|
||||
* Generate a fixing command for this deal and fix.
|
||||
*
|
||||
* TODO: This would also likely move to methods on the Contract once the changes to reference
|
||||
* the Contract from the ContractState are in
|
||||
* the Contract from the ContractState are in.
|
||||
*/
|
||||
fun generateFix(ptx: TransactionBuilder, oldState: StateAndRef<*>, fix: Fix)
|
||||
}
|
||||
@ -319,7 +319,7 @@ data class AuthenticatedObject<out T : Any>(
|
||||
|
||||
/**
|
||||
* If present in a transaction, contains a time that was verified by the timestamping authority/authorities whose
|
||||
* public keys are identified in the containing [Command] object. The true time must be between (after, before)
|
||||
* public keys are identified in the containing [Command] object. The true time must be between (after, before).
|
||||
*/
|
||||
// TODO: Timestamps are now always provided by the consensus service for the transaction, rather than potentially
|
||||
// having multiple timestamps on a transaction. As such, it likely makes more sense for time to be a field on the
|
||||
|
@ -32,7 +32,7 @@ open class TransactionBuilder(
|
||||
val time: TimestampCommand? get() = commands.mapNotNull { it.value as? TimestampCommand }.singleOrNull()
|
||||
|
||||
/**
|
||||
* Creates a copy of the builder
|
||||
* Creates a copy of the builder.
|
||||
*/
|
||||
fun copy(): TransactionBuilder =
|
||||
TransactionBuilder(
|
||||
@ -90,7 +90,7 @@ open class TransactionBuilder(
|
||||
* Checks that the given signature matches one of the commands and that it is a correct signature over the tx, then
|
||||
* adds it.
|
||||
*
|
||||
* @throws SignatureException if the signature didn't match the transaction contents
|
||||
* @throws SignatureException if the signature didn't match the transaction contents.
|
||||
* @throws IllegalArgumentException if the signature key doesn't appear in any command.
|
||||
*/
|
||||
fun checkAndAddSignature(sig: DigitalSignature.WithKey) {
|
||||
@ -101,7 +101,7 @@ open class TransactionBuilder(
|
||||
/**
|
||||
* Checks that the given signature matches one of the commands and that it is a correct signature over the tx.
|
||||
*
|
||||
* @throws SignatureException if the signature didn't match the transaction contents
|
||||
* @throws SignatureException if the signature didn't match the transaction contents.
|
||||
* @throws IllegalArgumentException if the signature key doesn't appear in any command.
|
||||
*/
|
||||
fun checkSignature(sig: DigitalSignature.WithKey) {
|
||||
|
@ -13,8 +13,8 @@ import java.util.concurrent.Callable
|
||||
*
|
||||
* In future, this should support restricting the search by time, and other types of useful query.
|
||||
*
|
||||
* @param transactions map of transaction id to [SignedTransaction]
|
||||
* @param startPoints transactions to use as starting points for the search
|
||||
* @param transactions map of transaction id to [SignedTransaction].
|
||||
* @param startPoints transactions to use as starting points for the search.
|
||||
*/
|
||||
class TransactionGraphSearch(val transactions: ReadOnlyTransactionStorage,
|
||||
val startPoints: List<WireTransaction>) : Callable<List<WireTransaction>> {
|
||||
|
@ -38,7 +38,7 @@ sealed class TransactionType {
|
||||
|
||||
/**
|
||||
* Return the list of public keys that that require signatures for the transaction type.
|
||||
* Note: the notary key is checked separately for all transactions and need not be included
|
||||
* Note: the notary key is checked separately for all transactions and need not be included.
|
||||
*/
|
||||
abstract fun getRequiredSigners(tx: TransactionForVerification): Set<PublicKey>
|
||||
|
||||
@ -52,7 +52,7 @@ sealed class TransactionType {
|
||||
|
||||
/**
|
||||
* Check the transaction is contract-valid by running the verify() for each input and output state contract.
|
||||
* If any contract fails to verify, the whole transaction is considered to be invalid
|
||||
* If any contract fails to verify, the whole transaction is considered to be invalid.
|
||||
*/
|
||||
override fun verifyTransaction(tx: TransactionForVerification) {
|
||||
// TODO: Check that notary is unchanged
|
||||
@ -92,7 +92,7 @@ sealed class TransactionType {
|
||||
|
||||
/**
|
||||
* Check that the difference between inputs and outputs is only the notary field,
|
||||
* and that all required signing public keys are present
|
||||
* and that all required signing public keys are present.
|
||||
*/
|
||||
override fun verifyTransaction(tx: TransactionForVerification) {
|
||||
try {
|
||||
@ -111,4 +111,4 @@ sealed class TransactionType {
|
||||
return participantKeys
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ data class TransactionForVerification(val inputs: List<TransactionState<Contract
|
||||
* TODO: Move this out of the core data structure definitions, once unit tests are more cleanly separated.
|
||||
*
|
||||
* @throws TransactionVerificationException if validation logic fails or if a contract throws an exception
|
||||
* (the original is in the cause field)
|
||||
* (the original is in the cause field).
|
||||
*/
|
||||
@Throws(TransactionVerificationException::class)
|
||||
fun verify() = type.verify(this)
|
||||
|
@ -142,7 +142,7 @@ data class SignedTransaction(val txBits: SerializedBytes<WireTransaction>,
|
||||
operator fun plus(sigList: Collection<DigitalSignature.WithKey>) = withAdditionalSignatures(sigList)
|
||||
|
||||
/**
|
||||
* Returns the set of missing signatures - a signature must be present for each signer public key
|
||||
* Returns the set of missing signatures - a signature must be present for each signer public key.
|
||||
*/
|
||||
fun getMissingSignatures(): Set<PublicKey> {
|
||||
val requiredKeys = tx.signers.toSet()
|
||||
@ -176,4 +176,4 @@ data class LedgerTransaction(
|
||||
) : NamedByHash {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
fun <T : ContractState> outRef(index: Int) = StateAndRef(outputs[index] as TransactionState<T>, StateRef(id, index))
|
||||
}
|
||||
}
|
||||
|
@ -77,8 +77,8 @@ open class DigitalSignature(bits: ByteArray, val covering: Int = 0) : OpaqueByte
|
||||
* A serialized piece of data and its signature. Enforces signature validity in order to deserialize the data
|
||||
* contained within.
|
||||
*
|
||||
* @param raw the raw serialized data
|
||||
* @param sig the (unverified) signature for the data
|
||||
* @param raw the raw serialized data.
|
||||
* @param sig the (unverified) signature for the data.
|
||||
*/
|
||||
open class SignedData<T : Any>(val raw: SerializedBytes<T>, val sig: DigitalSignature.WithKey) {
|
||||
/**
|
||||
|
@ -11,7 +11,7 @@ interface InterpolatorFactory {
|
||||
}
|
||||
|
||||
/**
|
||||
* Interpolates values between the given data points using straight lines
|
||||
* Interpolates values between the given data points using straight lines.
|
||||
*/
|
||||
class LinearInterpolator(private val xs: DoubleArray, private val ys: DoubleArray) : Interpolator {
|
||||
init {
|
||||
@ -105,8 +105,8 @@ class CubicSplineInterpolator(private val xs: DoubleArray, private val ys: Doubl
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a polynomial function of arbitrary degree
|
||||
* @param coefficients polynomial coefficients in the order of degree (constant first, followed by higher degree term coefficients)
|
||||
* Represents a polynomial function of arbitrary degree.
|
||||
* @param coefficients polynomial coefficients in the order of degree (constant first, followed by higher degree term coefficients).
|
||||
*/
|
||||
class Polynomial(private val coefficients: DoubleArray) {
|
||||
private val reversedCoefficients = coefficients.reversed()
|
||||
@ -118,7 +118,7 @@ class Polynomial(private val coefficients: DoubleArray) {
|
||||
* A *spline* is function piecewise-defined by polynomial functions.
|
||||
* Points at which polynomial pieces connect are known as *knots*.
|
||||
*
|
||||
* @param segmentMap a mapping between a knot and the polynomial that covers the subsequent interval
|
||||
* @param segmentMap a mapping between a knot and the polynomial that covers the subsequent interval.
|
||||
*/
|
||||
class SplineFunction(private val segmentMap: TreeMap<Double, Polynomial>) {
|
||||
fun getValue(x: Double): Double {
|
||||
|
@ -16,8 +16,8 @@ interface CordaPluginRegistry {
|
||||
* A Map with an entry for each consumed protocol used by the webAPIs.
|
||||
* The key of each map entry should contain the ProtocolLogic<T> class name.
|
||||
* The associated map values are the union of all concrete class names passed to the protocol constructor.
|
||||
* Standard java.lang.* and kotlin.* types do not need to be included explicitly
|
||||
* This is used to extend the white listed protocols that can be initiated from the ServiceHub invokeProtocolAsync method
|
||||
* Standard java.lang.* and kotlin.* types do not need to be included explicitly.
|
||||
* This is used to extend the white listed protocols that can be initiated from the ServiceHub invokeProtocolAsync method.
|
||||
*/
|
||||
val requiredProtocols: Map<String, Set<String>>
|
||||
}
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ interface ServiceHub {
|
||||
* Given a list of [SignedTransaction]s, writes them to the local storage for validated transactions and then
|
||||
* sends them to the wallet for further processing.
|
||||
*
|
||||
* @param txs The transactions to record
|
||||
* @param txs The transactions to record.
|
||||
*/
|
||||
fun recordTransactions(txs: Iterable<SignedTransaction>)
|
||||
|
||||
@ -50,14 +50,14 @@ interface ServiceHub {
|
||||
* Given some [SignedTransaction]s, writes them to the local storage for validated transactions and then
|
||||
* sends them to the wallet for further processing.
|
||||
*
|
||||
* @param txs The transactions to record
|
||||
* @param txs The transactions to record.
|
||||
*/
|
||||
fun recordTransactions(vararg txs: SignedTransaction) = recordTransactions(txs.toList())
|
||||
|
||||
/**
|
||||
* Given a [StateRef] loads the referenced transaction and looks up the specified output [ContractState]
|
||||
* Given a [StateRef] loads the referenced transaction and looks up the specified output [ContractState].
|
||||
*
|
||||
* @throws TransactionResolutionException if the [StateRef] points to a non-existent transaction
|
||||
* @throws TransactionResolutionException if the [StateRef] points to a non-existent transaction.
|
||||
*/
|
||||
fun loadState(stateRef: StateRef): TransactionState<*> {
|
||||
val definingTx = storageService.validatedTransactions.getTransaction(stateRef.txhash) ?: throw TransactionResolutionException(stateRef.txhash)
|
||||
@ -67,7 +67,7 @@ interface ServiceHub {
|
||||
/**
|
||||
* Will check [logicType] and [args] against a whitelist and if acceptable then construct and initiate the protocol.
|
||||
*
|
||||
* @throws IllegalProtocolLogicException or IllegalArgumentException if there are problems with the [logicType] or [args]
|
||||
* @throws IllegalProtocolLogicException or IllegalArgumentException if there are problems with the [logicType] or [args].
|
||||
*/
|
||||
fun <T : Any> invokeProtocolAsync(logicType: Class<out ProtocolLogic<T>>, vararg args: Any?): ListenableFuture<T>
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ interface AttachmentStorage {
|
||||
* to the raw byte stream is required.
|
||||
*
|
||||
* @throws FileAlreadyExistsException if the given byte stream has already been inserted.
|
||||
* @throws IllegalArgumentException if the given byte stream is empty or a [JarInputStream]
|
||||
* @throws IllegalArgumentException if the given byte stream is empty or a [JarInputStream].
|
||||
* @throws IOException if something went wrong.
|
||||
*/
|
||||
fun importAttachment(jar: InputStream): SecureHash
|
||||
|
@ -65,9 +65,9 @@ interface NetworkMapCache {
|
||||
* Add a network map service; fetches a copy of the latest map from the service and subscribes to any further
|
||||
* updates.
|
||||
*
|
||||
* @param net the network messaging service
|
||||
* @param net the network messaging service.
|
||||
* @param service the network map service to fetch current state from.
|
||||
* @param subscribe if the cache should subscribe to updates
|
||||
* @param subscribe if the cache should subscribe to updates.
|
||||
* @param ifChangedSinceVer an optional version number to limit updating the map based on. If the latest map
|
||||
* version is less than or equal to the given version, no update is fetched.
|
||||
*/
|
||||
@ -75,19 +75,19 @@ interface NetworkMapCache {
|
||||
subscribe: Boolean, ifChangedSinceVer: Int? = null): ListenableFuture<Unit>
|
||||
|
||||
/**
|
||||
* Adds a node to the local cache (generally only used for adding ourselves)
|
||||
* Adds a node to the local cache (generally only used for adding ourselves).
|
||||
*/
|
||||
fun addNode(node: NodeInfo)
|
||||
|
||||
/**
|
||||
* Removes a node from the local cache
|
||||
* Removes a node from the local cache.
|
||||
*/
|
||||
fun removeNode(node: NodeInfo)
|
||||
|
||||
/**
|
||||
* Deregister from updates from the given map service.
|
||||
*
|
||||
* @param net the network messaging service
|
||||
* @param net the network messaging service.
|
||||
* @param service the network map service to fetch current state from.
|
||||
*/
|
||||
fun deregisterForUpdates(net: MessagingService, service: NodeInfo): ListenableFuture<Unit>
|
||||
@ -96,4 +96,4 @@ interface NetworkMapCache {
|
||||
sealed class NetworkCacheError : Exception() {
|
||||
/** Indicates a failure to deregister, because of a rejected request from the remote node */
|
||||
class DeregistrationFailed : NetworkCacheError()
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ val TOPIC_DEFAULT_POSTFIX = ".0"
|
||||
*
|
||||
* [states] Holds the list of states that are *active* and *relevant*.
|
||||
* Active means they haven't been consumed yet (or we don't know about it).
|
||||
* Relevant means they contain at least one of our pubkeys
|
||||
* Relevant means they contain at least one of our pubkeys.
|
||||
*/
|
||||
class Wallet(val states: List<StateAndRef<ContractState>>) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
@ -80,7 +80,7 @@ interface WalletService {
|
||||
val currentWallet: Wallet
|
||||
|
||||
/**
|
||||
* Returns a snapshot of the heads of LinearStates
|
||||
* Returns a snapshot of the heads of LinearStates.
|
||||
*/
|
||||
val linearHeads: Map<SecureHash, StateAndRef<LinearState>>
|
||||
|
||||
@ -206,4 +206,4 @@ interface SchedulerService {
|
||||
|
||||
/** Unschedule all activity for a TX output, probably because it was consumed. */
|
||||
fun unscheduleStateActivity(ref: StateRef)
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ import java.time.Clock
|
||||
import java.time.Duration
|
||||
|
||||
/**
|
||||
* Checks if the given timestamp falls within the allowed tolerance interval
|
||||
* Checks if the given timestamp falls within the allowed tolerance interval.
|
||||
*/
|
||||
class TimestampChecker(val clock: Clock = Clock.systemUTC(),
|
||||
val tolerance: Duration = 30.seconds) {
|
||||
@ -23,4 +23,4 @@ class TimestampChecker(val clock: Clock = Clock.systemUTC(),
|
||||
if (after != null && now until after > tolerance) return false
|
||||
return true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import com.r3corda.core.crypto.SecureHash
|
||||
|
||||
/**
|
||||
* A service that records input states of the given transaction and provides conflict information
|
||||
* if any of the inputs have already been used in another transaction
|
||||
* if any of the inputs have already been used in another transaction.
|
||||
*/
|
||||
interface UniquenessProvider {
|
||||
/** Commits all input states of the given transaction */
|
||||
@ -17,7 +17,7 @@ interface UniquenessProvider {
|
||||
|
||||
/**
|
||||
* Specifies the transaction id, the position of the consumed state in the inputs, and
|
||||
* the caller identity requesting the commit
|
||||
* the caller identity requesting the commit.
|
||||
*
|
||||
* TODO: need to do more design work to prevent privacy problems: knowing the id of a
|
||||
* transaction, by the rules of our system the party can obtain it and see its contents.
|
||||
@ -27,4 +27,4 @@ interface UniquenessProvider {
|
||||
data class ConsumingTx(val id: SecureHash, val inputIndex: Int, val requestingParty: Party)
|
||||
}
|
||||
|
||||
class UniquenessException(val error: UniquenessProvider.Conflict) : Exception()
|
||||
class UniquenessException(val error: UniquenessProvider.Conflict) : Exception()
|
||||
|
@ -15,7 +15,7 @@ import kotlin.reflect.jvm.javaType
|
||||
import kotlin.reflect.primaryConstructor
|
||||
|
||||
/**
|
||||
* A class for conversion to and from [ProtocolLogic] and [ProtocolLogicRef] instances
|
||||
* A class for conversion to and from [ProtocolLogic] and [ProtocolLogicRef] instances.
|
||||
*
|
||||
* Validation of types is performed on the way in and way out in case this object is passed between JVMs which might have differing
|
||||
* whitelists.
|
||||
@ -151,9 +151,9 @@ class ProtocolLogicRefFactory(private val protocolWhitelist: Map<String, Set<Str
|
||||
class IllegalProtocolLogicException(type: Class<*>, msg: String) : IllegalArgumentException("${ProtocolLogicRef::class.java.simpleName} cannot be constructed for ${ProtocolLogic::class.java.simpleName} of type ${type.name} $msg")
|
||||
|
||||
/**
|
||||
* A class representing a [ProtocolLogic] instance which would be possible to safely pass out of the contract sandbox
|
||||
* A class representing a [ProtocolLogic] instance which would be possible to safely pass out of the contract sandbox.
|
||||
*
|
||||
* Only allows a String reference to the ProtocolLogic class, and only allows restricted argument types as per [ProtocolLogicRefFactory]
|
||||
* Only allows a String reference to the ProtocolLogic class, and only allows restricted argument types as per [ProtocolLogicRefFactory].
|
||||
*/
|
||||
// TODO: align this with the existing [ProtocolRef] in the bank-side API (probably replace some of the API classes)
|
||||
data class ProtocolLogicRef internal constructor(val protocolLogicClassName: String, val appContext: AppContext, val args: Map<String, Any?>)
|
||||
@ -166,4 +166,4 @@ data class AppContext(val attachments: List<SecureHash>) {
|
||||
// TODO: build a real [AttachmentsClassLoader] etc
|
||||
val classLoader: ClassLoader
|
||||
get() = this.javaClass.classLoader
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import org.slf4j.Logger
|
||||
|
||||
|
||||
/**
|
||||
* The interface of [ProtocolStateMachineImpl] exposing methods and properties required by ProtocolLogic for compilation
|
||||
* The interface of [ProtocolStateMachineImpl] exposing methods and properties required by ProtocolLogic for compilation.
|
||||
*/
|
||||
interface ProtocolStateMachine<R> {
|
||||
@Suspendable
|
||||
|
@ -113,7 +113,7 @@ object SerializedBytesSerializer : Serializer<SerializedBytes<Any>>() {
|
||||
|
||||
/**
|
||||
* Can be called on any object to convert it to a byte array (wrapped by [SerializedBytes]), regardless of whether
|
||||
* the type is marked as serializable or was designed for it (so be careful!)
|
||||
* the type is marked as serializable or was designed for it (so be careful!).
|
||||
*/
|
||||
fun <T : Any> T.serialize(kryo: Kryo = THREAD_LOCAL_KRYO.get()): SerializedBytes<T> {
|
||||
val stream = ByteArrayOutputStream()
|
||||
|
@ -27,7 +27,7 @@ interface SerializeAsToken {
|
||||
}
|
||||
|
||||
/**
|
||||
* This represents a token in the serialized stream for an instance of a type that implements [SerializeAsToken]
|
||||
* This represents a token in the serialized stream for an instance of a type that implements [SerializeAsToken].
|
||||
*/
|
||||
interface SerializationToken {
|
||||
fun fromToken(context: SerializeAsTokenContext): Any
|
||||
@ -130,4 +130,4 @@ abstract class SingletonSerializeAsToken() : SerializeAsToken {
|
||||
private val token = SingletonSerializationToken(this)
|
||||
|
||||
override fun toToken(context: SerializeAsTokenContext) = SingletonSerializationToken.registerWithContext(token, this, context)
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ open class InMemoryWalletService(private val services: ServiceHub) : SingletonSe
|
||||
get() = _updatesPublisher
|
||||
|
||||
/**
|
||||
* Returns a snapshot of the heads of LinearStates
|
||||
* Returns a snapshot of the heads of LinearStates.
|
||||
*/
|
||||
override val linearHeads: Map<SecureHash, StateAndRef<LinearState>>
|
||||
get() = currentWallet.let { wallet ->
|
||||
|
@ -12,14 +12,14 @@ interface OutputStateLookup {
|
||||
/**
|
||||
* Retrieves an output previously defined by [TransactionDSLInterpreter._output] with a label passed in.
|
||||
* @param clazz The class object holding the type of the output state expected.
|
||||
* @param label The label of the to-be-retrieved output state
|
||||
* @return The output [StateAndRef]
|
||||
* @param label The label of the to-be-retrieved output state.
|
||||
* @return The output [StateAndRef].
|
||||
*/
|
||||
fun <S : ContractState> retrieveOutputStateAndRef(clazz: Class<S>, label: String): StateAndRef<S>
|
||||
}
|
||||
|
||||
/**
|
||||
* This interface asserts that the DSL at hand is capable of verifying its underlying construct(ledger/transaction)
|
||||
* This interface asserts that the DSL at hand is capable of verifying its underlying construct(ledger/transaction).
|
||||
*/
|
||||
interface Verifies {
|
||||
/**
|
||||
@ -28,7 +28,7 @@ interface Verifies {
|
||||
fun verifies(): EnforceVerifyOrFail
|
||||
|
||||
/**
|
||||
* Asserts that verifies() throws
|
||||
* Asserts that verifies() throws.
|
||||
* @param expectedMessage An optional string to be searched for in the raised exception.
|
||||
*/
|
||||
fun failsWith(expectedMessage: String?): EnforceVerifyOrFail {
|
||||
@ -59,7 +59,7 @@ interface Verifies {
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts that [verifies] throws, with no condition on the exception message
|
||||
* Asserts that [verifies] throws, with no condition on the exception message.
|
||||
*/
|
||||
fun fails() = failsWith(null)
|
||||
|
||||
|
@ -68,7 +68,7 @@ fun LedgerDSLInterpreter<TransactionDSLInterpreter>.ledger(
|
||||
}
|
||||
|
||||
/**
|
||||
* If you jumped here from a compiler error make sure the last line of your test tests for a transaction verify or fail
|
||||
* If you jumped here from a compiler error make sure the last line of your test tests for a transaction verify or fail.
|
||||
* This is a dummy type that can only be instantiated by functions in this module. This way we can ensure that all tests
|
||||
* will have as the last line either an accept or a failure test. The name is deliberately long to help make sense of
|
||||
* the triggered diagnostic.
|
||||
|
@ -35,7 +35,7 @@ interface TransactionDSLInterpreter : Verifies, OutputStateLookup {
|
||||
|
||||
/**
|
||||
* Adds an [Attachment] reference to the transaction.
|
||||
* @param attachmentId The hash of the attachment, possibly returned by [LedgerDSLInterpreter.attachment]
|
||||
* @param attachmentId The hash of the attachment, possibly returned by [LedgerDSLInterpreter.attachment].
|
||||
*/
|
||||
fun attachment(attachmentId: SecureHash)
|
||||
|
||||
|
@ -27,10 +27,10 @@ object NotaryProtocol {
|
||||
|
||||
/**
|
||||
* A protocol to be used for obtaining a signature from a [NotaryService] ascertaining the transaction
|
||||
* timestamp is correct and none of its inputs have been used in another completed transaction
|
||||
* timestamp is correct and none of its inputs have been used in another completed transaction.
|
||||
*
|
||||
* @throws NotaryException in case the any of the inputs to the transaction have been consumed
|
||||
* by another transaction or the timestamp is invalid
|
||||
* by another transaction or the timestamp is invalid.
|
||||
*/
|
||||
class Client(private val stx: SignedTransaction,
|
||||
override val progressTracker: ProgressTracker = Client.tracker()) : ProtocolLogic<DigitalSignature.LegallyIdentifiable>() {
|
||||
@ -157,7 +157,7 @@ object NotaryProtocol {
|
||||
* history chain.
|
||||
* As a result, the Notary _will commit invalid transactions_ as well, but as it also records the identity of
|
||||
* the caller, it is possible to raise a dispute and verify the validity of the transaction and subsequently
|
||||
* undo the commit of the input states (the exact mechanism still needs to be worked out)
|
||||
* undo the commit of the input states (the exact mechanism still needs to be worked out).
|
||||
*/
|
||||
@Suspendable
|
||||
open fun beforeCommit(stx: SignedTransaction, reqIdentity: Party) {
|
||||
@ -234,4 +234,4 @@ sealed class NotaryError {
|
||||
class TransactionInvalid : NotaryError()
|
||||
|
||||
class SignaturesMissing(val missingSigners: List<PublicKey>) : NotaryError()
|
||||
}
|
||||
}
|
||||
|
@ -400,7 +400,7 @@ object TwoPartyDealProtocol {
|
||||
}
|
||||
|
||||
/**
|
||||
* One side of the fixing protocol for an interest rate swap, but could easily be generalised furher
|
||||
* One side of the fixing protocol for an interest rate swap, but could easily be generalised furher.
|
||||
*
|
||||
* As per the [Fixer], do not infer too much from this class name in terms of business roles. This
|
||||
* is just the "side" of the protocol run by the party with the floating leg as a way of deciding who
|
||||
@ -477,4 +477,4 @@ object TwoPartyDealProtocol {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ import java.security.SignatureException
|
||||
* A notary commit protocol that makes sure a given transaction is valid before committing it. This does mean that the calling
|
||||
* party has to reveal the whole transaction history; however, we avoid complex conflict resolution logic where a party
|
||||
* has its input states "blocked" by a transaction from another party, and needs to establish whether that transaction was
|
||||
* indeed valid
|
||||
* indeed valid.
|
||||
*/
|
||||
class ValidatingNotaryProtocol(otherSide: Party,
|
||||
sessionIdForSend: Long,
|
||||
@ -53,4 +53,4 @@ class ValidatingNotaryProtocol(otherSide: Party,
|
||||
private fun validateDependencies(reqIdentity: Party, wtx: WireTransaction) {
|
||||
subProtocol(ResolveTransactionsProtocol(wtx, reqIdentity))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ import kotlin.test.assertTrue
|
||||
import kotlin.test.fail
|
||||
|
||||
/**
|
||||
* Modified from the bitcoinj library
|
||||
* Modified from the bitcoinj library.
|
||||
*/
|
||||
class Base58Test {
|
||||
@Test
|
||||
|
@ -32,7 +32,7 @@ interface APIServer {
|
||||
fun serverTime(): LocalDateTime
|
||||
|
||||
/**
|
||||
* Report whether this node is started up or not
|
||||
* Report whether this node is started up or not.
|
||||
*/
|
||||
@GET
|
||||
@Path("status")
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.r3corda.node.api
|
||||
|
||||
/**
|
||||
* Extremely rudimentary query language which should most likely be replaced with a product
|
||||
* Extremely rudimentary query language which should most likely be replaced with a product.
|
||||
*/
|
||||
interface StatesQuery {
|
||||
companion object {
|
||||
|
@ -71,7 +71,7 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
|
||||
|
||||
// TODO: Persist this, as well as whether the node is registered.
|
||||
/**
|
||||
* Sequence number of changes sent to the network map service, when registering/de-registering this node
|
||||
* Sequence number of changes sent to the network map service, when registering/de-registering this node.
|
||||
*/
|
||||
var networkMapSeq: Long = 1
|
||||
|
||||
@ -202,7 +202,7 @@ abstract class AbstractNode(val dir: Path, val configuration: NodeConfiguration,
|
||||
|
||||
|
||||
/**
|
||||
* Run any tasks that are needed to ensure the node is in a correct state before running start()
|
||||
* Run any tasks that are needed to ensure the node is in a correct state before running start().
|
||||
*/
|
||||
open fun setup(): AbstractNode {
|
||||
createNodeDir()
|
||||
|
@ -42,15 +42,15 @@ class ConfigurationException(message: String) : Exception(message)
|
||||
* @param dir A [Path] to a location on disk where working files can be found or stored.
|
||||
* @param p2pAddr The host and port that this server will use. It can't find out its own external hostname, so you
|
||||
* have to specify that yourself.
|
||||
* @param configuration This is typically loaded from a .properties file
|
||||
* @param configuration This is typically loaded from a .properties file.
|
||||
* @param networkMapAddress An external network map service to use. Should only ever be null when creating the first
|
||||
* network map service, while bootstrapping a network.
|
||||
* @param advertisedServices The services this node advertises. This must be a subset of the services it runs,
|
||||
* but nodes are not required to advertise services they run (hence subset).
|
||||
* @param clientAPIs A list of JAX-RS annotated classes to register
|
||||
* which will be used to register any extra client web interfaces the node requires for demos to use.
|
||||
* Listed clientAPI classes are assumed to have to take a single APIServer constructor parameter
|
||||
* @param clock The clock used within the node and by all protocols etc
|
||||
* Listed clientAPI classes are assumed to have to take a single APIServer constructor parameter.
|
||||
* @param clock The clock used within the node and by all protocols etc.
|
||||
*/
|
||||
class Node(dir: Path, val p2pAddr: HostAndPort, val webServerAddr: HostAndPort, configuration: NodeConfiguration,
|
||||
networkMapAddress: NodeInfo?, advertisedServices: Set<ServiceType>,
|
||||
|
@ -12,7 +12,7 @@ import javax.annotation.concurrent.ThreadSafe
|
||||
|
||||
|
||||
/**
|
||||
* A [Clock] that can have the time advanced for use in testing
|
||||
* A [Clock] that can have the time advanced for use in testing.
|
||||
*/
|
||||
@ThreadSafe
|
||||
class TestClock(private var delegateClock: Clock = Clock.systemUTC()) : MutableClock(), SerializeAsToken {
|
||||
|
@ -19,9 +19,9 @@ abstract class AbstractNodeService(val net: MessagingService, val networkMapCach
|
||||
/**
|
||||
* Register a handler for a message topic. In comparison to using net.addMessageHandler() this manages a lot of
|
||||
* common boilerplate code. Exceptions are caught and passed to the provided consumer. If you just want a simple
|
||||
* acknowledgement response with no content, use [com.r3corda.core.messaging.Ack]
|
||||
* acknowledgement response with no content, use [com.r3corda.core.messaging.Ack].
|
||||
*
|
||||
* @param topic the topic, without the default session ID postfix (".0)
|
||||
* @param topic the topic, without the default session ID postfix (".0).
|
||||
* @param handler a function to handle the deserialised request and return an optional response (if return type not Unit)
|
||||
* @param exceptionConsumer a function to which any thrown exception is passed.
|
||||
*/
|
||||
@ -47,10 +47,10 @@ abstract class AbstractNodeService(val net: MessagingService, val networkMapCach
|
||||
/**
|
||||
* Register a handler for a message topic. In comparison to using net.addMessageHandler() this manages a lot of
|
||||
* common boilerplate code. Exceptions are propagated to the messaging layer. If you just want a simple
|
||||
* acknowledgement response with no content, use [com.r3corda.core.messaging.Ack]
|
||||
* acknowledgement response with no content, use [com.r3corda.core.messaging.Ack].
|
||||
*
|
||||
* @param topic the topic, without the default session ID postfix (".0)
|
||||
* @param handler a function to handle the deserialised request and return an optional response (if return type not Unit)
|
||||
* @param topic the topic, without the default session ID postfix (".0).
|
||||
* @param handler a function to handle the deserialised request and return an optional response (if return type not Unit).
|
||||
*/
|
||||
protected inline fun <reified Q : ServiceRequestMessage, reified R : Any>
|
||||
addMessageHandler(topic: String,
|
||||
|
@ -16,7 +16,7 @@ abstract class ServiceHubInternal : ServiceHub {
|
||||
* sends them to the wallet for further processing. This is intended for implementations to call from
|
||||
* [recordTransactions].
|
||||
*
|
||||
* @param txs The transactions to record
|
||||
* @param txs The transactions to record.
|
||||
*/
|
||||
internal fun recordTransactionsInternal(writableStorageService: TxWritableStorageService, txs: Iterable<SignedTransaction>) {
|
||||
txs.forEach { writableStorageService.validatedTransactions.addTransaction(it) }
|
||||
@ -26,7 +26,7 @@ abstract class ServiceHubInternal : ServiceHub {
|
||||
/**
|
||||
* TODO: borrowing this method from service manager work in another branch. It's required to avoid circular dependency
|
||||
* between SMM and the scheduler. That particular problem should also be resolved by the service manager work
|
||||
* itself, at which point this method would not be needed (by the scheduler)
|
||||
* itself, at which point this method would not be needed (by the scheduler).
|
||||
*/
|
||||
abstract fun <T> startProtocol(loggerName: String, logic: ProtocolLogic<T>): ListenableFuture<T>
|
||||
|
||||
@ -36,4 +36,4 @@ abstract class ServiceHubInternal : ServiceHub {
|
||||
val logic = protocolLogicRefFactory.toProtocolLogic(logicRef) as ProtocolLogic<T>
|
||||
return startProtocol(logicType.simpleName, logic)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +97,7 @@ object NodeInterestRates {
|
||||
}
|
||||
|
||||
/**
|
||||
* Register the protocol that is used with the Fixing integration tests
|
||||
* Register the protocol that is used with the Fixing integration tests.
|
||||
*/
|
||||
class FixingServicePlugin : CordaPluginRegistry {
|
||||
override val webApis: List<Class<*>> = emptyList()
|
||||
@ -252,7 +252,7 @@ object NodeInterestRates {
|
||||
|
||||
/**
|
||||
* Returns the interest rate for a given [Tenor],
|
||||
* or _null_ if the rate is not found and cannot be interpolated
|
||||
* or _null_ if the rate is not found and cannot be interpolated.
|
||||
*/
|
||||
fun getRate(tenor: Tenor): BigDecimal? {
|
||||
return rates.getOrElse(tenor) {
|
||||
@ -297,4 +297,4 @@ object NodeInterestRates {
|
||||
val name = words.dropLast(2).joinToString(" ")
|
||||
return FixOf(name, LocalDate.parse(date), Tenor(tenorString))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,9 +17,9 @@ import javax.annotation.concurrent.ThreadSafe
|
||||
* on a separate/firewalled service.
|
||||
* - Use the protocol framework so requests to fetch keys can be suspended whilst a human signs off on the request.
|
||||
* - Use deterministic key derivation.
|
||||
* - Possibly have some sort of TREZOR-like two-factor authentication ability
|
||||
* - Possibly have some sort of TREZOR-like two-factor authentication ability.
|
||||
*
|
||||
* etc
|
||||
* etc.
|
||||
*/
|
||||
@ThreadSafe
|
||||
class E2ETestKeyManagementService(initialKeys: Set<KeyPair>) : SingletonSerializeAsToken(), KeyManagementService {
|
||||
@ -47,4 +47,4 @@ class E2ETestKeyManagementService(initialKeys: Set<KeyPair>) : SingletonSerializ
|
||||
}
|
||||
return keypair
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -85,9 +85,9 @@ class InMemoryMessagingNetwork(val sendManuallyPumped: Boolean) : SingletonSeria
|
||||
/**
|
||||
* Creates a node at the given address: useful if you want to recreate a node to simulate a restart.
|
||||
*
|
||||
* @param manuallyPumped see [createNode]
|
||||
* @param manuallyPumped see [createNode].
|
||||
* @param id the numeric ID to use, e.g. set to whatever ID the node used last time.
|
||||
* @param description text string that identifies this node for message logging (if is enabled) or null to autogenerate
|
||||
* @param description text string that identifies this node for message logging (if is enabled) or null to autogenerate.
|
||||
*/
|
||||
fun createNodeWithID(manuallyPumped: Boolean, id: Int, description: String? = null): MessagingServiceBuilder<InMemoryMessaging> {
|
||||
return Builder(manuallyPumped, Handle(id, description ?: "In memory node $id"))
|
||||
|
@ -12,12 +12,12 @@ import com.r3corda.protocols.NotaryProtocol
|
||||
|
||||
/**
|
||||
* A Notary service acts as the final signer of a transaction ensuring two things:
|
||||
* - The (optional) timestamp of the transaction is valid
|
||||
* - The (optional) timestamp of the transaction is valid.
|
||||
* - None of the referenced input states have previously been consumed by a transaction signed by this Notary
|
||||
*
|
||||
* A transaction has to be signed by a Notary to be considered valid (except for output-only transactions without a timestamp).
|
||||
*
|
||||
* This is the base implementation that can be customised with specific Notary transaction commit protocol
|
||||
* This is the base implementation that can be customised with specific Notary transaction commit protocol.
|
||||
*/
|
||||
abstract class NotaryService(val smm: StateMachineManager,
|
||||
net: MessagingService,
|
||||
|
@ -8,10 +8,10 @@ import javax.ws.rs.ext.Provider
|
||||
|
||||
/**
|
||||
* Primary purpose is to install Kotlin extensions for Jackson ObjectMapper so data classes work
|
||||
* and to organise serializers / deserializers for java.time.* classes as necessary
|
||||
* and to organise serializers / deserializers for java.time.* classes as necessary.
|
||||
*/
|
||||
@Provider
|
||||
class Config(val services: ServiceHub) : ContextResolver<ObjectMapper> {
|
||||
val defaultObjectMapper = JsonSupport.createDefaultMapper(services.identityService)
|
||||
override fun getContext(type: Class<*>) = defaultObjectMapper
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import javax.ws.rs.container.ContainerResponseFilter
|
||||
import javax.ws.rs.ext.Provider
|
||||
|
||||
/**
|
||||
* This adds headers needed for cross site scripting on API clients
|
||||
* This adds headers needed for cross site scripting on API clients.
|
||||
*/
|
||||
@Provider
|
||||
class ResponseFilter : ContainerResponseFilter {
|
||||
@ -18,7 +18,7 @@ class ResponseFilter : ContainerResponseFilter {
|
||||
*
|
||||
* We don't want this scriptable from any web page anywhere, but for demo reasons
|
||||
* we're making this really easy to access pending a proper security approach including
|
||||
* access control and authentication at a network and software level
|
||||
* access control and authentication at a network and software level.
|
||||
*
|
||||
*/
|
||||
headers.add("Access-Control-Allow-Origin", "*")
|
||||
|
@ -77,7 +77,7 @@ abstract class MutableClock : Clock() {
|
||||
* of it being mutated. Just returns if [MutableClock] mutates, so needs to be
|
||||
* called in a loop.
|
||||
*
|
||||
* @throws InterruptedException if interrupted by something other than a [MutableClock]
|
||||
* @throws InterruptedException if interrupted by something other than a [MutableClock].
|
||||
*/
|
||||
@Suppress("UNUSED_VALUE") // This is here due to the compiler thinking version is not used
|
||||
@Suspendable
|
||||
@ -107,9 +107,9 @@ private fun Clock.doInterruptibly(runnable: SuspendableRunnable) {
|
||||
|
||||
/**
|
||||
* Wait until the given [Future] is complete or the deadline is reached, with support for [MutableClock] implementations
|
||||
* used in demos or testing. This will also substitute a Fiber compatible Future if required
|
||||
* used in demos or testing. This will also substitute a Fiber compatible Future if required.
|
||||
*
|
||||
* @return true if the [Future] is complete, false if the deadline was reached
|
||||
* @return true if the [Future] is complete, false if the deadline was reached.
|
||||
*/
|
||||
@Suspendable
|
||||
fun Clock.awaitWithDeadline(deadline: Instant, future: Future<*> = SettableFuture<Any>()): Boolean {
|
||||
|
@ -12,7 +12,7 @@ import kotlin.concurrent.withLock
|
||||
|
||||
|
||||
/**
|
||||
* Modelled on [ThreadBox], but with support for waiting that is compatible with Quasar [Fiber]s and [MutableClock]s
|
||||
* Modelled on [ThreadBox], but with support for waiting that is compatible with Quasar [Fiber]s and [MutableClock]s.
|
||||
*
|
||||
* It supports 3 main operations, all of which operate in a similar context to the [locked] method
|
||||
* of [ThreadBox]. i.e. in the context of the content.
|
||||
@ -74,4 +74,4 @@ class FiberBox<T>(private val content: T, private val lock: Lock = ReentrantLock
|
||||
lock.unlock()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@ object JsonSupport {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implemented as a class so that we can instantiate for T
|
||||
* Implemented as a class so that we can instantiate for T.
|
||||
*/
|
||||
class SecureHashDeserializer<T : SecureHash> : JsonDeserializer<T>() {
|
||||
override fun deserialize(parser: JsonParser, context: DeserializationContext): T {
|
||||
|
@ -5,7 +5,7 @@ import java.util.*
|
||||
|
||||
/**
|
||||
* [timestamp] holds a formatted (UTC) timestamp that's set the first time it is queried. This is used to
|
||||
* provide a uniform timestamp for tests
|
||||
* provide a uniform timestamp for tests.
|
||||
*/
|
||||
class TestTimestamp {
|
||||
companion object {
|
||||
|
@ -8,7 +8,7 @@ import java.time.*
|
||||
import javax.annotation.concurrent.ThreadSafe
|
||||
|
||||
/**
|
||||
* A [Clock] that can have the date advanced for use in demos
|
||||
* A [Clock] that can have the date advanced for use in demos.
|
||||
*/
|
||||
@ThreadSafe
|
||||
class DemoClock(private var delegateClock: Clock = Clock.systemUTC()) : MutableClock(), SerializeAsToken {
|
||||
@ -41,4 +41,4 @@ class DemoClock(private var delegateClock: Clock = Clock.systemUTC()) : MutableC
|
||||
return delegateClock.zone
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ enum class IRSDemoRole {
|
||||
sealed class CliParams {
|
||||
|
||||
/**
|
||||
* Corresponds to roles 'SetupNodeA' and 'SetupNodeB'
|
||||
* Corresponds to roles 'SetupNodeA' and 'SetupNodeB'.
|
||||
*/
|
||||
class SetupNode(
|
||||
val node: IRSDemoNode,
|
||||
@ -73,7 +73,7 @@ sealed class CliParams {
|
||||
) : CliParams()
|
||||
|
||||
/**
|
||||
* Corresponds to roles 'NodeA' and 'NodeB'
|
||||
* Corresponds to roles 'NodeA' and 'NodeB'.
|
||||
*/
|
||||
class RunNode(
|
||||
val node: IRSDemoNode,
|
||||
@ -90,7 +90,7 @@ sealed class CliParams {
|
||||
) : CliParams()
|
||||
|
||||
/**
|
||||
* Corresponds to role 'Trade'
|
||||
* Corresponds to role 'Trade'.
|
||||
*/
|
||||
class Trade(
|
||||
val apiAddress: HostAndPort,
|
||||
@ -98,7 +98,7 @@ sealed class CliParams {
|
||||
) : CliParams()
|
||||
|
||||
/**
|
||||
* Corresponds to role 'Date'
|
||||
* Corresponds to role 'Date'.
|
||||
*/
|
||||
class DateChange(
|
||||
val apiAddress: HostAndPort,
|
||||
|
@ -18,7 +18,7 @@ import com.r3corda.protocols.TwoPartyDealProtocol
|
||||
* API call from a single party without bi-directional access to the database of offers etc.
|
||||
*
|
||||
* In the "real world", we'd probably have the offers sitting in the platform prior to the agreement step
|
||||
* or the protocol would have to reach out to external systems (or users) to verify the deals
|
||||
* or the protocol would have to reach out to external systems (or users) to verify the deals.
|
||||
*/
|
||||
object AutoOfferProtocol {
|
||||
val TOPIC = "autooffer.topic"
|
||||
|
@ -35,7 +35,7 @@ object ExitServerProtocol {
|
||||
|
||||
/**
|
||||
* This takes a Java Integer rather than Kotlin Int as that is what we end up with in the calling map and currently
|
||||
* we do not support coercing numeric types in the reflective search for matching constructors
|
||||
* we do not support coercing numeric types in the reflective search for matching constructors.
|
||||
*/
|
||||
class Broadcast(val exitCode: Int) : ProtocolLogic<Boolean>() {
|
||||
|
||||
|
@ -11,7 +11,7 @@ import com.r3corda.node.services.network.MockNetworkMapCache
|
||||
import java.time.LocalDate
|
||||
|
||||
/**
|
||||
* This is a less temporary, demo-oriented way of initiating processing of temporal events
|
||||
* This is a less temporary, demo-oriented way of initiating processing of temporal events.
|
||||
*/
|
||||
object UpdateBusinessDayProtocol {
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user