mirror of
https://github.com/corda/corda.git
synced 2025-01-28 15:14:48 +00:00
Change string of PublicKey to hash as database primary key.
This commit is contained in:
parent
571c1ff31f
commit
20e0e63eed
@ -1,6 +1,6 @@
|
|||||||
package net.corda.node.services.network
|
package net.corda.node.services.network
|
||||||
|
|
||||||
import net.corda.core.utilities.toBase58String
|
import net.corda.core.crypto.SecureHash
|
||||||
import net.corda.core.identity.PartyAndCertificate
|
import net.corda.core.identity.PartyAndCertificate
|
||||||
import net.corda.core.internal.ThreadBox
|
import net.corda.core.internal.ThreadBox
|
||||||
import net.corda.core.messaging.SingleMessageRecipient
|
import net.corda.core.messaging.SingleMessageRecipient
|
||||||
@ -31,8 +31,8 @@ class PersistentNetworkMapService(network: MessagingService, networkMapCache: Ne
|
|||||||
@Entity
|
@Entity
|
||||||
@Table(name = "${NODE_DATABASE_PREFIX}network_map_nodes")
|
@Table(name = "${NODE_DATABASE_PREFIX}network_map_nodes")
|
||||||
class NetworkNode(
|
class NetworkNode(
|
||||||
@Id @Column(name = "node_party_key")
|
@Id @Column(name = "node_party_key_hash")
|
||||||
var publicKey: String = "",
|
var publicKeyHash: String = "",
|
||||||
|
|
||||||
@Column
|
@Column
|
||||||
var nodeParty: NodeParty = NodeParty(),
|
var nodeParty: NodeParty = NodeParty(),
|
||||||
@ -58,14 +58,14 @@ class PersistentNetworkMapService(network: MessagingService, networkMapCache: Ne
|
|||||||
|
|
||||||
fun createNetworkNodesMap(): PersistentMap<PartyAndCertificate, NodeRegistrationInfo, NetworkNode, String> {
|
fun createNetworkNodesMap(): PersistentMap<PartyAndCertificate, NodeRegistrationInfo, NetworkNode, String> {
|
||||||
return PersistentMap(
|
return PersistentMap(
|
||||||
toPersistentEntityKey = { it.owningKey.toBase58String() },
|
toPersistentEntityKey = { SecureHash.sha256(it.owningKey.encoded).toString() },
|
||||||
fromPersistentEntity = {
|
fromPersistentEntity = {
|
||||||
Pair(PartyAndCertificate(factory.generateCertPath(ByteArrayInputStream(it.nodeParty.certPath))),
|
Pair(PartyAndCertificate(factory.generateCertPath(ByteArrayInputStream(it.nodeParty.certPath))),
|
||||||
it.registrationInfo.deserialize(context = SerializationDefaults.STORAGE_CONTEXT))
|
it.registrationInfo.deserialize(context = SerializationDefaults.STORAGE_CONTEXT))
|
||||||
},
|
},
|
||||||
toPersistentEntity = { key: PartyAndCertificate, value: NodeRegistrationInfo ->
|
toPersistentEntity = { key: PartyAndCertificate, value: NodeRegistrationInfo ->
|
||||||
NetworkNode(
|
NetworkNode(
|
||||||
publicKey = key.owningKey.toBase58String(),
|
publicKeyHash = SecureHash.sha256(key.owningKey.encoded).toString(),
|
||||||
nodeParty = NodeParty(
|
nodeParty = NodeParty(
|
||||||
key.name.toString(),
|
key.name.toString(),
|
||||||
key.certificate.encoded,
|
key.certificate.encoded,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user