Why Nostr? What is Njump?
2024-07-03 00:50:47

npub1tf…3ylra on Nostr: commit 3f7e3014310a0c6e2cdc2f5d5913c064f65e89b0 Author: randymcmillan ...

commit 3f7e3014310a0c6e2cdc2f5d5913c064f65e89b0
Author: randymcmillan <[email protected]>
Date: Sat May 4 21:15:39 2024 -0400

make:test-loop-back:test-gnostr-fetch-watch-list-iterator

diff --git a/bins/GNUmakefile b/bins/GNUmakefile
index e6f006089..67f78ac80 100755
--- a/bins/GNUmakefile
+++ b/bins/GNUmakefile
@@ -47,6 +47,12 @@ cargo-i:## cargo-i
cargo-publish:## cargo publish
cargo publish --registry crates-io

+test-loop-back:## test-loop-back
+ gnostr-fetch-metadata wss://relay.damus.io a34b99f22c790c4e36b2b3c2c35a36db06226e41c692fc82b8b56ac1c540c5bd | gnostr-post-event
+test-gnostr-fetch-watch-list:## test-gnostr-fetch-watch-list
+ for relay in $$(gnostr-fetch-watch-list); do echo $$relay;done
+test-gnostr-fetch-watch-list-interator:## test-gnostr-fetch-watch-list-interator
+ for relay in $$(gnostr-fetch-watch-list-iterator); do echo $$relay;done
test-gnostr-post-duplicate:## test-gnostr-post-duplicate
@[ -x $(shell which cat) ] && \
cat tests/event.ab0d7c747e0d6651814f8092287f9a58c9cc7a48ce700e2cf743c082577f7850 | gnostr-post-event --relay wss://relay.damus.io
diff --git a/bins/src/bin/gnostr-fetch-watch-list-iterator.rs b/bins/src/bin/gnostr-fetch-watch-list-iterator.rs
index d2520692f..272d6d22e 100644
--- a/bins/src/bin/gnostr-fetch-watch-list-iterator.rs
+++ b/bins/src/bin/gnostr-fetch-watch-list-iterator.rs
@@ -1,5 +1,6 @@
use futures::executor::block_on;
use url::Url;
+use gnostr_bins::watch_list;
async fn parse_urls(urls_str: &str) -> Result<Vec<String>, url::ParseError> {
let mut urls: Vec<String> = Vec::new();
let mut part = String::new();
diff --git a/bins/src/lib.rs b/bins/src/lib.rs
index a403b2310..04527556a 100644
--- a/bins/src/lib.rs
+++ b/bins/src/lib.rs
@@ -46,6 +46,14 @@ pub use relays::relays_offline;
pub use relays::relays_online;
pub use relays::relays_paid;
pub use relays::relays_public;
+use futures::executor::block_on;
+pub mod watch_list;
+pub use watch_list::*;
+pub async fn watch_list() -> Result<Vec<String>, url::ParseError> {
+ let future = watch_list(); // Nothing is printed
+ let list = block_on(future);
+ Ok(list.unwrap())
+}

pub fn strip_trailing_nl(input: &mut String) {
let new_len = input
diff --git a/bins/src/bin/gnostr-fetch-watch-list-iterator.rs b/bins/src/watch_list.rs
similarity index 68%
copy from bins/src/bin/gnostr-fetch-watch-list-iterator.rs
copy to bins/src/watch_list.rs
index d2520692f..381548381 100644
--- a/bins/src/bin/gnostr-fetch-watch-list-iterator.rs
+++ b/bins/src/watch_list.rs
@@ -1,6 +1,7 @@
use futures::executor::block_on;
use url::Url;
-async fn parse_urls(urls_str: &str) -> Result<Vec<String>, url::ParseError> {
+use crate::get_relays_public;
+pub async fn parse_urls(urls_str: &str) -> Result<Vec<String>, url::ParseError> {
let mut urls: Vec<String> = Vec::new();
let mut part = String::new();
let mut collected = Vec::new();
@@ -26,10 +27,11 @@ async fn parse_urls(urls_str: &str) -> Result<Vec<String>, url::ParseError> {
Ok(urls)
}

-async fn print_relay_list() {
- let vec_relay_list = parse_urls(&gnostr_bins::get_relays_public().unwrap().as_str()).await;
-}
-fn main() {
- let future = print_relay_list(); // Nothing is printed
- block_on(future);
+pub async fn watch_list() {
+ let vec_relay_list = parse_urls(&get_relays_public().unwrap().as_str()).await;
}
+//pub async fn watch_list() -> Result<Vec<String>, url::ParseError> {
+// let future = watch_list(); // Nothing is printed
+// let list = block_on(future);
+// Ok(list)
+//}
Author Public Key
npub1tf8l90an2h8pn6ywuyhemyrwrsd0eactclsnu5trhemm64qfa76qu3ylra