Minor: more cleanups

This commit is contained in:
Mike Hearn 2017-04-12 12:00:03 +02:00
parent bea799c60d
commit ac337240a6
6 changed files with 7 additions and 9 deletions

View File

@ -74,7 +74,7 @@ object Crypto {
"EDDSA_ED25519_SHA512",
"EdDSA",
EdDSAEngine(),
EdDSAKeyFactory(),
EdDSAKeyFactory,
net.i2p.crypto.eddsa.KeyPairGenerator(), // EdDSA engine uses a custom KeyPairGenerator Vs BouncyCastle.
EdDSANamedCurveTable.getByName("ed25519-sha-512"),
256,

View File

@ -7,4 +7,4 @@ import java.security.KeyFactory
* This is required as a [SignatureScheme] requires a [java.security.KeyFactory] property, but i2p has
* its own KeyFactory for EdDSA, thus this actually a Proxy Pattern over i2p's KeyFactory.
*/
class EdDSAKeyFactory : KeyFactory(net.i2p.crypto.eddsa.KeyFactory(), null, "EDDSA_ED25519_SHA512")
object EdDSAKeyFactory : KeyFactory(net.i2p.crypto.eddsa.KeyFactory(), null, "EDDSA_ED25519_SHA512")

View File

@ -424,14 +424,12 @@ class CryptoUtilsTest {
val privKey: EdDSAPrivateKey = keyPair.private as EdDSAPrivateKey
val pubKey: EdDSAPublicKey = keyPair.public as EdDSAPublicKey
val kf = EdDSAKeyFactory()
// Encode and decode private key.
val privKey2 = kf.generatePrivate(PKCS8EncodedKeySpec(privKey.encoded))
val privKey2 = EdDSAKeyFactory.generatePrivate(PKCS8EncodedKeySpec(privKey.encoded))
assertEquals(privKey2, privKey)
// Encode and decode public key.
val pubKey2 = kf.generatePublic(X509EncodedKeySpec(pubKey.encoded))
val pubKey2 = EdDSAKeyFactory.generatePublic(X509EncodedKeySpec(pubKey.encoded))
assertEquals(pubKey2, pubKey)
}

View File

@ -44,7 +44,7 @@ class DBTransactionMappingStorage : StateMachineRecordedTransactionMappingStorag
private class InnerState {
val stateMachineTransactionMap = TransactionMappingsMap()
val updates = PublishSubject.create<StateMachineTransactionMapping>()!!
val updates: PublishSubject<StateMachineTransactionMapping> = PublishSubject.create()
}
private val mutex = ThreadBox(InnerState())

View File

@ -44,7 +44,7 @@ class DistributedImmutableMap<K : Any, V : Any>(val db: Database, tableName: Str
/** Gets a value for the given [Commands.Get.key] */
fun get(commit: Commit<Commands.Get<K, V>>): V? {
commit.use {
val key = commit.operation().key
val key = it.operation().key
return databaseTransaction(db) { map[key] }
}
}

View File

@ -20,7 +20,7 @@ class VaultSoftLockManager(val vault: VaultService, smm: StateMachineManager) {
init {
smm.changes.subscribe { (logic, addOrRemove, id) ->
if (addOrRemove == AddOrRemove.REMOVE && trackingFlowIds.contains(id.uuid)) {
if (addOrRemove == AddOrRemove.REMOVE && id.uuid in trackingFlowIds) {
log.trace { "$addOrRemove Flow name ${logic.javaClass} with id $id" }
unregisterSoftLocks(id, logic)
}