From 19f5d47add949f62085a022a01b84c83d3fc0389 Mon Sep 17 00:00:00 2001 From: InversionSpaces Date: Tue, 7 Nov 2023 16:29:43 +0100 Subject: [PATCH] feat(registry): Use streams instead of options [LNG-277] (#282) Use streams instead of options --- aqua/misc.aqua | 2 +- aqua/registry-api.aqua | 2 +- aqua/resources-api.aqua | 10 +++++----- aqua/subnetwork.aqua | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/aqua/misc.aqua b/aqua/misc.aqua index cfa692b..ac88355 100644 --- a/aqua/misc.aqua +++ b/aqua/misc.aqua @@ -37,7 +37,7 @@ func appendErrors(error1: *Error, error2: *Error): func getResourceHelper(resource_id: ResourceId) -> ?Resource, *Error: nodes <- getNeighbors(resource_id) - result: ?Resource + result: *Resource error: *Error resources: *Key diff --git a/aqua/registry-api.aqua b/aqua/registry-api.aqua index 4275121..9b593ea 100644 --- a/aqua/registry-api.aqua +++ b/aqua/registry-api.aqua @@ -15,7 +15,7 @@ func getRecordMetadata(key_id: string, value: string, peer_id: string, relay_id: on INIT_PEER_ID via HOST_PEER_ID: sig_result <- Sig.sign(bytes) - result: ?RecordMetadata + result: *RecordMetadata error: *string if sig_result.success == true: result <- Registry.create_record_metadata(key_id, INIT_PEER_ID, t, value, peer_id, relay_id, service_id, solution, sig_result.signature!) diff --git a/aqua/resources-api.aqua b/aqua/resources-api.aqua index 6721e57..c906cbf 100644 --- a/aqua/resources-api.aqua +++ b/aqua/resources-api.aqua @@ -24,7 +24,7 @@ func getResourceId(label: string, peer_id: string) -> ResourceId: func createResource(label: string) -> ?ResourceId, *Error: t <- Peer.timestamp_sec() - resource_id: ?ResourceId + resource_id: *ResourceId error: *Error on HOST_PEER_ID: sig_result <- getKeySignature(label, t) @@ -57,7 +57,7 @@ func createResource(label: string) -> ?ResourceId, *Error: -- Note: resource must be already created func registerService(resource_id: ResourceId, value: string, peer_id: PeerId, service_id: ?string) -> bool, *Error: - relay_id: ?string + relay_id: *string if peer_id == INIT_PEER_ID: relay_id <<- HOST_PEER_ID @@ -116,7 +116,7 @@ func registerService(resource_id: ResourceId, value: string, peer_id: PeerId, se func unregisterService(resource_id: ResourceId, peer_id: PeerId) -> bool, *Error: - success: ?bool + success: *bool error: *Error on HOST_PEER_ID: @@ -168,7 +168,7 @@ func unregisterService(resource_id: ResourceId, peer_id: PeerId) -> bool, *Error func resolveResource(resource_id: ResourceId, ack: i16) -> ?[]Record, *Error: on HOST_PEER_ID: nodes <- getNeighbors(resource_id) - result: ?[]Record + result: *[]Record records: *[]Record error: *Error successful: *bool @@ -197,7 +197,7 @@ func resolveResource(resource_id: ResourceId, ack: i16) -> ?[]Record, *Error: -- Execute the given call on providers -- Note that you can provide another Aqua function as an argument to this one func executeOnResource(resource_id: ResourceId, ack: i16, call: Record -> ()) -> bool, *Error: - success: ?bool + success: *bool result, error <- resolveResource(resource_id, ack) if result == nil: diff --git a/aqua/subnetwork.aqua b/aqua/subnetwork.aqua index 96967df..b794344 100644 --- a/aqua/subnetwork.aqua +++ b/aqua/subnetwork.aqua @@ -32,7 +32,7 @@ func registerSubnetworkKey(deal_id: string, peer_id: PeerId, timestamp_created: func createSubnetwork(deal_id: string) -> ?string, *Error: t <- Peer.timestamp_sec() - subnetwork_id: ?string + subnetwork_id: *string error: *Error on HOST_PEER_ID: peer_id <- getInsecuredPeerId() @@ -73,7 +73,7 @@ func getWorkerRecordMetadata(subnetwork_id: string) -> ?RecordMetadata, ?string: Sig "sig" sig_result <- Sig.sign(bytes) - result: ?RecordMetadata + result: *RecordMetadata error: *string if sig_result.success == true: result <- Registry.create_record_metadata(subnetwork_id, INIT_PEER_ID, t, "", INIT_PEER_ID, relay_id, nil, nil, sig_result.signature!) @@ -148,7 +148,7 @@ func registerWorker(subnetwork_id: string) -> bool, *Error: <- succ, error func resolveSubnetwork(deal_id: string) -> ?[]Record, *Error: - result: ?[]Record + result: *[]Record error: *Error on HOST_PEER_ID: peer_id <- getInsecuredPeerId()