mirror of
https://github.com/corda/corda.git
synced 2025-02-06 11:09:18 +00:00
Minor: rewrap a few lines to be style guide compliant.
This commit is contained in:
parent
4a36751798
commit
9cfa5743ff
@ -105,7 +105,8 @@ fun Iterable<Amount>.sumOrZero(currency: Currency) = if (iterator().hasNext()) s
|
|||||||
//// Authenticated commands ///////////////////////////////////////////////////////////////////////////////////////////
|
//// Authenticated commands ///////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/** Filters the command list by type, party and public key all at once. */
|
/** Filters the command list by type, party and public key all at once. */
|
||||||
inline fun <reified T : CommandData> List<AuthenticatedObject<CommandData>>.select(signer: PublicKey? = null, party: Party? = null) =
|
inline fun <reified T : CommandData> List<AuthenticatedObject<CommandData>>.select(signer: PublicKey? = null,
|
||||||
|
party: Party? = null) =
|
||||||
filter { it.value is T }.
|
filter { it.value is T }.
|
||||||
filter { if (signer == null) true else it.signers.contains(signer) }.
|
filter { if (signer == null) true else it.signers.contains(signer) }.
|
||||||
filter { if (party == null) true else it.signingParties.contains(party) }.
|
filter { if (party == null) true else it.signingParties.contains(party) }.
|
||||||
@ -118,7 +119,8 @@ inline fun <reified T : CommandData> List<AuthenticatedObject<CommandData>>.requ
|
|||||||
}
|
}
|
||||||
|
|
||||||
// For Java
|
// For Java
|
||||||
fun List<AuthenticatedObject<CommandData>>.requireSingleCommand(klass: Class<out CommandData>) = filter { klass.isInstance(it) }.single()
|
fun List<AuthenticatedObject<CommandData>>.requireSingleCommand(klass: Class<out CommandData>) =
|
||||||
|
filter { klass.isInstance(it) }.single()
|
||||||
|
|
||||||
/** Returns a timestamp that was signed by the given authority, or returns null if missing. */
|
/** Returns a timestamp that was signed by the given authority, or returns null if missing. */
|
||||||
fun List<AuthenticatedObject<CommandData>>.getTimestampBy(timestampingAuthority: Party): TimestampCommand? {
|
fun List<AuthenticatedObject<CommandData>>.getTimestampBy(timestampingAuthority: Party): TimestampCommand? {
|
||||||
|
@ -142,7 +142,8 @@ public class InMemoryNetwork {
|
|||||||
* An instance can be obtained by creating a builder and then using the start method.
|
* An instance can be obtained by creating a builder and then using the start method.
|
||||||
*/
|
*/
|
||||||
inner class Node(private val manuallyPumped: Boolean, private val handle: Handle): MessagingService {
|
inner class Node(private val manuallyPumped: Boolean, private val handle: Handle): MessagingService {
|
||||||
inner class Handler(val executor: Executor?, val topic: String, val callback: (Message, MessageHandlerRegistration) -> Unit) : MessageHandlerRegistration
|
inner class Handler(val executor: Executor?, val topic: String,
|
||||||
|
val callback: (Message, MessageHandlerRegistration) -> Unit) : MessageHandlerRegistration
|
||||||
@GuardedBy("this")
|
@GuardedBy("this")
|
||||||
protected val handlers: MutableList<Handler> = ArrayList()
|
protected val handlers: MutableList<Handler> = ArrayList()
|
||||||
@GuardedBy("this")
|
@GuardedBy("this")
|
||||||
@ -156,7 +157,8 @@ public class InMemoryNetwork {
|
|||||||
override val timestampingNodes = if (timestampingAdvert != null) listOf(timestampingAdvert!!) else emptyList()
|
override val timestampingNodes = if (timestampingAdvert != null) listOf(timestampingAdvert!!) else emptyList()
|
||||||
}
|
}
|
||||||
|
|
||||||
protected val backgroundThread = if (manuallyPumped) null else thread(isDaemon = true, name = "In-memory message dispatcher ") {
|
protected val backgroundThread = if (manuallyPumped) null else
|
||||||
|
thread(isDaemon = true, name = "In-memory message dispatcher ") {
|
||||||
while (!currentThread.isInterrupted) {
|
while (!currentThread.isInterrupted) {
|
||||||
try {
|
try {
|
||||||
pumpInternal(true)
|
pumpInternal(true)
|
||||||
|
@ -72,8 +72,12 @@ class SerializedBytes<T : Any>(bits: ByteArray) : OpaqueBytes(bits) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Some extension functions that make deserialisation convenient and provide auto-casting of the result.
|
// Some extension functions that make deserialisation convenient and provide auto-casting of the result.
|
||||||
inline fun <reified T : Any> ByteArray.deserialize(kryo: Kryo = THREAD_LOCAL_KRYO.get()): T = kryo.readObject(Input(this), T::class.java)
|
inline fun <reified T : Any> ByteArray.deserialize(kryo: Kryo = THREAD_LOCAL_KRYO.get()): T {
|
||||||
inline fun <reified T : Any> OpaqueBytes.deserialize(kryo: Kryo = THREAD_LOCAL_KRYO.get()): T = kryo.readObject(Input(this.bits), T::class.java)
|
return kryo.readObject(Input(this), T::class.java)
|
||||||
|
}
|
||||||
|
inline fun <reified T : Any> OpaqueBytes.deserialize(kryo: Kryo = THREAD_LOCAL_KRYO.get()): T {
|
||||||
|
return kryo.readObject(Input(this.bits), T::class.java)
|
||||||
|
}
|
||||||
inline fun <reified T : Any> SerializedBytes<T>.deserialize(): T = bits.deserialize()
|
inline fun <reified T : Any> SerializedBytes<T>.deserialize(): T = bits.deserialize()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -132,7 +136,8 @@ class ImmutableClassSerializer<T : Any>(val klass: KClass<T>) : Serializer<T>()
|
|||||||
// A few quick checks for data evolution. Note that this is not guaranteed to catch every problem! But it's
|
// A few quick checks for data evolution. Note that this is not guaranteed to catch every problem! But it's
|
||||||
// good enough for a prototype.
|
// good enough for a prototype.
|
||||||
if (numFields != constructor.parameters.size)
|
if (numFields != constructor.parameters.size)
|
||||||
throw KryoException("Mismatch between number of constructor parameters and number of serialised fields for ${klass.qualifiedName} ($numFields vs ${constructor.parameters.size})")
|
throw KryoException("Mismatch between number of constructor parameters and number of serialised fields " +
|
||||||
|
"for ${klass.qualifiedName} ($numFields vs ${constructor.parameters.size})")
|
||||||
if (fieldTypeHash != constructor.parameters.hashCode())
|
if (fieldTypeHash != constructor.parameters.hashCode())
|
||||||
throw KryoException("Hashcode mismatch for parameter types for ${klass.qualifiedName}: unsupported type evolution has happened.")
|
throw KryoException("Hashcode mismatch for parameter types for ${klass.qualifiedName}: unsupported type evolution has happened.")
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user