From cda3ecbc0a8434bec39000114e39b9b8476008e2 Mon Sep 17 00:00:00 2001 From: josecoll Date: Tue, 17 Oct 2017 11:43:29 +0100 Subject: [PATCH] Revert DBPartyAndCertificate change: PK should be party name (not owningKeyHash). --- .../kotlin/net/corda/core/schemas/NodeInfoSchema.kt | 11 +++++------ .../services/network/PersistentNetworkMapCache.kt | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/core/src/main/kotlin/net/corda/core/schemas/NodeInfoSchema.kt b/core/src/main/kotlin/net/corda/core/schemas/NodeInfoSchema.kt index 1f4d375dc9..61247d4f80 100644 --- a/core/src/main/kotlin/net/corda/core/schemas/NodeInfoSchema.kt +++ b/core/src/main/kotlin/net/corda/core/schemas/NodeInfoSchema.kt @@ -1,11 +1,11 @@ package net.corda.core.schemas -import net.corda.core.crypto.sha256 import net.corda.core.identity.PartyAndCertificate import net.corda.core.node.NodeInfo import net.corda.core.serialization.deserialize import net.corda.core.serialization.serialize import net.corda.core.utilities.NetworkHostAndPort +import net.corda.core.utilities.toBase58String import java.io.Serializable import javax.persistence.* @@ -85,13 +85,12 @@ object NodeInfoSchemaV1 : MappedSchema( @Table(name = "node_info_party_cert") data class DBPartyAndCertificate( @Id - @Column(name = "owning_key_hash", length = 64) - val owningKeyHash: String, - - //@Id // TODO Do we assume that names are unique? Note: We can't have it as Id, because our toString on X500 is inconsistent. @Column(name = "party_name", nullable = false) val name: String, + @Column(name = "owning_key", length = 65535, nullable = false) + val owningKey: String, + @Column(name = "party_cert_binary") @Lob val partyCertBinary: ByteArray, @@ -102,7 +101,7 @@ object NodeInfoSchemaV1 : MappedSchema( private val persistentNodeInfos: Set = emptySet() ) { constructor(partyAndCert: PartyAndCertificate, isMain: Boolean = false) - : this(partyAndCert.owningKey.encoded.sha256().toString(), partyAndCert.party.name.toString(), partyAndCert.serialize().bytes, isMain) + : this(partyAndCert.party.name.toString(), partyAndCert.party.owningKey.toBase58String(), partyAndCert.serialize().bytes, isMain) fun toLegalIdentityAndCert(): PartyAndCertificate { return partyCertBinary.deserialize() diff --git a/node/src/main/kotlin/net/corda/node/services/network/PersistentNetworkMapCache.kt b/node/src/main/kotlin/net/corda/node/services/network/PersistentNetworkMapCache.kt index a6dffc54c1..6f17e86b39 100644 --- a/node/src/main/kotlin/net/corda/node/services/network/PersistentNetworkMapCache.kt +++ b/node/src/main/kotlin/net/corda/node/services/network/PersistentNetworkMapCache.kt @@ -310,9 +310,9 @@ open class PersistentNetworkMapCache(private val serviceHub: ServiceHubInternal) private fun findByIdentityKey(session: Session, identityKey: PublicKey): List { val query = session.createQuery( - "SELECT n FROM ${NodeInfoSchemaV1.PersistentNodeInfo::class.java.name} n JOIN n.legalIdentitiesAndCerts l WHERE l.owningKeyHash = :owningKeyHash", + "SELECT n FROM ${NodeInfoSchemaV1.PersistentNodeInfo::class.java.name} n JOIN n.legalIdentitiesAndCerts l WHERE l.owningKey = :owningKey", NodeInfoSchemaV1.PersistentNodeInfo::class.java) - query.setParameter("owningKeyHash", SecureHash.sha256(identityKey.encoded).toString()) + query.setParameter("owningKey", identityKey.toBase58String()) return query.resultList }