Updated DB schemas from using string'ified key to use hash of key.

This commit is contained in:
josecoll
2017-10-16 17:23:12 +01:00
parent 20e0e63eed
commit 0e5346caa1
4 changed files with 21 additions and 20 deletions

View File

@ -1,11 +1,11 @@
package net.corda.core.schemas
import net.corda.core.crypto.SecureHash
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,8 +85,8 @@ object NodeInfoSchemaV1 : MappedSchema(
@Table(name = "node_info_party_cert")
data class DBPartyAndCertificate(
@Id
@Column(name = "owning_key", length = 65535, nullable = false)
val owningKey: String,
@Column(name = "owning_key_hash")
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)
@ -102,10 +102,10 @@ object NodeInfoSchemaV1 : MappedSchema(
private val persistentNodeInfos: Set<PersistentNodeInfo> = emptySet()
) {
constructor(partyAndCert: PartyAndCertificate, isMain: Boolean = false)
: this(partyAndCert.party.owningKey.toBase58String(), partyAndCert.party.name.toString(), partyAndCert.serialize().bytes, isMain)
: this(SecureHash.sha256(partyAndCert.owningKey.encoded).toString(), partyAndCert.party.name.toString(), partyAndCert.serialize().bytes, isMain)
fun toLegalIdentityAndCert(): PartyAndCertificate {
return partyCertBinary.deserialize<PartyAndCertificate>()
return partyCertBinary.deserialize()
}
}
}