mirror of
https://github.com/fluencelabs/registry.git
synced 2025-04-25 02:02:14 +00:00
57 lines
2.5 KiB
Plaintext
57 lines
2.5 KiB
Plaintext
import "registry-service.aqua"
|
|
import PeerId, Peer, Sig, SignResult from "@fluencelabs/aqua-lib/builtin.aqua"
|
|
import "@fluencelabs/trust-graph/trust-graph.aqua"
|
|
|
|
func getKeySignature(label: string, timestamp_created: u64) -> SignResult:
|
|
bytes <- Registry.get_key_bytes(label, nil, timestamp_created, nil, "")
|
|
on INIT_PEER_ID:
|
|
result <- Sig.sign(bytes)
|
|
<- result
|
|
|
|
func getRecordSignature(key_id: string, value: string, relay_id: ?PeerId, service_id: ?string, timestamp_created: u64) -> SignResult:
|
|
bytes <- Registry.get_record_bytes(key_id, value, relay_id, service_id, timestamp_created, nil)
|
|
on INIT_PEER_ID:
|
|
signature <- Sig.sign(bytes)
|
|
<- signature
|
|
|
|
func getHostRecordSignature(key_id: string, value: string, relay_id: ?PeerId, service_id: ?string, timestamp_created: u64) -> SignResult:
|
|
bytes <- Registry.get_host_record_bytes(key_id, value, relay_id, service_id, timestamp_created, nil)
|
|
on INIT_PEER_ID:
|
|
signature <- Sig.sign(bytes)
|
|
<- signature
|
|
|
|
func registerKey(label: string, timestamp_created: u64, signature: []u8) -> RegisterKeyResult:
|
|
t <- Peer.timestamp_sec()
|
|
weight <- TrustGraph.get_weight(%init_peer_id%, t)
|
|
result <- Registry.register_key(label, nil, timestamp_created, nil, "", signature, weight, t)
|
|
<- result
|
|
|
|
func putRecord(key_id: string, value: string, relay_id: ?PeerId, service_id: []string, timestamp_created: u64, signature: []u8) -> RegistryResult:
|
|
t <- Peer.timestamp_sec()
|
|
weight <- TrustGraph.get_weight(%init_peer_id%, t)
|
|
result <- Registry.put_record(key_id, value, relay_id, service_id, timestamp_created, nil, signature, weight, t)
|
|
<- result
|
|
|
|
func putHostRecord(key_id: string, value: string, relay_id: ?PeerId, service_id: []string, timestamp_created: u64, signature: []u8) -> PutHostRecordResult:
|
|
t <- Peer.timestamp_sec()
|
|
weight <- TrustGraph.get_weight(%init_peer_id%, t)
|
|
result <- Registry.put_host_record(key_id, value, relay_id, service_id, timestamp_created, nil, signature, weight, t)
|
|
<- result
|
|
|
|
func propagateHostRecord(res: PutHostRecordResult) -> RegistryResult:
|
|
t <- Peer.timestamp_sec()
|
|
weight <- TrustGraph.get_weight(res.record!.peer_id, t)
|
|
result <- Registry.propagate_host_record(res, t, weight)
|
|
<- result
|
|
|
|
func getKeyMetadata(key_id: string) -> GetKeyMetadataResult:
|
|
t <- Peer.timestamp_sec()
|
|
result <- Registry.get_key_metadata(key_id, t)
|
|
<- result
|
|
|
|
func republishKey(key: Key) -> RegistryResult:
|
|
t <- Peer.timestamp_sec()
|
|
weight <- TrustGraph.get_weight(key.owner_peer_id, t)
|
|
result <- Registry.republish_key(key, weight, t)
|
|
<- result
|