mirror of
https://github.com/corda/corda.git
synced 2025-06-11 20:01:46 +00:00
@ -66,6 +66,7 @@ private fun calculateRandomlySizedAmounts(howMuch: Amount<Currency>, min: Int, m
|
|||||||
val numStates = min + Math.floor(rng.nextDouble() * (max - min)).toInt()
|
val numStates = min + Math.floor(rng.nextDouble() * (max - min)).toInt()
|
||||||
val amounts = LongArray(numStates)
|
val amounts = LongArray(numStates)
|
||||||
val baseSize = howMuch.quantity / numStates
|
val baseSize = howMuch.quantity / numStates
|
||||||
|
check(baseSize > 0) { baseSize }
|
||||||
var filledSoFar = 0L
|
var filledSoFar = 0L
|
||||||
for (i in 0..numStates - 1) {
|
for (i in 0..numStates - 1) {
|
||||||
if (i < numStates - 1) {
|
if (i < numStates - 1) {
|
||||||
@ -76,6 +77,7 @@ private fun calculateRandomlySizedAmounts(howMuch: Amount<Currency>, min: Int, m
|
|||||||
// Handle inexact rounding.
|
// Handle inexact rounding.
|
||||||
amounts[i] = howMuch.quantity - filledSoFar
|
amounts[i] = howMuch.quantity - filledSoFar
|
||||||
}
|
}
|
||||||
|
check(amounts[i] >= 0) { amounts[i] }
|
||||||
}
|
}
|
||||||
check(amounts.sum() == howMuch.quantity)
|
check(amounts.sum() == howMuch.quantity)
|
||||||
return amounts
|
return amounts
|
||||||
|
@ -5,9 +5,9 @@ import com.r3corda.core.serialization.OpaqueBytes
|
|||||||
import com.r3corda.core.serialization.SerializedBytes
|
import com.r3corda.core.serialization.SerializedBytes
|
||||||
import com.r3corda.core.serialization.deserialize
|
import com.r3corda.core.serialization.deserialize
|
||||||
import net.i2p.crypto.eddsa.EdDSAEngine
|
import net.i2p.crypto.eddsa.EdDSAEngine
|
||||||
|
import net.i2p.crypto.eddsa.EdDSAPublicKey
|
||||||
import java.math.BigInteger
|
import java.math.BigInteger
|
||||||
import java.security.*
|
import java.security.*
|
||||||
import java.security.interfaces.ECPublicKey
|
|
||||||
import net.i2p.crypto.eddsa.KeyPairGenerator as EddsaKeyPairGenerator
|
import net.i2p.crypto.eddsa.KeyPairGenerator as EddsaKeyPairGenerator
|
||||||
|
|
||||||
fun newSecureRandom(): SecureRandom {
|
fun newSecureRandom(): SecureRandom {
|
||||||
@ -158,8 +158,8 @@ fun PublicKey.verifyWithECDSA(content: ByteArray, signature: DigitalSignature) {
|
|||||||
|
|
||||||
/** Render a public key to a string, using a short form if it's an elliptic curve public key */
|
/** Render a public key to a string, using a short form if it's an elliptic curve public key */
|
||||||
fun PublicKey.toStringShort(): String {
|
fun PublicKey.toStringShort(): String {
|
||||||
return (this as? ECPublicKey)?.let { key ->
|
return (this as? EdDSAPublicKey)?.let { key ->
|
||||||
"DL" + Base58.encode(key.w.affineX.toByteArray()) // DL -> Distributed Ledger
|
"DL" + Base58.encode(key.abyte) // DL -> Distributed Ledger
|
||||||
} ?: toString()
|
} ?: toString()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,7 +121,11 @@ class MockNetwork(private val networkSendManuallyPumped: Boolean = false,
|
|||||||
override val nearestCity: String = "Atlantis"
|
override val nearestCity: String = "Atlantis"
|
||||||
}
|
}
|
||||||
val node = nodeFactory.create(path, config, this, networkMapAddress, advertisedServices.toSet(), id, keyPair)
|
val node = nodeFactory.create(path, config, this, networkMapAddress, advertisedServices.toSet(), id, keyPair)
|
||||||
if (start) node.setup().start()
|
if (start) {
|
||||||
|
node.setup().start()
|
||||||
|
if (threadPerNode && networkMapAddress != null)
|
||||||
|
node.networkMapRegistrationFuture.get() // Block and wait for the node to register in the net map.
|
||||||
|
}
|
||||||
_nodes.add(node)
|
_nodes.add(node)
|
||||||
return node
|
return node
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user