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

npub19w…8d5rr on Nostr: commit 2846dad5a7f5c17e347efc589ba96dd8e1387f55 Author: randymcmillan ...

commit 2846dad5a7f5c17e347efc589ba96dd8e1387f55
Author: randymcmillan <[email protected]>
Date: Sun May 5 22:43:36 2024 -0400

bins:apply cargo fmt

diff --git a/bins/src/blockheight.rs b/bins/src/blockheight.rs
index be4980a78..f6e78b6f6 100644
--- a/bins/src/blockheight.rs
+++ b/bins/src/blockheight.rs
@@ -1,7 +1,8 @@
-use reqwest::Url;
use std::io::Read;
use std::time::SystemTime;

+use reqwest::Url;
+
pub fn check_curl() {

//println!("check_curl");
diff --git a/bins/src/gitminer.rs b/bins/src/gitminer.rs
index 32cc8d901..6c5b591e6 100644
--- a/bins/src/gitminer.rs
+++ b/bins/src/gitminer.rs
@@ -1,12 +1,13 @@
-use super::worker::Worker;
-use git2::Repository;
use std::fs::File;
use std::io::Write;
use std::path::Path;
-use std::process;
use std::process::Command;
use std::sync::mpsc::channel;
-use std::thread;
+use std::{process, thread};
+
+use git2::Repository;
+
+use super::worker::Worker;

pub struct Options {
pub threads: u32,
@@ -127,14 +128,19 @@ impl Gitminer {
//write the blob
let _ = Command::new("sh")
.arg("-c")
- .arg(format!("cd {} && mkdir -p .gnostr && touch -f .gnostr/blobs/{} && git show {} > .gnostr/blobs/{}", self.opts.repo, hash, hash, hash))
+ .arg(format!(
+ "cd {} && mkdir -p .gnostr && touch -f .gnostr/blobs/{} && git show {} > \
+ .gnostr/blobs/{}",
+ self.opts.repo, hash, hash, hash
+ ))
.output();
//.ok()
//.expect("Failed to write .gnostr/blobs/<hash>");

//REF:
- //gnostr-git reflog --format='wss://{RELAY}/{REPO}/%C(auto)%H/%<|(17)%gd:commit:%s'
- //gnostr-git-reflog -f
+ //gnostr-git reflog
+ // --format='wss://{RELAY}/{REPO}/%C(auto)%H/%<|(17)%gd:commit:%s'
+ // gnostr-git-reflog -f
//write the reflog
//the new reflog is associated with a commit
//we will use gnostr-git-reflog -f
@@ -144,19 +150,30 @@ impl Gitminer {

//gnostr-git update-index --assume-unchanged .gnostr/reflog
//--[no-]assume-unchanged
- //When this flag is specified, the object names recorded for the paths are not updated. Instead, this option sets/unsets the "assume unchanged" bit for the paths. When the "assume unchanged" bit is on, the user promises not to change the file and allows Git to assume that the working tree file matches what is recorded in the index. If you want to change the working tree file, you need to unset the bit to tell Git. This is sometimes helpful when working with a big project on a filesystem that has very slow lstat(2) system call (e.g. cifs).
+ //When this flag is specified, the object names recorded for the paths are not
+ // updated. Instead, this option sets/unsets the "assume unchanged" bit for the
+ // paths. When the "assume unchanged" bit is on, the user promises not to change
+ // the file and allows Git to assume that the working tree file matches what is
+ // recorded in the index. If you want to change the working tree file, you need
+ // to unset the bit to tell Git. This is sometimes helpful when working with a
+ // big project on a filesystem that has very slow lstat(2) system call (e.g.
+ // cifs).
//
- //Git will fail (gracefully) in case it needs to modify this file in the index e.g. when merging in a commit; thus, in case the assumed-untracked file is changed upstream, you will need to handle the situation manually.
+ //Git will fail (gracefully) in case it needs to modify this file in the index
+ // e.g. when merging in a commit; thus, in case the assumed-untracked file is
+ // changed upstream, you will need to handle the situation manually.

//let _ = Command::new("sh")
// .arg("-c")
- // .arg(format!("cd {} && mkdir -p .gnostr && touch -f .gnostr/reflog && git reflog --format='wss://{}/{}/%C(auto)%H/%<|(17)%gd:commit:%s' > .gnostr/reflog", self.opts.repo, "{RELAY}", "{REPO}"))
- // .output();
+ // .arg(format!("cd {} && mkdir -p .gnostr && touch -f .gnostr/reflog && git
+ // reflog --format='wss://{}/{}/%C(auto)%H/%<|(17)%gd:commit:%s' >
+ // .gnostr/reflog", self.opts.repo, "{RELAY}", "{REPO}")) .output();
////.ok()
////.expect("Failed to write .gnostr/reflog");
//let _ = Command::new("sh")
// .arg("-c")
- // .arg(format!("cd {} && mkdir -p .gnostr && touch -f .gnostr/reflog && git update-index --assume-unchaged .gnostr/reflog", self.opts.repo))
+ // .arg(format!("cd {} && mkdir -p .gnostr && touch -f .gnostr/reflog && git
+ // update-index --assume-unchaged .gnostr/reflog", self.opts.repo))
// .output();
//.ok()
//.expect("Failed to write .gnostr/reflog");
diff --git a/bins/src/internal.rs b/bins/src/internal.rs
index e8bb4623f..af7622e17 100644
--- a/bins/src/internal.rs
+++ b/bins/src/internal.rs
@@ -1,8 +1,8 @@
use base64::Engine;
use gnostr_types::RelayMessageV3;
-use http::Uri;
//use nostr_types::RelayMessageV3;
use gnostr_types::{ClientMessage, Event, Filter, RelayMessage, SubscriptionId};
+use http::Uri;
use tungstenite::protocol::Message;

pub(crate) fn filters_to_wire(filters: Vec<Filter>) -> String {
diff --git a/bins/src/lib.rs b/bins/src/lib.rs
index 04527556a..62d4739c8 100644
--- a/bins/src/lib.rs
+++ b/bins/src/lib.rs
@@ -5,10 +5,9 @@ mod internal;
use internal::*;

mod reflog_simple;
-use crate::reflog_simple::pwd;
-use crate::reflog_simple::ref_hash_list;
-use crate::reflog_simple::ref_hash_list_padded;
-use crate::reflog_simple::ref_hash_list_w_commit_message;
+use crate::reflog_simple::{
+ pwd, ref_hash_list, ref_hash_list_padded, ref_hash_list_w_commit_message,
+};

pub mod weeble;
pub use weeble::weeble;
@@ -41,12 +40,8 @@ pub use worker::*;
/// Offline Relays: https://api.nostr.watch/v1/offline
/// Relays by supported NIP: https://api.nostr.watch/v1/nip/X Use NIP ids without leading zeros - for example: https://api.nostr.watch/v1/nip/1
pub mod relays;
-pub use relays::relays;
-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 use relays::{relays, relays_offline, relays_online, relays_paid, relays_public};
pub mod watch_list;
pub use watch_list::*;
pub async fn watch_list() -> Result<Vec<String>, url::ParseError> {
@@ -173,10 +168,11 @@ pub fn print_event(event: &Event) {
serde_json::to_string(event).expect("Cannot serialize event to JSON")
);
}
-use sha256::digest;
use std::error::Error;
use std::process;

+use sha256::digest;
+
pub struct Config {
pub query: String,
}
diff --git a/bins/src/reflog_simple.rs b/bins/src/reflog_simple.rs
index ae2803574..7c5576b15 100644
--- a/bins/src/reflog_simple.rs
+++ b/bins/src/reflog_simple.rs
@@ -1,6 +1,7 @@
+use std::process::Command;
+
use ascii::AsciiChar;
use git2::Repository;
-use std::process::Command;

pub fn strip_trailing_nl(input: &mut String) {
let new_len = input
diff --git a/bins/src/relays.rs b/bins/src/relays.rs
index 99cb8e14e..24634f66c 100644
--- a/bins/src/relays.rs
+++ b/bins/src/relays.rs
@@ -1,6 +1,7 @@
-use reqwest::Url;
use std::io::Read;

+use reqwest::Url;
+
pub fn relays() -> Result<String, ascii::AsciiChar> {
let url = Url::parse("https://api.nostr.watch/v1/online";).unwrap();
let mut res = reqwest::blocking::get(url).unwrap();
diff --git a/bins/src/repo.rs b/bins/src/repo.rs
index a3ac0d997..0fdb56a91 100644
--- a/bins/src/repo.rs
+++ b/bins/src/repo.rs
@@ -1,8 +1,8 @@
extern crate git2;
-use git2::Repository;
-use git2::RepositoryState;
use std::process::Command;

+use git2::{Repository, RepositoryState};
+
pub trait ToString {
fn to_string(&self) -> String;
}
diff --git a/bins/src/watch_list.rs b/bins/src/watch_list.rs
index a3ebd5dbe..76982282a 100644
--- a/bins/src/watch_list.rs
+++ b/bins/src/watch_list.rs
@@ -1,5 +1,6 @@
use futures::executor::block_on;
use url::Url;
+
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();
@@ -16,7 +17,7 @@ pub async fn parse_urls(urls_str: &str) -> Result<Vec<String>, url::ParseError>
Some(',') | Some(' ') => {
if !part.is_empty() {
collected.push(part.clone());
- print!("{}\n", format!("{}",part.clone().replace("\"", "")));
+ print!("{}\n", format!("{}", part.clone().replace("\"", "")));
part = String::new();
}
}
@@ -29,5 +30,5 @@ pub async fn parse_urls(urls_str: &str) -> Result<Vec<String>, url::ParseError>

pub async fn print_watch_list() -> Result<Vec<String>, url::ParseError> {
let vec_relay_list = parse_urls(&get_relays_public().unwrap().as_str()).await;
- vec_relay_list//.expect("REASON")
+ vec_relay_list //.expect("REASON")
}
diff --git a/bins/src/weeble.rs b/bins/src/weeble.rs
index d0461af46..de9be34ec 100644
--- a/bins/src/weeble.rs
+++ b/bins/src/weeble.rs
@@ -1,7 +1,8 @@
-use reqwest::Url;
use std::io::Read;
use std::time::SystemTime;

+use reqwest::Url;
+
pub fn weeble() -> Result<f64, ascii::AsciiChar> {
let since_the_epoch = SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
diff --git a/bins/src/wobble.rs b/bins/src/wobble.rs
index fb71112b9..1c6db0188 100644
--- a/bins/src/wobble.rs
+++ b/bins/src/wobble.rs
@@ -1,8 +1,10 @@
-use crate::get_blockheight;
-use reqwest::Url;
use std::io::Read;
use std::time::SystemTime;

+use reqwest::Url;
+
+use crate::get_blockheight;
+
pub fn check_curl() {

//println!("check_curl");
diff --git a/bins/src/worker.rs b/bins/src/worker.rs
index 28866d884..b0d682791 100644
--- a/bins/src/worker.rs
+++ b/bins/src/worker.rs
@@ -1,6 +1,7 @@
+use std::sync::mpsc;
+
use crypto::digest::Digest;
use crypto::sha1;
-use std::sync::mpsc;
//use time;

pub struct Worker {
@@ -92,34 +93,34 @@ impl Worker {
}

let raw = format!(
- "tree {}\n\
- parent {}\n\
- author {} {}\n\
- committer {} {}\n\n\
- {}/{}/{}:{}\n\n\"tree\":\"{}\",\"parent\":\"{}\",\"weeble\":\"{:04}\",\"blockheight\":\"{:06}\",\"wobble\":\"{:}\",\"bit\":\"{:02}\",\"nonce\":\"{:08x}\",\"message\":\"{:}\"",
-
+ "tree {}\nparent {}\nauthor {} {}\ncommitter {} \
+ {}\n\n{}/{}/{}:{}\n\n\"tree\":\"{}\",\"parent\":\"{}\",\"weeble\":\"{:04}\",\"\
+ blockheight\":\"{:06}\",\"wobble\":\"{:}\",\"bit\":\"{:02}\",\"nonce\":\"{:08x}\",\"\
+ message\":\"{:}\"",
//below are in essential format
- self.tree,
- self.parent,
- self.author, tstamp, //author
- self.author, tstamp, //committer
+ self.tree,
+ self.parent,
+ self.author,
+ tstamp, //author
+ self.author,
+ tstamp, //committer
//above are in essential format

- //first element is commit subject line
- self.weeble.trim(),
- self.blockheight.trim(),
- self.wobble.trim(),
- self.message,
-
+ //first element is commit subject line
+ self.weeble.trim(),
+ self.blockheight.trim(),
+ self.wobble.trim(),
+ self.message,
//event body
- self.tree,
- self.parent,
- self.weeble.trim(),
- self.blockheight.trim(),
- self.wobble.trim(),
- self.id, value,
- self.message
- );
+ self.tree,
+ self.parent,
+ self.weeble.trim(),
+ self.blockheight.trim(),
+ self.wobble.trim(),
+ self.id,
+ value,
+ self.message
+ );
if cfg!(debug_assertions) {
print!("raw={}\n", raw);
}
Author Public Key
npub19w930lfc4pngkl50ys39s7ps3ngvcyq4qtqzc0laa34arz6ulddsx8d5rr