From 6f71e2a66a61ef179656fe8ebbc803d54d06b024 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:30:25 +0200 Subject: [PATCH 01/24] fix blocks --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index c25d017..f8fe5c3 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -61,13 +61,13 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< rpc_module.register_method("blocks", move |params: Params, _| { task::block_on(async { // Parse the parameter containing the public key. - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; // Open the primary KV database for reading. let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let blocks = indexes.get_blocks(&pub_key.0)?; + let blocks = indexes.get_blocks(&pub_key[0])?; let response = json!(blocks); Ok::(response) From b2609b78941859056f43628e994a83f3bfba2545 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:33:35 +0200 Subject: [PATCH 02/24] fix blockers --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index f8fe5c3..f194e56 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -79,12 +79,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns an array of public keys. rpc_module.register_method("blockers", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let blockers = indexes.get_blockers(&pub_key.0)?; + let blockers = indexes.get_blockers(&pub_key[0])?; let response = json!(blockers); Ok::(response) From 0641df37e86ef6d088e79b59452186d76e1f4fc6 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:34:01 +0200 Subject: [PATCH 03/24] fix descriptions --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index f194e56..77d86eb 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -96,12 +96,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns an array of descriptions. rpc_module.register_method("descriptions", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let descriptions = indexes.get_descriptions(&pub_key.0)?; + let descriptions = indexes.get_descriptions(&pub_key[0])?; let response = json!(descriptions); Ok::(response) From 0e9d345d89607728d9b931d38d3b2b3d5a6c0121 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:34:26 +0200 Subject: [PATCH 04/24] fix self_descriptions --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index 77d86eb..edf2518 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -113,12 +113,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns an array of descriptions. rpc_module.register_method("self_descriptions", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let descriptions = indexes.get_self_assigned_descriptions(&pub_key.0)?; + let descriptions = indexes.get_self_assigned_descriptions(&pub_key[0])?; let response = json!(descriptions); Ok::(response) From 0341ac583886a5d768e86622af6755b25509d5ca Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:34:43 +0200 Subject: [PATCH 05/24] fix latest_descriptions --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index edf2518..ce0c5df 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -130,12 +130,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns a string. rpc_module.register_method("latest_description", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let description = indexes.get_latest_description(&pub_key.0)?; + let description = indexes.get_latest_description(&pub_key[0])?; let response = json!(description); Ok::(response) From dde2eb00c195f831a29a96fc05d536f8dad7860a Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:35:00 +0200 Subject: [PATCH 06/24] fix latest_self_descriptions --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index ce0c5df..ff6b853 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -148,12 +148,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns a string. rpc_module.register_method("latest_self_description", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let description = indexes.get_latest_self_assigned_description(&pub_key.0)?; + let description = indexes.get_latest_self_assigned_description(&pub_key[0])?; let response = json!(description); Ok::(response) From b90ef4a9bdb6d9307f16fff6edcb9b0756e07589 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:35:18 +0200 Subject: [PATCH 07/24] fix follows --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index ff6b853..b251efe 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -165,12 +165,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns an array of public keys. rpc_module.register_method("follows", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let follows = indexes.get_follows(&pub_key.0)?; + let follows = indexes.get_follows(&pub_key[0])?; let response = json!(follows); Ok::(response) From 0adfc441d59a0d1882d8612417d9bf3418393730 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:35:33 +0200 Subject: [PATCH 08/24] fix followers --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index b251efe..1052930 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -182,12 +182,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns an array of public keys. rpc_module.register_method("followers", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let followers = indexes.get_followers(&pub_key.0)?; + let followers = indexes.get_followers(&pub_key[0])?; let response = json!(followers); Ok::(response) From f395a6aab98187b0558109ea343acfe53a8f7fd3 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:42:35 +0200 Subject: [PATCH 09/24] fix is_following --- solar/src/actors/jsonrpc/server.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index 1052930..87eb971 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -17,13 +17,6 @@ use crate::{broker::*, error::Error, node::KV_STORE, Result}; #[derive(Debug, Deserialize)] struct Channel(String); -/// The public keys (ID) of two peers. -#[derive(Debug, Deserialize)] -struct IsFollowing { - peer_a: String, - peer_b: String, -} - /// Message reference containing the key (sha256 hash) of a message. /// Used to parse the key from the parameters supplied to the `message` /// endpoint. @@ -199,12 +192,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns a boolean. rpc_module.register_method("is_following", move |params: Params, _| { task::block_on(async { - let peers: IsFollowing = params.parse()?; + let peers = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let is_following = indexes.is_following(&peers.peer_a, &peers.peer_b)?; + let is_following = indexes.is_following(&peers[0], &peers[1])?; let response = json!(is_following); Ok::(response) From 94e41e2e3eed749614f7353c23f117e84466b7a1 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:43:16 +0200 Subject: [PATCH 10/24] fix friends --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index 87eb971..7bfe69a 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -210,12 +210,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns an array of public keys. rpc_module.register_method("friends", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let friends = indexes.get_friends(&pub_key.0)?; + let friends = indexes.get_friends(&pub_key[0])?; let response = json!(friends); Ok::(response) From 818bf7d58868df5d5c3e03f7b5d69d0f5216696c Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:43:36 +0200 Subject: [PATCH 11/24] fix images --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index 7bfe69a..9d3b78c 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -227,12 +227,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns an array of strings. rpc_module.register_method("images", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let images = indexes.get_images(&pub_key.0)?; + let images = indexes.get_images(&pub_key[0])?; let response = json!(images); Ok::(response) From a8761dd2e21e15501184fa7762e38248bee59145 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:43:53 +0200 Subject: [PATCH 12/24] fix self_images --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index 9d3b78c..f58c580 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -244,12 +244,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns an array of strings. rpc_module.register_method("self_images", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let images = indexes.get_self_assigned_images(&pub_key.0)?; + let images = indexes.get_self_assigned_images(&pub_key[0])?; let response = json!(images); Ok::(response) From 447317665cef1ec71d57505521a29d362d35c530 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:44:14 +0200 Subject: [PATCH 13/24] fix latest_image --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index f58c580..92a5d9e 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -261,12 +261,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns a string. rpc_module.register_method("latest_image", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let image = indexes.get_latest_image(&pub_key.0)?; + let image = indexes.get_latest_image(&pub_key[0])?; let response = json!(image); Ok::(response) From 62856b9f8107edec3514f53e34a7f81e9f025b84 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:44:33 +0200 Subject: [PATCH 14/24] fix latest_self_image --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index 92a5d9e..af4e5c1 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -279,12 +279,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns an array of strings. rpc_module.register_method("latest_self_image", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let image = indexes.get_latest_self_assigned_image(&pub_key.0)?; + let image = indexes.get_latest_self_assigned_image(&pub_key[0])?; let response = json!(image); Ok::(response) From d7767f5ea21883f08d9fc20cdcfc2ad9b7f0c46c Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:44:54 +0200 Subject: [PATCH 15/24] fix names --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index af4e5c1..b58f567 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -296,12 +296,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns an array of strings. rpc_module.register_method("names", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let names = indexes.get_names(&pub_key.0)?; + let names = indexes.get_names(&pub_key[0])?; let response = json!(names); Ok::(response) From 04912b4c2b5cd9bf2a0547dd663db92dd5c0ea16 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:45:13 +0200 Subject: [PATCH 16/24] fix self_names --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index b58f567..748e0c0 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -313,12 +313,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns an array of strings. rpc_module.register_method("self_names", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let names = indexes.get_self_assigned_names(&pub_key.0)?; + let names = indexes.get_self_assigned_names(&pub_key[0])?; let response = json!(names); Ok::(response) From f8ee7d5fb6844b8862c5aa5eea46e0981716bb50 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:45:34 +0200 Subject: [PATCH 17/24] fix latest_name --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index 748e0c0..dea1763 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -330,12 +330,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns a string. rpc_module.register_method("latest_name", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let names = indexes.get_latest_name(&pub_key.0)?; + let names = indexes.get_latest_name(&pub_key[0])?; let response = json!(names); Ok::(response) From 509e34b9faa2518bf2adbd781e4c21ee96f1e9dd Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:45:52 +0200 Subject: [PATCH 18/24] fix latest_self_name --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index dea1763..be52779 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -347,12 +347,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns a string. rpc_module.register_method("latest_self_name", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let names = indexes.get_latest_self_assigned_name(&pub_key.0)?; + let names = indexes.get_latest_self_assigned_name(&pub_key[0])?; let response = json!(names); Ok::(response) From 354daeabddefcdf36ae3c44457096bdfef18c009 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:46:34 +0200 Subject: [PATCH 19/24] fix subscribers --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index be52779..b891be9 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -364,12 +364,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns an array of public keys. rpc_module.register_method("subscribers", move |params: Params, _| { task::block_on(async { - let channel: Channel = params.parse()?; + let channel = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let subscribers = indexes.get_channel_subscribers(&channel.0)?; + let subscribers = indexes.get_channel_subscribers(&channel[0])?; let response = json!(subscribers); Ok::(response) From 0eb5c07df867f1e3f127e6262dc6917e4efac729 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:47:00 +0200 Subject: [PATCH 20/24] fix subscriptions --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index b891be9..335b673 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -381,12 +381,12 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< // Returns an array of channel names. rpc_module.register_method("subscriptions", move |params: Params, _| { task::block_on(async { - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; let db = KV_STORE.read().await; let indexes = &db.indexes.as_ref().ok_or(Error::Indexes)?; - let subscriptions = indexes.get_channel_subscriptions(&pub_key.0)?; + let subscriptions = indexes.get_channel_subscriptions(&pub_key[0])?; let response = json!(subscriptions); Ok::(response) From 508b799df6dcf0153ec6c27126953a67f818ee09 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:47:20 +0200 Subject: [PATCH 21/24] fix feed --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index 335b673..a1f9306 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -398,13 +398,13 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< rpc_module.register_method("feed", move |params: Params, _| { task::block_on(async { // Parse the parameter containing the public key. - let pub_key: PubKey = params.parse()?; + let pub_key = params.parse::>()?; // Open the primary KV database for reading. let db = KV_STORE.read().await; // Retrieve the message value for the requested message. - let feed = db.get_feed(&pub_key.0)?; + let feed = db.get_feed(&pub_key[0])?; let response = json!(feed); Ok::(response) From 048b83ba6cf3b3028cb94738bdde7a68e6507497 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:47:47 +0200 Subject: [PATCH 22/24] fix message --- solar/src/actors/jsonrpc/server.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index a1f9306..2baa2bf 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -416,13 +416,13 @@ pub async fn actor(server_id: OwnedIdentity, server_addr: SocketAddr) -> Result< rpc_module.register_method("message", move |params: Params, _| { task::block_on(async { // Parse the parameter containing the message reference (key). - let msg_ref: MsgRef = params.parse()?; + let msg_ref = params.parse::>()?; // Open the primary KV database for reading. let db = KV_STORE.read().await; // Retrieve the message value for the requested message. - let msg_val = db.get_msg_val(&msg_ref.0)?; + let msg_val = db.get_msg_val(&msg_ref[0])?; // Retrieve the message KVT for the requested message using the // author and sequence fields from the message value. From e8f535f030c89453677dd3b6d514bf23b663bc36 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:52:08 +0200 Subject: [PATCH 23/24] remove unnecessary structs --- solar/src/actors/jsonrpc/server.rs | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/solar/src/actors/jsonrpc/server.rs b/solar/src/actors/jsonrpc/server.rs index 2baa2bf..c882723 100644 --- a/solar/src/actors/jsonrpc/server.rs +++ b/solar/src/actors/jsonrpc/server.rs @@ -8,25 +8,10 @@ use jsonrpsee::server::{logger::Params, RpcModule, ServerBuilder}; use jsonrpsee::types::error::ErrorObject as JsonRpcError; use kuska_ssb::{api::dto::content::TypedMessage, feed::Message, keystore::OwnedIdentity}; use log::{info, warn}; -use serde::Deserialize; use serde_json::{json, Value}; use crate::{broker::*, error::Error, node::KV_STORE, Result}; -/// The name of a channel. -#[derive(Debug, Deserialize)] -struct Channel(String); - -/// Message reference containing the key (sha256 hash) of a message. -/// Used to parse the key from the parameters supplied to the `message` -/// endpoint. -#[derive(Debug, Deserialize)] -struct MsgRef(String); - -/// The public key (ID) of a peer. -#[derive(Debug, Deserialize)] -struct PubKey(String); - /// Register the JSON-RPC server endpoint, define the JSON-RPC methods /// and spawn the server. /// From e588476f6488aa88948fe95057ccc7f8a01f62e8 Mon Sep 17 00:00:00 2001 From: mycognosist Date: Mon, 12 Feb 2024 12:56:57 +0200 Subject: [PATCH 24/24] update the api docs --- README.md | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 1bd9b09..72aa4f7 100644 --- a/README.md +++ b/README.md @@ -132,31 +132,31 @@ While running, a solar node can be queried using JSON-RPC over HTTP. | Method | Parameters | Response | Description | | --- | --- | --- | --- | -| `blocks` | `"<@...=.ed25519>"` | `[<@...=.ed25519>]` | Returns an array of public keys | -| `blockers` | `"<@...=.ed25519>"` | `[<@...=.ed25519>]` | Returns an array of public keys | -| `descriptions` | `"<@...=.ed25519>"` | `[]` | Returns an array of descriptions | -| `self_descriptions` | `"<@...=.ed25519>"` | `[]` | Returns an array of descriptions | -| `latest_description` | `"<@...=.ed25519>"` | `` | Returns a single description | -| `latest_self_description` | `"<@...=.ed25519>"` | `` | Returns a single description | -| `feed` | `"<@...=.ed25519>"` | `[{ "key": "<%...=.sha256>", "value": , "timestamp": , "rts": null }]` | Returns an array of message KVTs (key, value, timestamp) from the local database | -| `follows` | `"<@...=.ed25519>"` | `[<@...=.ed25519>]` | Returns an array of public keys | -| `followers` | `"<@...=.ed25519>"` | `[<@...=.ed25519>]` | Returns an array of public keys | -| `is_following` | `{ "peer_a": "<@...=.ed25519>", "peer_b": "<@...=.ed25519>" }` | `[<@...=.ed25519>]` | Returns a boolean | -| `friends` | `"<@...=.ed25519>"` | `[<@...=.ed25519>]` | Returns an array of public keys | -| `images` | `"<@...=.ed25519>"` | `[<&...=.sha256>]` | Returns an array of image references | -| `self_images` | `"<@...=.ed25519>"` | `[<&...=.sha256>]` | Returns an array of image references | -| `latest_image` | `"<@...=.ed25519>"` | `<&...=.sha256>` | Returns a single image reference | -| `latest_self_image` | `"<@...=.ed25519>"` | `<&...=.sha256>` | Returns a single image reference | -| `message` | `"<%...=.sha256>"` | `{ "key": "<%...=.sha256>", "value": , "timestamp": , "rts": null }` | Returns a single message KVT (key, value, timestamp) from the local database | -| `names` | `"<@...=.ed25519>"` | `[]` | Returns an array of names | -| `self_names` | `"<@...=.ed25519>"` | `[]` | Returns an array of names | -| `latest_name` | `"<@...=.ed25519>"` | `` | Returns a single name | -| `latest_self_name` | `"<@...=.ed25519>"` | `` | Returns a single name | +| `blocks` | `["<@...=.ed25519>"]` | `[<@...=.ed25519>]` | Returns an array of public keys | +| `blockers` | `["<@...=.ed25519>"]` | `[<@...=.ed25519>]` | Returns an array of public keys | +| `descriptions` | `["<@...=.ed25519>"]` | `[]` | Returns an array of descriptions | +| `self_descriptions` | `["<@...=.ed25519>"]` | `[]` | Returns an array of descriptions | +| `latest_description` | `["<@...=.ed25519>"]` | `` | Returns a single description | +| `latest_self_description` | `["<@...=.ed25519>"]` | `` | Returns a single description | +| `feed` | `["<@...=.ed25519>"]` | `[{ "key": "<%...=.sha256>", "value": , "timestamp": , "rts": null }]` | Returns an array of message KVTs (key, value, timestamp) from the local database | +| `follows` | `["<@...=.ed25519>"]` | `[<@...=.ed25519>]` | Returns an array of public keys | +| `followers` | `["<@...=.ed25519>"]` | `[<@...=.ed25519>]` | Returns an array of public keys | +| `is_following` | `["<@...=.ed25519>", "<@...=.ed25519>"]` | `` | Returns a boolean | +| `friends` | `["<@...=.ed25519>"]` | `[<@...=.ed25519>]` | Returns an array of public keys | +| `images` | `["<@...=.ed25519>"]` | `[<&...=.sha256>]` | Returns an array of image references | +| `self_images` | `["<@...=.ed25519>"]` | `[<&...=.sha256>]` | Returns an array of image references | +| `latest_image` | `["<@...=.ed25519>"]` | `<&...=.sha256>` | Returns a single image reference | +| `latest_self_image` | `["<@...=.ed25519>"]` | `<&...=.sha256>` | Returns a single image reference | +| `message` | `["<%...=.sha256>"]` | `{ "key": "<%...=.sha256>", "value": , "timestamp": , "rts": null }` | Returns a single message KVT (key, value, timestamp) from the local database | +| `names` | `["<@...=.ed25519>"]` | `[]` | Returns an array of names | +| `self_names` | `["<@...=.ed25519>"]` | `[]` | Returns an array of names | +| `latest_name` | `["<@...=.ed25519>"]` | `` | Returns a single name | +| `latest_self_name` | `["<@...=.ed25519>"]` | `` | Returns a single name | | `peers` | | `[{ "pub_key": "<@...=.ed25519>", "seq_num": }` | Returns an array of public key and latest sequence number for each peer in the local database | | `ping` | | `pong!` | Responds if the JSON-RPC server is running | | `publish` | `` | `{ "msg_ref": "<%...=.sha256>", "seq_num": }` | Publishes a message and returns the reference (message hash) and sequence number | -| `subscribers` | `""` | `[<@...=.ed25519>]` | Returns an array of public keys | -| `subscriptions` | `"<@...=.ed25519>"` | `[]` | Returns an array of channel names | +| `subscribers` | `[""]` | `[<@...=.ed25519>]` | Returns an array of public keys | +| `subscriptions` | `["<@...=.ed25519>"]` | `[]` | Returns an array of channel names | | `whoami` | | `<@...=.ed25519>` | Returns the public key of the local node | ### Examples