mirror of
https://github.com/corda/corda.git
synced 2025-02-25 02:56:29 +00:00
all: Full stops in comments!
This commit is contained in:
parent
04c6449f92
commit
d7cc34c9a5
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,5 +1,3 @@
|
|||||||
TODO
|
|
||||||
|
|
||||||
# Eclipse, ctags, Mac metadata, log files
|
# Eclipse, ctags, Mac metadata, log files
|
||||||
.classpath
|
.classpath
|
||||||
.project
|
.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
|
* 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.
|
* 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)
|
@Throws(InsufficientBalanceException::class)
|
||||||
fun generateRedeem(tx: TransactionBuilder, paper: StateAndRef<State>, wallet: List<StateAndRef<Cash.State>>) {
|
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.
|
* Assumes that the rate is valid.
|
||||||
*/
|
*/
|
||||||
class FixedRatePaymentEvent(date: LocalDate,
|
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?
|
* If the rate is null returns a zero payment. // TODO: Is this the desired behaviour?
|
||||||
*/
|
*/
|
||||||
class FloatingRatePaymentEvent(date: LocalDate,
|
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"
|
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 =
|
fun withNewRate(newRate: Rate): FloatingRatePaymentEvent =
|
||||||
FloatingRatePaymentEvent(date, accrualStartDate, accrualEndDate, dayCountBasisDay,
|
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)
|
* 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"
|
* 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".
|
* 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).
|
* 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.
|
* 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
|
* 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
|
* 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(
|
data class Calculation(
|
||||||
val expression: Expression,
|
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 =
|
fun getFixing(date: LocalDate): FloatingRatePaymentEvent =
|
||||||
floatingLegPaymentSchedule.values.single { it.fixingDate == date }
|
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(
|
data class State(
|
||||||
val fixedLeg: FixedLeg,
|
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 {
|
fun evaluateCalculation(businessDate: LocalDate, expression: Expression = calculation.expression): Any {
|
||||||
|
@ -36,14 +36,14 @@ open class PercentageRatioUnit(percentageAsString: String) : RatioUnit(BigDecima
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For the convenience of writing "5".percent
|
* For the convenience of writing "5".percent.
|
||||||
* Note that we do not currently allow 10.percent (ie no quotes) as this might get a little confusing if 0.1.percent was
|
* Note that we do not currently allow 10.percent (ie no quotes) as this might get a little confusing if 0.1.percent was
|
||||||
* written. Additionally, there is a possibility of creating a precision error in the implicit conversion.
|
* written. Additionally, there is a possibility of creating a precision error in the implicit conversion.
|
||||||
*/
|
*/
|
||||||
val String.percent: PercentageRatioUnit get() = PercentageRatioUnit(this)
|
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) {
|
open class Rate(val ratioUnit: RatioUnit? = null) {
|
||||||
override fun equals(other: Any?): Boolean {
|
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)
|
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
|
* 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
|
* 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
|
* 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")
|
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 */
|
/** 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)
|
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] */
|
/** 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.
|
* 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
|
* @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 {
|
abstract class FungibleAsset<T> : Contract {
|
||||||
/** A state representing a cash claim against some party */
|
/** 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()
|
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. */
|
/** 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
|
* 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
|
* 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
|
* 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")
|
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
|
* 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.
|
* 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>,
|
data class Settle<P>(override val aggregateState: IssuanceDefinition<P>,
|
||||||
val amount: Amount<P>) : Commands, IssuanceCommands<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.
|
* 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>,
|
fun ServiceHub.fillWithSomeTestCash(howMuch: Amount<Currency>,
|
||||||
notary: Party = DUMMY_NOTARY,
|
notary: Party = DUMMY_NOTARY,
|
||||||
@ -81,4 +81,4 @@ private fun calculateRandomlySizedAmounts(howMuch: Amount<Currency>, min: Int, m
|
|||||||
}
|
}
|
||||||
check(amounts.sum() == howMuch.quantity)
|
check(amounts.sum() == howMuch.quantity)
|
||||||
return amounts
|
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 {
|
fun singleIRS(irsSelector: Int = 1): InterestRateSwap.State {
|
||||||
return generateIRSTxn(irsSelector).outputs.map { it.data }.filterIsInstance<InterestRateSwap.State>().single()
|
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
|
@Test
|
||||||
fun `IRS Export 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
|
@Test
|
||||||
fun `next fixing date`() {
|
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
|
@Test
|
||||||
fun generateIRSandFixSome() {
|
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
|
@Test
|
||||||
fun `ensure same currency notionals`() {
|
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.
|
* 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)
|
@Throws(IllegalArgumentException::class)
|
||||||
// TODO: Can we have a common Move command for all contracts and avoid the reified type parameter here?
|
// 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.
|
* 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)
|
@Throws(IllegalArgumentException::class)
|
||||||
inline fun <reified T : MoveCommand> verifyMoveCommand(inputs: List<OwnableState>,
|
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,
|
* 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...
|
* 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: 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].
|
* @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
|
* 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) }
|
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
|
* 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
|
* 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
|
* There are some additional rules which are explained in the individual cases below.
|
||||||
*/
|
*/
|
||||||
enum class DateRollConvention {
|
enum class DateRollConvention {
|
||||||
// direction() cannot be a val due to the throw in the Actual instance
|
// 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.
|
* can be a multilateral netting transaction, and may be created by a central clearing service.
|
||||||
*/
|
*/
|
||||||
PAYMENT
|
PAYMENT
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ data class TransactionState<out T : ContractState>(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Copies the underlying state, replacing the notary field with the new value.
|
* 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)
|
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.
|
* 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.
|
* 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
|
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 {
|
interface LinearState : ContractState {
|
||||||
/** Unique thread id within the wallets of all parties */
|
/** 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.
|
* 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?
|
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
|
* 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: 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
|
* 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
|
fun generateAgreement(notary: Party): TransactionBuilder
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Interface adding fixing specific methods
|
* Interface adding fixing specific methods.
|
||||||
*/
|
*/
|
||||||
interface FixableDealState : DealState {
|
interface FixableDealState : DealState {
|
||||||
/**
|
/**
|
||||||
@ -237,10 +237,10 @@ interface FixableDealState : DealState {
|
|||||||
fun nextFixingOf(): FixOf?
|
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
|
* 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)
|
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
|
* 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
|
// 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
|
// 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()
|
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 =
|
fun copy(): TransactionBuilder =
|
||||||
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
|
* Checks that the given signature matches one of the commands and that it is a correct signature over the tx, then
|
||||||
* adds it.
|
* 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.
|
* @throws IllegalArgumentException if the signature key doesn't appear in any command.
|
||||||
*/
|
*/
|
||||||
fun checkAndAddSignature(sig: DigitalSignature.WithKey) {
|
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.
|
* 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.
|
* @throws IllegalArgumentException if the signature key doesn't appear in any command.
|
||||||
*/
|
*/
|
||||||
fun checkSignature(sig: DigitalSignature.WithKey) {
|
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.
|
* 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 transactions map of transaction id to [SignedTransaction].
|
||||||
* @param startPoints transactions to use as starting points for the search
|
* @param startPoints transactions to use as starting points for the search.
|
||||||
*/
|
*/
|
||||||
class TransactionGraphSearch(val transactions: ReadOnlyTransactionStorage,
|
class TransactionGraphSearch(val transactions: ReadOnlyTransactionStorage,
|
||||||
val startPoints: List<WireTransaction>) : Callable<List<WireTransaction>> {
|
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.
|
* 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>
|
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.
|
* 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) {
|
override fun verifyTransaction(tx: TransactionForVerification) {
|
||||||
// TODO: Check that notary is unchanged
|
// 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,
|
* 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) {
|
override fun verifyTransaction(tx: TransactionForVerification) {
|
||||||
try {
|
try {
|
||||||
@ -111,4 +111,4 @@ sealed class TransactionType {
|
|||||||
return participantKeys
|
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.
|
* 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
|
* @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)
|
@Throws(TransactionVerificationException::class)
|
||||||
fun verify() = type.verify(this)
|
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)
|
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> {
|
fun getMissingSignatures(): Set<PublicKey> {
|
||||||
val requiredKeys = tx.signers.toSet()
|
val requiredKeys = tx.signers.toSet()
|
||||||
@ -176,4 +176,4 @@ data class LedgerTransaction(
|
|||||||
) : NamedByHash {
|
) : NamedByHash {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
fun <T : ContractState> outRef(index: Int) = StateAndRef(outputs[index] as TransactionState<T>, StateRef(id, index))
|
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
|
* A serialized piece of data and its signature. Enforces signature validity in order to deserialize the data
|
||||||
* contained within.
|
* contained within.
|
||||||
*
|
*
|
||||||
* @param raw the raw serialized data
|
* @param raw the raw serialized data.
|
||||||
* @param sig the (unverified) signature for the data
|
* @param sig the (unverified) signature for the data.
|
||||||
*/
|
*/
|
||||||
open class SignedData<T : Any>(val raw: SerializedBytes<T>, val sig: DigitalSignature.WithKey) {
|
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 {
|
class LinearInterpolator(private val xs: DoubleArray, private val ys: DoubleArray) : Interpolator {
|
||||||
init {
|
init {
|
||||||
@ -105,8 +105,8 @@ class CubicSplineInterpolator(private val xs: DoubleArray, private val ys: Doubl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a polynomial function of arbitrary degree
|
* Represents a polynomial function of arbitrary degree.
|
||||||
* @param coefficients polynomial coefficients in the order of degree (constant first, followed by higher degree term coefficients)
|
* @param coefficients polynomial coefficients in the order of degree (constant first, followed by higher degree term coefficients).
|
||||||
*/
|
*/
|
||||||
class Polynomial(private val coefficients: DoubleArray) {
|
class Polynomial(private val coefficients: DoubleArray) {
|
||||||
private val reversedCoefficients = coefficients.reversed()
|
private val reversedCoefficients = coefficients.reversed()
|
||||||
@ -118,7 +118,7 @@ class Polynomial(private val coefficients: DoubleArray) {
|
|||||||
* A *spline* is function piecewise-defined by polynomial functions.
|
* A *spline* is function piecewise-defined by polynomial functions.
|
||||||
* Points at which polynomial pieces connect are known as *knots*.
|
* 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>) {
|
class SplineFunction(private val segmentMap: TreeMap<Double, Polynomial>) {
|
||||||
fun getValue(x: Double): Double {
|
fun getValue(x: Double): Double {
|
||||||
|
@ -16,8 +16,8 @@ interface CordaPluginRegistry {
|
|||||||
* A Map with an entry for each consumed protocol used by the webAPIs.
|
* 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 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.
|
* 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
|
* 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
|
* This is used to extend the white listed protocols that can be initiated from the ServiceHub invokeProtocolAsync method.
|
||||||
*/
|
*/
|
||||||
val requiredProtocols: Map<String, Set<String>>
|
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
|
* 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.
|
* 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>)
|
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
|
* Given some [SignedTransaction]s, writes them to the local storage for validated transactions and then
|
||||||
* sends them to the wallet for further processing.
|
* 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())
|
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<*> {
|
fun loadState(stateRef: StateRef): TransactionState<*> {
|
||||||
val definingTx = storageService.validatedTransactions.getTransaction(stateRef.txhash) ?: throw TransactionResolutionException(stateRef.txhash)
|
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.
|
* 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>
|
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.
|
* to the raw byte stream is required.
|
||||||
*
|
*
|
||||||
* @throws FileAlreadyExistsException if the given byte stream has already been inserted.
|
* @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.
|
* @throws IOException if something went wrong.
|
||||||
*/
|
*/
|
||||||
fun importAttachment(jar: InputStream): SecureHash
|
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
|
* Add a network map service; fetches a copy of the latest map from the service and subscribes to any further
|
||||||
* updates.
|
* 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 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
|
* @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.
|
* 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>
|
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)
|
fun addNode(node: NodeInfo)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a node from the local cache
|
* Removes a node from the local cache.
|
||||||
*/
|
*/
|
||||||
fun removeNode(node: NodeInfo)
|
fun removeNode(node: NodeInfo)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deregister from updates from the given map service.
|
* 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.
|
* @param service the network map service to fetch current state from.
|
||||||
*/
|
*/
|
||||||
fun deregisterForUpdates(net: MessagingService, service: NodeInfo): ListenableFuture<Unit>
|
fun deregisterForUpdates(net: MessagingService, service: NodeInfo): ListenableFuture<Unit>
|
||||||
@ -96,4 +96,4 @@ interface NetworkMapCache {
|
|||||||
sealed class NetworkCacheError : Exception() {
|
sealed class NetworkCacheError : Exception() {
|
||||||
/** Indicates a failure to deregister, because of a rejected request from the remote node */
|
/** Indicates a failure to deregister, because of a rejected request from the remote node */
|
||||||
class DeregistrationFailed : NetworkCacheError()
|
class DeregistrationFailed : NetworkCacheError()
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ val TOPIC_DEFAULT_POSTFIX = ".0"
|
|||||||
*
|
*
|
||||||
* [states] Holds the list of states that are *active* and *relevant*.
|
* [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).
|
* 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>>) {
|
class Wallet(val states: List<StateAndRef<ContractState>>) {
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
@ -80,7 +80,7 @@ interface WalletService {
|
|||||||
val currentWallet: Wallet
|
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>>
|
val linearHeads: Map<SecureHash, StateAndRef<LinearState>>
|
||||||
|
|
||||||
@ -206,4 +206,4 @@ interface SchedulerService {
|
|||||||
|
|
||||||
/** Unschedule all activity for a TX output, probably because it was consumed. */
|
/** Unschedule all activity for a TX output, probably because it was consumed. */
|
||||||
fun unscheduleStateActivity(ref: StateRef)
|
fun unscheduleStateActivity(ref: StateRef)
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ import java.time.Clock
|
|||||||
import java.time.Duration
|
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(),
|
class TimestampChecker(val clock: Clock = Clock.systemUTC(),
|
||||||
val tolerance: Duration = 30.seconds) {
|
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
|
if (after != null && now until after > tolerance) return false
|
||||||
return true
|
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
|
* 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 {
|
interface UniquenessProvider {
|
||||||
/** Commits all input states of the given transaction */
|
/** 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
|
* 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
|
* 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.
|
* 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)
|
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
|
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
|
* 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.
|
* 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")
|
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)
|
// 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?>)
|
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
|
// TODO: build a real [AttachmentsClassLoader] etc
|
||||||
val classLoader: ClassLoader
|
val classLoader: ClassLoader
|
||||||
get() = this.javaClass.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> {
|
interface ProtocolStateMachine<R> {
|
||||||
@Suspendable
|
@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
|
* 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> {
|
fun <T : Any> T.serialize(kryo: Kryo = THREAD_LOCAL_KRYO.get()): SerializedBytes<T> {
|
||||||
val stream = ByteArrayOutputStream()
|
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 {
|
interface SerializationToken {
|
||||||
fun fromToken(context: SerializeAsTokenContext): Any
|
fun fromToken(context: SerializeAsTokenContext): Any
|
||||||
@ -130,4 +130,4 @@ abstract class SingletonSerializeAsToken() : SerializeAsToken {
|
|||||||
private val token = SingletonSerializationToken(this)
|
private val token = SingletonSerializationToken(this)
|
||||||
|
|
||||||
override fun toToken(context: SerializeAsTokenContext) = SingletonSerializationToken.registerWithContext(token, this, context)
|
override fun toToken(context: SerializeAsTokenContext) = SingletonSerializationToken.registerWithContext(token, this, context)
|
||||||
}
|
}
|
||||||
|
@ -43,7 +43,7 @@ open class InMemoryWalletService(private val services: ServiceHub) : SingletonSe
|
|||||||
get() = _updatesPublisher
|
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>>
|
override val linearHeads: Map<SecureHash, StateAndRef<LinearState>>
|
||||||
get() = currentWallet.let { wallet ->
|
get() = currentWallet.let { wallet ->
|
||||||
|
@ -12,14 +12,14 @@ interface OutputStateLookup {
|
|||||||
/**
|
/**
|
||||||
* Retrieves an output previously defined by [TransactionDSLInterpreter._output] with a label passed in.
|
* 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 clazz The class object holding the type of the output state expected.
|
||||||
* @param label The label of the to-be-retrieved output state
|
* @param label The label of the to-be-retrieved output state.
|
||||||
* @return The output [StateAndRef]
|
* @return The output [StateAndRef].
|
||||||
*/
|
*/
|
||||||
fun <S : ContractState> retrieveOutputStateAndRef(clazz: Class<S>, label: String): StateAndRef<S>
|
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 {
|
interface Verifies {
|
||||||
/**
|
/**
|
||||||
@ -28,7 +28,7 @@ interface Verifies {
|
|||||||
fun verifies(): EnforceVerifyOrFail
|
fun verifies(): EnforceVerifyOrFail
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that verifies() throws
|
* Asserts that verifies() throws.
|
||||||
* @param expectedMessage An optional string to be searched for in the raised exception.
|
* @param expectedMessage An optional string to be searched for in the raised exception.
|
||||||
*/
|
*/
|
||||||
fun failsWith(expectedMessage: String?): EnforceVerifyOrFail {
|
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)
|
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
|
* 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
|
* 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.
|
* the triggered diagnostic.
|
||||||
|
@ -35,7 +35,7 @@ interface TransactionDSLInterpreter : Verifies, OutputStateLookup {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Adds an [Attachment] reference to the transaction.
|
* 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)
|
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
|
* 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
|
* @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,
|
class Client(private val stx: SignedTransaction,
|
||||||
override val progressTracker: ProgressTracker = Client.tracker()) : ProtocolLogic<DigitalSignature.LegallyIdentifiable>() {
|
override val progressTracker: ProgressTracker = Client.tracker()) : ProtocolLogic<DigitalSignature.LegallyIdentifiable>() {
|
||||||
@ -157,7 +157,7 @@ object NotaryProtocol {
|
|||||||
* history chain.
|
* history chain.
|
||||||
* As a result, the Notary _will commit invalid transactions_ as well, but as it also records the identity of
|
* 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
|
* 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
|
@Suspendable
|
||||||
open fun beforeCommit(stx: SignedTransaction, reqIdentity: Party) {
|
open fun beforeCommit(stx: SignedTransaction, reqIdentity: Party) {
|
||||||
@ -234,4 +234,4 @@ sealed class NotaryError {
|
|||||||
class TransactionInvalid : NotaryError()
|
class TransactionInvalid : NotaryError()
|
||||||
|
|
||||||
class SignaturesMissing(val missingSigners: List<PublicKey>) : 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
|
* 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
|
* 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
|
* 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
|
* 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
|
* 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,
|
class ValidatingNotaryProtocol(otherSide: Party,
|
||||||
sessionIdForSend: Long,
|
sessionIdForSend: Long,
|
||||||
@ -53,4 +53,4 @@ class ValidatingNotaryProtocol(otherSide: Party,
|
|||||||
private fun validateDependencies(reqIdentity: Party, wtx: WireTransaction) {
|
private fun validateDependencies(reqIdentity: Party, wtx: WireTransaction) {
|
||||||
subProtocol(ResolveTransactionsProtocol(wtx, reqIdentity))
|
subProtocol(ResolveTransactionsProtocol(wtx, reqIdentity))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import kotlin.test.assertTrue
|
|||||||
import kotlin.test.fail
|
import kotlin.test.fail
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modified from the bitcoinj library
|
* Modified from the bitcoinj library.
|
||||||
*/
|
*/
|
||||||
class Base58Test {
|
class Base58Test {
|
||||||
@Test
|
@Test
|
||||||
|
@ -32,7 +32,7 @@ interface APIServer {
|
|||||||
fun serverTime(): LocalDateTime
|
fun serverTime(): LocalDateTime
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Report whether this node is started up or not
|
* Report whether this node is started up or not.
|
||||||
*/
|
*/
|
||||||
@GET
|
@GET
|
||||||
@Path("status")
|
@Path("status")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package com.r3corda.node.api
|
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 {
|
interface StatesQuery {
|
||||||
companion object {
|
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.
|
// 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
|
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 {
|
open fun setup(): AbstractNode {
|
||||||
createNodeDir()
|
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 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
|
* @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.
|
* 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
|
* @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.
|
* network map service, while bootstrapping a network.
|
||||||
* @param advertisedServices The services this node advertises. This must be a subset of the services it runs,
|
* @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).
|
* but nodes are not required to advertise services they run (hence subset).
|
||||||
* @param clientAPIs A list of JAX-RS annotated classes to register
|
* @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.
|
* 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
|
* 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
|
* @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,
|
class Node(dir: Path, val p2pAddr: HostAndPort, val webServerAddr: HostAndPort, configuration: NodeConfiguration,
|
||||||
networkMapAddress: NodeInfo?, advertisedServices: Set<ServiceType>,
|
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
|
@ThreadSafe
|
||||||
class TestClock(private var delegateClock: Clock = Clock.systemUTC()) : MutableClock(), SerializeAsToken {
|
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
|
* 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
|
* 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 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.
|
* @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
|
* 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
|
* 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 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 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>
|
protected inline fun <reified Q : ServiceRequestMessage, reified R : Any>
|
||||||
addMessageHandler(topic: String,
|
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
|
* sends them to the wallet for further processing. This is intended for implementations to call from
|
||||||
* [recordTransactions].
|
* [recordTransactions].
|
||||||
*
|
*
|
||||||
* @param txs The transactions to record
|
* @param txs The transactions to record.
|
||||||
*/
|
*/
|
||||||
internal fun recordTransactionsInternal(writableStorageService: TxWritableStorageService, txs: Iterable<SignedTransaction>) {
|
internal fun recordTransactionsInternal(writableStorageService: TxWritableStorageService, txs: Iterable<SignedTransaction>) {
|
||||||
txs.forEach { writableStorageService.validatedTransactions.addTransaction(it) }
|
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
|
* 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
|
* 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>
|
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>
|
val logic = protocolLogicRefFactory.toProtocolLogic(logicRef) as ProtocolLogic<T>
|
||||||
return startProtocol(logicType.simpleName, logic)
|
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 {
|
class FixingServicePlugin : CordaPluginRegistry {
|
||||||
override val webApis: List<Class<*>> = emptyList()
|
override val webApis: List<Class<*>> = emptyList()
|
||||||
@ -252,7 +252,7 @@ object NodeInterestRates {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the interest rate for a given [Tenor],
|
* 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? {
|
fun getRate(tenor: Tenor): BigDecimal? {
|
||||||
return rates.getOrElse(tenor) {
|
return rates.getOrElse(tenor) {
|
||||||
@ -297,4 +297,4 @@ object NodeInterestRates {
|
|||||||
val name = words.dropLast(2).joinToString(" ")
|
val name = words.dropLast(2).joinToString(" ")
|
||||||
return FixOf(name, LocalDate.parse(date), Tenor(tenorString))
|
return FixOf(name, LocalDate.parse(date), Tenor(tenorString))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,9 @@ import javax.annotation.concurrent.ThreadSafe
|
|||||||
* on a separate/firewalled service.
|
* 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 the protocol framework so requests to fetch keys can be suspended whilst a human signs off on the request.
|
||||||
* - Use deterministic key derivation.
|
* - 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
|
@ThreadSafe
|
||||||
class E2ETestKeyManagementService(initialKeys: Set<KeyPair>) : SingletonSerializeAsToken(), KeyManagementService {
|
class E2ETestKeyManagementService(initialKeys: Set<KeyPair>) : SingletonSerializeAsToken(), KeyManagementService {
|
||||||
@ -47,4 +47,4 @@ class E2ETestKeyManagementService(initialKeys: Set<KeyPair>) : SingletonSerializ
|
|||||||
}
|
}
|
||||||
return keypair
|
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.
|
* 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 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> {
|
fun createNodeWithID(manuallyPumped: Boolean, id: Int, description: String? = null): MessagingServiceBuilder<InMemoryMessaging> {
|
||||||
return Builder(manuallyPumped, Handle(id, description ?: "In memory node $id"))
|
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:
|
* 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
|
* - 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).
|
* 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,
|
abstract class NotaryService(val smm: StateMachineManager,
|
||||||
net: MessagingService,
|
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
|
* 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
|
@Provider
|
||||||
class Config(val services: ServiceHub) : ContextResolver<ObjectMapper> {
|
class Config(val services: ServiceHub) : ContextResolver<ObjectMapper> {
|
||||||
val defaultObjectMapper = JsonSupport.createDefaultMapper(services.identityService)
|
val defaultObjectMapper = JsonSupport.createDefaultMapper(services.identityService)
|
||||||
override fun getContext(type: Class<*>) = defaultObjectMapper
|
override fun getContext(type: Class<*>) = defaultObjectMapper
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import javax.ws.rs.container.ContainerResponseFilter
|
|||||||
import javax.ws.rs.ext.Provider
|
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
|
@Provider
|
||||||
class ResponseFilter : ContainerResponseFilter {
|
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 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
|
* 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", "*")
|
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
|
* of it being mutated. Just returns if [MutableClock] mutates, so needs to be
|
||||||
* called in a loop.
|
* 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
|
@Suppress("UNUSED_VALUE") // This is here due to the compiler thinking version is not used
|
||||||
@Suspendable
|
@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
|
* 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
|
@Suspendable
|
||||||
fun Clock.awaitWithDeadline(deadline: Instant, future: Future<*> = SettableFuture<Any>()): Boolean {
|
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
|
* 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.
|
* 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()
|
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>() {
|
class SecureHashDeserializer<T : SecureHash> : JsonDeserializer<T>() {
|
||||||
override fun deserialize(parser: JsonParser, context: DeserializationContext): 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
|
* [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 {
|
class TestTimestamp {
|
||||||
companion object {
|
companion object {
|
||||||
|
@ -8,7 +8,7 @@ import java.time.*
|
|||||||
import javax.annotation.concurrent.ThreadSafe
|
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
|
@ThreadSafe
|
||||||
class DemoClock(private var delegateClock: Clock = Clock.systemUTC()) : MutableClock(), SerializeAsToken {
|
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
|
return delegateClock.zone
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ enum class IRSDemoRole {
|
|||||||
sealed class CliParams {
|
sealed class CliParams {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Corresponds to roles 'SetupNodeA' and 'SetupNodeB'
|
* Corresponds to roles 'SetupNodeA' and 'SetupNodeB'.
|
||||||
*/
|
*/
|
||||||
class SetupNode(
|
class SetupNode(
|
||||||
val node: IRSDemoNode,
|
val node: IRSDemoNode,
|
||||||
@ -73,7 +73,7 @@ sealed class CliParams {
|
|||||||
) : CliParams()
|
) : CliParams()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Corresponds to roles 'NodeA' and 'NodeB'
|
* Corresponds to roles 'NodeA' and 'NodeB'.
|
||||||
*/
|
*/
|
||||||
class RunNode(
|
class RunNode(
|
||||||
val node: IRSDemoNode,
|
val node: IRSDemoNode,
|
||||||
@ -90,7 +90,7 @@ sealed class CliParams {
|
|||||||
) : CliParams()
|
) : CliParams()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Corresponds to role 'Trade'
|
* Corresponds to role 'Trade'.
|
||||||
*/
|
*/
|
||||||
class Trade(
|
class Trade(
|
||||||
val apiAddress: HostAndPort,
|
val apiAddress: HostAndPort,
|
||||||
@ -98,7 +98,7 @@ sealed class CliParams {
|
|||||||
) : CliParams()
|
) : CliParams()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Corresponds to role 'Date'
|
* Corresponds to role 'Date'.
|
||||||
*/
|
*/
|
||||||
class DateChange(
|
class DateChange(
|
||||||
val apiAddress: HostAndPort,
|
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.
|
* 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
|
* 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 {
|
object AutoOfferProtocol {
|
||||||
val TOPIC = "autooffer.topic"
|
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
|
* 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>() {
|
class Broadcast(val exitCode: Int) : ProtocolLogic<Boolean>() {
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ import com.r3corda.node.services.network.MockNetworkMapCache
|
|||||||
import java.time.LocalDate
|
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 {
|
object UpdateBusinessDayProtocol {
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user