mirror of
https://github.com/corda/corda.git
synced 2025-02-27 03:27:34 +00:00
Revert DBPartyAndCertificate change: PK should be party name (not owningKeyHash).
This commit is contained in:
parent
72ad9a51fe
commit
cda3ecbc0a
@ -1,11 +1,11 @@
|
|||||||
package net.corda.core.schemas
|
package net.corda.core.schemas
|
||||||
|
|
||||||
import net.corda.core.crypto.sha256
|
|
||||||
import net.corda.core.identity.PartyAndCertificate
|
import net.corda.core.identity.PartyAndCertificate
|
||||||
import net.corda.core.node.NodeInfo
|
import net.corda.core.node.NodeInfo
|
||||||
import net.corda.core.serialization.deserialize
|
import net.corda.core.serialization.deserialize
|
||||||
import net.corda.core.serialization.serialize
|
import net.corda.core.serialization.serialize
|
||||||
import net.corda.core.utilities.NetworkHostAndPort
|
import net.corda.core.utilities.NetworkHostAndPort
|
||||||
|
import net.corda.core.utilities.toBase58String
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
import javax.persistence.*
|
import javax.persistence.*
|
||||||
|
|
||||||
@ -85,13 +85,12 @@ object NodeInfoSchemaV1 : MappedSchema(
|
|||||||
@Table(name = "node_info_party_cert")
|
@Table(name = "node_info_party_cert")
|
||||||
data class DBPartyAndCertificate(
|
data class DBPartyAndCertificate(
|
||||||
@Id
|
@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)
|
@Column(name = "party_name", nullable = false)
|
||||||
val name: String,
|
val name: String,
|
||||||
|
|
||||||
|
@Column(name = "owning_key", length = 65535, nullable = false)
|
||||||
|
val owningKey: String,
|
||||||
|
|
||||||
@Column(name = "party_cert_binary")
|
@Column(name = "party_cert_binary")
|
||||||
@Lob
|
@Lob
|
||||||
val partyCertBinary: ByteArray,
|
val partyCertBinary: ByteArray,
|
||||||
@ -102,7 +101,7 @@ object NodeInfoSchemaV1 : MappedSchema(
|
|||||||
private val persistentNodeInfos: Set<PersistentNodeInfo> = emptySet()
|
private val persistentNodeInfos: Set<PersistentNodeInfo> = emptySet()
|
||||||
) {
|
) {
|
||||||
constructor(partyAndCert: PartyAndCertificate, isMain: Boolean = false)
|
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 {
|
fun toLegalIdentityAndCert(): PartyAndCertificate {
|
||||||
return partyCertBinary.deserialize()
|
return partyCertBinary.deserialize()
|
||||||
|
@ -310,9 +310,9 @@ open class PersistentNetworkMapCache(private val serviceHub: ServiceHubInternal)
|
|||||||
|
|
||||||
private fun findByIdentityKey(session: Session, identityKey: PublicKey): List<NodeInfoSchemaV1.PersistentNodeInfo> {
|
private fun findByIdentityKey(session: Session, identityKey: PublicKey): List<NodeInfoSchemaV1.PersistentNodeInfo> {
|
||||||
val query = session.createQuery(
|
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)
|
NodeInfoSchemaV1.PersistentNodeInfo::class.java)
|
||||||
query.setParameter("owningKeyHash", SecureHash.sha256(identityKey.encoded).toString())
|
query.setParameter("owningKey", identityKey.toBase58String())
|
||||||
return query.resultList
|
return query.resultList
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user