mirror of
https://github.com/mikedilger/gossip.git
synced 2024-09-19 19:46:50 +00:00
Update nostr-types: Unixtime::now() without .unwrap()
This commit is contained in:
parent
f4cf662ccf
commit
f51a2877cd
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -2240,7 +2240,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "gossip-relay-picker"
|
name = "gossip-relay-picker"
|
||||||
version = "0.2.0-unstable"
|
version = "0.2.0-unstable"
|
||||||
source = "git+https://github.com/mikedilger/gossip-relay-picker?rev=7fa49bdab37c042a839bc2f1cf17cf30120c36f9#7fa49bdab37c042a839bc2f1cf17cf30120c36f9"
|
source = "git+https://github.com/mikedilger/gossip-relay-picker?rev=c04ed85ef3ca95cd4083d8f2b7eac497a332b9f6#c04ed85ef3ca95cd4083d8f2b7eac497a332b9f6"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"dashmap",
|
"dashmap",
|
||||||
@ -3233,7 +3233,7 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "nostr-types"
|
name = "nostr-types"
|
||||||
version = "0.8.0-unstable"
|
version = "0.8.0-unstable"
|
||||||
source = "git+https://github.com/mikedilger/nostr-types?rev=9589c9223c7e775891d314849c5359c3d4f327b0#9589c9223c7e775891d314849c5359c3d4f327b0"
|
source = "git+https://github.com/mikedilger/nostr-types?rev=45fde646b9f8d8e4c330ba52120b445535fc1dfd#45fde646b9f8d8e4c330ba52120b445535fc1dfd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aes",
|
"aes",
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
|
@ -25,13 +25,13 @@ egui-winit = { git = "https://github.com/bu5hm4nn/egui", rev = "63dde4c9b311da0c
|
|||||||
egui_extras = { git = "https://github.com/bu5hm4nn/egui", rev = "63dde4c9b311da0cae0cb9f9465bf7273227be6c", features = [ "syntect" ] }
|
egui_extras = { git = "https://github.com/bu5hm4nn/egui", rev = "63dde4c9b311da0cae0cb9f9465bf7273227be6c", features = [ "syntect" ] }
|
||||||
#egui = { git = "https://github.com/bu5hm4nn/egui", rev = "63dde4c9b311da0cae0cb9f9465bf7273227be6c", features = [ "deadlock_detection" ] }
|
#egui = { git = "https://github.com/bu5hm4nn/egui", rev = "63dde4c9b311da0cae0cb9f9465bf7273227be6c", features = [ "deadlock_detection" ] }
|
||||||
egui-video = { git = "https://github.com/mikedilger/egui-video", rev = "97f58f88dfe912697393567830d0751676492a89", features = [ "from_bytes" ], optional = true }
|
egui-video = { git = "https://github.com/mikedilger/egui-video", rev = "97f58f88dfe912697393567830d0751676492a89", features = [ "from_bytes" ], optional = true }
|
||||||
gossip-relay-picker = { git = "https://github.com/mikedilger/gossip-relay-picker", rev = "7fa49bdab37c042a839bc2f1cf17cf30120c36f9" }
|
gossip-relay-picker = { git = "https://github.com/mikedilger/gossip-relay-picker", rev = "c04ed85ef3ca95cd4083d8f2b7eac497a332b9f6" }
|
||||||
gossip-lib = { path = "../gossip-lib" }
|
gossip-lib = { path = "../gossip-lib" }
|
||||||
humansize = "2.1"
|
humansize = "2.1"
|
||||||
image = { version = "0.24.6", features = [ "png", "jpeg" ] }
|
image = { version = "0.24.6", features = [ "png", "jpeg" ] }
|
||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
memoize = "0.4"
|
memoize = "0.4"
|
||||||
nostr-types = { git = "https://github.com/mikedilger/nostr-types", rev = "9589c9223c7e775891d314849c5359c3d4f327b0", features = [ "speedy" ] }
|
nostr-types = { git = "https://github.com/mikedilger/nostr-types", rev = "45fde646b9f8d8e4c330ba52120b445535fc1dfd", features = [ "speedy" ] }
|
||||||
paste = "1.0"
|
paste = "1.0"
|
||||||
qrcode = { git = "https://github.com/mikedilger/qrcode-rust", rev = "519b77b3efa3f84961169b47d3de08c5ddd86548" }
|
qrcode = { git = "https://github.com/mikedilger/qrcode-rust", rev = "519b77b3efa3f84961169b47d3de08c5ddd86548" }
|
||||||
resvg = "0.35.0"
|
resvg = "0.35.0"
|
||||||
|
@ -313,7 +313,7 @@ pub fn add_person_list(cmd: Command, mut args: env::Args) -> Result<(), Error> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn backdate_eose() -> Result<(), Error> {
|
pub fn backdate_eose() -> Result<(), Error> {
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
let ago = (now.0 - 60 * 60 * 24) as u64;
|
let ago = (now.0 - 60 * 60 * 24) as u64;
|
||||||
|
|
||||||
GLOBALS.storage.modify_all_relays(
|
GLOBALS.storage.modify_all_relays(
|
||||||
@ -573,7 +573,7 @@ pub fn delete_spam_by_content(
|
|||||||
let public_key = GLOBALS.identity.public_key().unwrap();
|
let public_key = GLOBALS.identity.public_key().unwrap();
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey: public_key,
|
pubkey: public_key,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind: EventKind::EventDeletion,
|
kind: EventKind::EventDeletion,
|
||||||
tags,
|
tags,
|
||||||
content: "spam".to_owned(),
|
content: "spam".to_owned(),
|
||||||
@ -917,7 +917,7 @@ pub fn reprocess_recent(_cmd: Command, runtime: &Runtime) -> Result<(), Error> {
|
|||||||
login()?;
|
login()?;
|
||||||
|
|
||||||
let job = tokio::task::spawn(async move {
|
let job = tokio::task::spawn(async move {
|
||||||
let mut ago = Unixtime::now().unwrap();
|
let mut ago = Unixtime::now();
|
||||||
ago.0 -= 86400;
|
ago.0 -= 86400;
|
||||||
|
|
||||||
let mut filter = Filter::new();
|
let mut filter = Filter::new();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
use nostr_types::Unixtime;
|
use nostr_types::Unixtime;
|
||||||
|
|
||||||
pub fn date_ago(then: Unixtime) -> String {
|
pub fn date_ago(then: Unixtime) -> String {
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
let seconds = now.0 - then.0;
|
let seconds = now.0 - then.0;
|
||||||
let minutes: f32 = seconds as f32 / 60.0;
|
let minutes: f32 = seconds as f32 / 60.0;
|
||||||
let hours: f32 = minutes / 60.0;
|
let hours: f32 = minutes / 60.0;
|
||||||
|
@ -654,7 +654,7 @@ pub(super) fn render_create_list_dialog(ui: &mut Ui, app: &mut GossipUi) {
|
|||||||
{
|
{
|
||||||
app.new_list_name = app.new_list_name.trim().into();
|
app.new_list_name = app.new_list_name.trim().into();
|
||||||
if !app.new_list_name.is_empty() {
|
if !app.new_list_name.is_empty() {
|
||||||
let dtag = format!("pl{}", Unixtime::now().unwrap().0);
|
let dtag = format!("pl{}", Unixtime::now().0);
|
||||||
let metadata = PersonListMetadata {
|
let metadata = PersonListMetadata {
|
||||||
dtag,
|
dtag,
|
||||||
title: app.new_list_name.to_owned(),
|
title: app.new_list_name.to_owned(),
|
||||||
|
@ -313,13 +313,9 @@ impl RelayEntry {
|
|||||||
// show remaining time on timeout
|
// show remaining time on timeout
|
||||||
if let Some(timeout) = self.timeout_until {
|
if let Some(timeout) = self.timeout_until {
|
||||||
let color = egui::Color32::from_rgb(0xf4, 0xbf, 0x4f); // orange
|
let color = egui::Color32::from_rgb(0xf4, 0xbf, 0x4f); // orange
|
||||||
if let Ok(now) = Unixtime::now() {
|
let remain = timeout - Unixtime::now().0;
|
||||||
let remain = timeout - now.0;
|
let text = format!("Timeout, retry in {} seconds", remain);
|
||||||
let text = format!("Timeout, retry in {} seconds", remain);
|
(color, text)
|
||||||
(color, text)
|
|
||||||
} else {
|
|
||||||
(color, "Timeout, retry soon".to_string())
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
(egui::Color32::GRAY, "Not connected".to_string())
|
(egui::Color32::GRAY, "Not connected".to_string())
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ fallible-iterator = "0.2"
|
|||||||
filetime = "0.2"
|
filetime = "0.2"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
gossip-relay-picker = { git = "https://github.com/mikedilger/gossip-relay-picker", rev = "7fa49bdab37c042a839bc2f1cf17cf30120c36f9" }
|
gossip-relay-picker = { git = "https://github.com/mikedilger/gossip-relay-picker", rev = "c04ed85ef3ca95cd4083d8f2b7eac497a332b9f6" }
|
||||||
heed = "0.20"
|
heed = "0.20"
|
||||||
hex = "0.4"
|
hex = "0.4"
|
||||||
http = "1.0"
|
http = "1.0"
|
||||||
@ -59,7 +59,7 @@ kamadak-exif = "0.5"
|
|||||||
lazy_static = "1.4"
|
lazy_static = "1.4"
|
||||||
linkify = "0.10"
|
linkify = "0.10"
|
||||||
mime = "0.3"
|
mime = "0.3"
|
||||||
nostr-types = { git = "https://github.com/mikedilger/nostr-types", rev = "9589c9223c7e775891d314849c5359c3d4f327b0", features = [ "speedy" ] }
|
nostr-types = { git = "https://github.com/mikedilger/nostr-types", rev = "45fde646b9f8d8e4c330ba52120b445535fc1dfd", features = [ "speedy" ] }
|
||||||
parking_lot = "0.12"
|
parking_lot = "0.12"
|
||||||
paste = "1.0"
|
paste = "1.0"
|
||||||
rand = "0.8"
|
rand = "0.8"
|
||||||
|
@ -147,7 +147,7 @@ impl BookmarkList {
|
|||||||
|
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey: public_key,
|
pubkey: public_key,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind: EventKind::BookmarkList,
|
kind: EventKind::BookmarkList,
|
||||||
tags,
|
tags,
|
||||||
content,
|
content,
|
||||||
|
@ -79,7 +79,7 @@ impl Feed {
|
|||||||
let anchor_key = self.current_feed_kind.read().anchor_key();
|
let anchor_key = self.current_feed_kind.read().anchor_key();
|
||||||
match self.feed_anchors.get(&anchor_key) {
|
match self.feed_anchors.get(&anchor_key) {
|
||||||
Some(r) => *r,
|
Some(r) => *r,
|
||||||
None => Unixtime::now().unwrap(),
|
None => Unixtime::now(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ impl Feed {
|
|||||||
Some(refanchor) => *refanchor,
|
Some(refanchor) => *refanchor,
|
||||||
None => {
|
None => {
|
||||||
// Start the feed anchor if it was not yet set
|
// Start the feed anchor if it was not yet set
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
self.feed_anchors.insert(anchor_key, now);
|
self.feed_anchors.insert(anchor_key, now);
|
||||||
now
|
now
|
||||||
}
|
}
|
||||||
@ -390,7 +390,7 @@ impl Feed {
|
|||||||
where
|
where
|
||||||
F: Fn(&Event) -> bool,
|
F: Fn(&Event) -> bool,
|
||||||
{
|
{
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
let limit = GLOBALS.storage.read_setting_load_more_count() as usize;
|
let limit = GLOBALS.storage.read_setting_load_more_count() as usize;
|
||||||
let dismissed = GLOBALS.dismissed.read().await.clone();
|
let dismissed = GLOBALS.dismissed.read().await.clone();
|
||||||
|
|
||||||
@ -424,7 +424,7 @@ impl Feed {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn basic_screen(e: &Event, include_replies: bool, include_dms: bool, dismissed: &[Id]) -> bool {
|
fn basic_screen(e: &Event, include_replies: bool, include_dms: bool, dismissed: &[Id]) -> bool {
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
|
|
||||||
e.created_at <= now
|
e.created_at <= now
|
||||||
&& (include_replies || e.replies_to().is_none())
|
&& (include_replies || e.replies_to().is_none())
|
||||||
|
@ -104,7 +104,7 @@ impl Fetcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
|
|
||||||
let mut count = 0;
|
let mut count = 0;
|
||||||
|
|
||||||
@ -512,7 +512,7 @@ impl Fetcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn sinbin(&self, url: &Url, duration: Duration) {
|
fn sinbin(&self, url: &Url, duration: Duration) {
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
let later = now + duration;
|
let later = now + duration;
|
||||||
let host = match self.host(url) {
|
let host = match self.host(url) {
|
||||||
Some(h) => h,
|
Some(h) => h,
|
||||||
|
@ -11,7 +11,7 @@ pub async fn validate_nip05(person: Person) -> Result<(), Error> {
|
|||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
|
|
||||||
// invalid if their nip-05 is not set
|
// invalid if their nip-05 is not set
|
||||||
if person.metadata().is_none()
|
if person.metadata().is_none()
|
||||||
@ -113,12 +113,7 @@ pub async fn get_and_follow_nip05(
|
|||||||
// Save person
|
// Save person
|
||||||
GLOBALS
|
GLOBALS
|
||||||
.people
|
.people
|
||||||
.upsert_nip05_validity(
|
.upsert_nip05_validity(&pubkey, Some(nip05.clone()), true, Unixtime::now().0 as u64)
|
||||||
&pubkey,
|
|
||||||
Some(nip05.clone()),
|
|
||||||
true,
|
|
||||||
Unixtime::now().unwrap().0 as u64,
|
|
||||||
)
|
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
update_relays(&nip05, nip05file, &pubkey).await?;
|
update_relays(&nip05, nip05file, &pubkey).await?;
|
||||||
|
@ -76,7 +76,7 @@ impl Approval {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
Approval::Until(time) => {
|
Approval::Until(time) => {
|
||||||
let approved = Unixtime::now().unwrap() < *time;
|
let approved = Unixtime::now() < *time;
|
||||||
if !approved {
|
if !approved {
|
||||||
*self = Approval::None;
|
*self = Approval::None;
|
||||||
}
|
}
|
||||||
@ -221,7 +221,7 @@ impl Nip46Server {
|
|||||||
|
|
||||||
let pre_event: PreEvent = PreEvent {
|
let pre_event: PreEvent = PreEvent {
|
||||||
pubkey: public_key,
|
pubkey: public_key,
|
||||||
created_at: created_at.unwrap_or(Unixtime::now().unwrap()),
|
created_at: created_at.unwrap_or(Unixtime::now()),
|
||||||
kind,
|
kind,
|
||||||
tags,
|
tags,
|
||||||
content,
|
content,
|
||||||
@ -310,7 +310,7 @@ pub struct Nip46PreEvent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn default_now() -> Option<Unixtime> {
|
fn default_now() -> Option<Unixtime> {
|
||||||
Some(Unixtime::now().unwrap())
|
Some(Unixtime::now())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Hash, PartialEq)]
|
#[derive(Debug, Clone, Hash, PartialEq)]
|
||||||
@ -405,7 +405,7 @@ fn send_response(
|
|||||||
|
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey: public_key,
|
pubkey: public_key,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind: EventKind::NostrConnect,
|
kind: EventKind::NostrConnect,
|
||||||
tags: vec![Tag::new_pubkey(peer_pubkey, None, None)],
|
tags: vec![Tag::new_pubkey(peer_pubkey, None, None)],
|
||||||
content: e,
|
content: e,
|
||||||
|
@ -123,7 +123,7 @@ impl Minion {
|
|||||||
}
|
}
|
||||||
if handle == "general_feed" {
|
if handle == "general_feed" {
|
||||||
// Update last general EOSE
|
// Update last general EOSE
|
||||||
let now = Unixtime::now().unwrap().0 as u64;
|
let now = Unixtime::now().0 as u64;
|
||||||
self.dbrelay.last_general_eose_at =
|
self.dbrelay.last_general_eose_at =
|
||||||
Some(match self.dbrelay.last_general_eose_at {
|
Some(match self.dbrelay.last_general_eose_at {
|
||||||
Some(old) => old.max(now),
|
Some(old) => old.max(now),
|
||||||
@ -180,7 +180,7 @@ impl Minion {
|
|||||||
GLOBALS.storage.add_event_seen_on_relay(
|
GLOBALS.storage.add_event_seen_on_relay(
|
||||||
id,
|
id,
|
||||||
&self.url,
|
&self.url,
|
||||||
Unixtime::now().unwrap(),
|
Unixtime::now(),
|
||||||
None,
|
None,
|
||||||
)?;
|
)?;
|
||||||
} else {
|
} else {
|
||||||
@ -309,7 +309,7 @@ impl Minion {
|
|||||||
|
|
||||||
// cork and retry once auth completes
|
// cork and retry once auth completes
|
||||||
self.subscriptions_waiting_for_auth
|
self.subscriptions_waiting_for_auth
|
||||||
.insert(handle, Unixtime::now().unwrap());
|
.insert(handle, Unixtime::now());
|
||||||
|
|
||||||
// return now, don't remove sub from map
|
// return now, don't remove sub from map
|
||||||
return Ok(());
|
return Ok(());
|
||||||
@ -317,7 +317,7 @@ impl Minion {
|
|||||||
AuthState::Waiting(_) => {
|
AuthState::Waiting(_) => {
|
||||||
// cork and retry once auth completes
|
// cork and retry once auth completes
|
||||||
self.subscriptions_waiting_for_auth
|
self.subscriptions_waiting_for_auth
|
||||||
.insert(handle, Unixtime::now().unwrap());
|
.insert(handle, Unixtime::now());
|
||||||
|
|
||||||
// return now, don't remove sub from map
|
// return now, don't remove sub from map
|
||||||
return Ok(());
|
return Ok(());
|
||||||
|
@ -190,7 +190,7 @@ impl Minion {
|
|||||||
let websocket_stream = {
|
let websocket_stream = {
|
||||||
// Fetch NIP-11 data (if not fetched recently)
|
// Fetch NIP-11 data (if not fetched recently)
|
||||||
if let Some(last_nip11) = self.dbrelay.last_attempt_nip11 {
|
if let Some(last_nip11) = self.dbrelay.last_attempt_nip11 {
|
||||||
if last_nip11 as i64 + 3600 < Unixtime::now().unwrap().0 {
|
if last_nip11 as i64 + 3600 < Unixtime::now().0 {
|
||||||
if let Err(e) = self.fetch_nip11(fetcher_timeout).await {
|
if let Err(e) = self.fetch_nip11(fetcher_timeout).await {
|
||||||
if matches!(e.kind, ErrorKind::ShuttingDown) {
|
if matches!(e.kind, ErrorKind::ShuttingDown) {
|
||||||
return Ok(MinionExitReason::GotShutdownMessage);
|
return Ok(MinionExitReason::GotShutdownMessage);
|
||||||
@ -393,7 +393,7 @@ impl Minion {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.dbrelay.last_attempt_nip11 = Some(Unixtime::now().unwrap().0 as u64);
|
self.dbrelay.last_attempt_nip11 = Some(Unixtime::now().0 as u64);
|
||||||
let status = response.status();
|
let status = response.status();
|
||||||
match Self::text_with_charset(response, "utf-8").await {
|
match Self::text_with_charset(response, "utf-8").await {
|
||||||
Ok(text) => {
|
Ok(text) => {
|
||||||
@ -514,7 +514,7 @@ impl Minion {
|
|||||||
&& self.subscriptions_waiting_for_metadata.is_empty()
|
&& self.subscriptions_waiting_for_metadata.is_empty()
|
||||||
&& self.posting_jobs.is_empty()
|
&& self.posting_jobs.is_empty()
|
||||||
{
|
{
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
if let Some(when) = self.subscriptions_empty_asof {
|
if let Some(when) = self.subscriptions_empty_asof {
|
||||||
if now - when > Duration::from_secs(10) {
|
if now - when > Duration::from_secs(10) {
|
||||||
// Exit as we have been idle 30 seconds without subscriptions
|
// Exit as we have been idle 30 seconds without subscriptions
|
||||||
@ -817,7 +817,7 @@ impl Minion {
|
|||||||
|
|
||||||
// Subscribe to the user's config (config, DMs, etc) which is on their own write relays
|
// Subscribe to the user's config (config, DMs, etc) which is on their own write relays
|
||||||
async fn subscribe_config(&mut self, job_id: u64) -> Result<(), Error> {
|
async fn subscribe_config(&mut self, job_id: u64) -> Result<(), Error> {
|
||||||
let since = Unixtime::now().unwrap() - Duration::from_secs(60 * 60 * 24 * 15);
|
let since = Unixtime::now() - Duration::from_secs(60 * 60 * 24 * 15);
|
||||||
|
|
||||||
let filters = filter_fns::config(since);
|
let filters = filter_fns::config(since);
|
||||||
|
|
||||||
@ -1075,7 +1075,7 @@ impl Minion {
|
|||||||
if self.auth_state == AuthState::Authenticated {
|
if self.auth_state == AuthState::Authenticated {
|
||||||
// Apply subscriptions that were waiting for auth
|
// Apply subscriptions that were waiting for auth
|
||||||
let mut handles = std::mem::take(&mut self.subscriptions_waiting_for_auth);
|
let mut handles = std::mem::take(&mut self.subscriptions_waiting_for_auth);
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
for (handle, when) in handles.drain() {
|
for (handle, when) in handles.drain() {
|
||||||
// Do not try if we just inserted it within the last second
|
// Do not try if we just inserted it within the last second
|
||||||
if when - now < Duration::from_secs(1) {
|
if when - now < Duration::from_secs(1) {
|
||||||
@ -1199,7 +1199,7 @@ impl Minion {
|
|||||||
// our fault the subscription is getting cut off. This way we will pick up
|
// our fault the subscription is getting cut off. This way we will pick up
|
||||||
// where we left off instead of potentially loading a bunch of events
|
// where we left off instead of potentially loading a bunch of events
|
||||||
// yet again.
|
// yet again.
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
|
|
||||||
// Update last general EOSE
|
// Update last general EOSE
|
||||||
self.dbrelay.last_general_eose_at = Some(match self.dbrelay.last_general_eose_at {
|
self.dbrelay.last_general_eose_at = Some(match self.dbrelay.last_general_eose_at {
|
||||||
@ -1234,7 +1234,7 @@ impl Minion {
|
|||||||
if matches!(self.auth_state, AuthState::Waiting(_)) {
|
if matches!(self.auth_state, AuthState::Waiting(_)) {
|
||||||
// Save this, subscribe after AUTH completes
|
// Save this, subscribe after AUTH completes
|
||||||
self.subscriptions_waiting_for_auth
|
self.subscriptions_waiting_for_auth
|
||||||
.insert(handle.to_owned(), Unixtime::now().unwrap());
|
.insert(handle.to_owned(), Unixtime::now());
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1311,7 +1311,7 @@ impl Minion {
|
|||||||
};
|
};
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey,
|
pubkey,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind: EventKind::Auth,
|
kind: EventKind::Auth,
|
||||||
tags: vec![
|
tags: vec![
|
||||||
Tag::new(&["relay", self.url.as_str()]),
|
Tag::new(&["relay", self.url.as_str()]),
|
||||||
@ -1372,7 +1372,7 @@ impl Minion {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn bump_success_count(&mut self, also_bump_last_connected: bool) {
|
async fn bump_success_count(&mut self, also_bump_last_connected: bool) {
|
||||||
let now = Unixtime::now().unwrap().0 as u64;
|
let now = Unixtime::now().0 as u64;
|
||||||
|
|
||||||
// Update in self
|
// Update in self
|
||||||
self.dbrelay.success_count += 1;
|
self.dbrelay.success_count += 1;
|
||||||
|
@ -560,7 +560,7 @@ impl Overlord {
|
|||||||
|
|
||||||
// Record the exclusion in the relay record
|
// Record the exclusion in the relay record
|
||||||
if let Ok(Some(mut relay)) = GLOBALS.storage.read_relay(&url, None) {
|
if let Ok(Some(mut relay)) = GLOBALS.storage.read_relay(&url, None) {
|
||||||
let until = Unixtime::now().unwrap() + Duration::from_secs(exclusion);
|
let until = Unixtime::now() + Duration::from_secs(exclusion);
|
||||||
relay.avoid_until = Some(until);
|
relay.avoid_until = Some(until);
|
||||||
let _ = GLOBALS.storage.write_relay(&relay, None);
|
let _ = GLOBALS.storage.write_relay(&relay, None);
|
||||||
}
|
}
|
||||||
@ -861,7 +861,7 @@ impl Overlord {
|
|||||||
|
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey: public_key,
|
pubkey: public_key,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind: EventKind::RelayList,
|
kind: EventKind::RelayList,
|
||||||
tags,
|
tags,
|
||||||
content: "".to_string(),
|
content: "".to_string(),
|
||||||
@ -881,7 +881,7 @@ impl Overlord {
|
|||||||
|
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey: public_key,
|
pubkey: public_key,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind: EventKind::DmRelayList,
|
kind: EventKind::DmRelayList,
|
||||||
tags,
|
tags,
|
||||||
content: "".to_string(),
|
content: "".to_string(),
|
||||||
@ -1215,7 +1215,7 @@ impl Overlord {
|
|||||||
|
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey: public_key,
|
pubkey: public_key,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind: EventKind::EventDeletion,
|
kind: EventKind::EventDeletion,
|
||||||
tags,
|
tags,
|
||||||
content: "Deleting person list".to_owned(),
|
content: "Deleting person list".to_owned(),
|
||||||
@ -1293,7 +1293,7 @@ impl Overlord {
|
|||||||
|
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey: public_key,
|
pubkey: public_key,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind: EventKind::EventDeletion,
|
kind: EventKind::EventDeletion,
|
||||||
tags,
|
tags,
|
||||||
content: "".to_owned(), // FIXME, option to supply a delete reason
|
content: "".to_owned(), // FIXME, option to supply a delete reason
|
||||||
@ -1476,7 +1476,7 @@ impl Overlord {
|
|||||||
nprofile.pubkey,
|
nprofile.pubkey,
|
||||||
&relay_url,
|
&relay_url,
|
||||||
|pr| {
|
|pr| {
|
||||||
pr.last_suggested = Some(Unixtime::now().unwrap().0 as u64);
|
pr.last_suggested = Some(Unixtime::now().0 as u64);
|
||||||
},
|
},
|
||||||
None,
|
None,
|
||||||
)?
|
)?
|
||||||
@ -1595,7 +1595,7 @@ impl Overlord {
|
|||||||
|
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey: public_key,
|
pubkey: public_key,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind: EventKind::Reaction,
|
kind: EventKind::Reaction,
|
||||||
tags,
|
tags,
|
||||||
content: "+".to_owned(),
|
content: "+".to_owned(),
|
||||||
@ -1913,7 +1913,7 @@ impl Overlord {
|
|||||||
.write()
|
.write()
|
||||||
.write("Pruning database, please be patient..".to_owned());
|
.write("Pruning database, please be patient..".to_owned());
|
||||||
|
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
let then = now
|
let then = now
|
||||||
- Duration::new(
|
- Duration::new(
|
||||||
GLOBALS.storage.read_setting_prune_period_days() * 60 * 60 * 24,
|
GLOBALS.storage.read_setting_prune_period_days() * 60 * 60 * 24,
|
||||||
@ -1972,7 +1972,7 @@ impl Overlord {
|
|||||||
|
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey: public_key,
|
pubkey: public_key,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind: EventKind::Metadata,
|
kind: EventKind::Metadata,
|
||||||
tags: vec![],
|
tags: vec![],
|
||||||
content: serde_json::to_string(&metadata)?,
|
content: serde_json::to_string(&metadata)?,
|
||||||
@ -2121,7 +2121,7 @@ impl Overlord {
|
|||||||
|
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey: public_key,
|
pubkey: public_key,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind,
|
kind,
|
||||||
tags,
|
tags,
|
||||||
content: serde_json::to_string(&reposted_event)?,
|
content: serde_json::to_string(&reposted_event)?,
|
||||||
@ -2656,7 +2656,7 @@ impl Overlord {
|
|||||||
|
|
||||||
// Mark for each person that we are seeking their relay list
|
// Mark for each person that we are seeking their relay list
|
||||||
// so that we don't repeat this for a while
|
// so that we don't repeat this for a while
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
let mut txn = GLOBALS.storage.get_write_txn()?;
|
let mut txn = GLOBALS.storage.get_write_txn()?;
|
||||||
for pk in pubkeys.iter() {
|
for pk in pubkeys.iter() {
|
||||||
PersonTable::modify(*pk, |p| p.relay_list_last_sought = now.0, Some(&mut txn))?;
|
PersonTable::modify(*pk, |p| p.relay_list_last_sought = now.0, Some(&mut txn))?;
|
||||||
@ -2687,7 +2687,7 @@ impl Overlord {
|
|||||||
|
|
||||||
/// Subscribe to the user's configuration events from the given relay
|
/// Subscribe to the user's configuration events from the given relay
|
||||||
pub async fn subscribe_inbox(&mut self, relays: Option<Vec<RelayUrl>>) -> Result<(), Error> {
|
pub async fn subscribe_inbox(&mut self, relays: Option<Vec<RelayUrl>>) -> Result<(), Error> {
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
let mention_relays: Vec<RelayUrl> = match relays {
|
let mention_relays: Vec<RelayUrl> = match relays {
|
||||||
Some(r) => r,
|
Some(r) => r,
|
||||||
None => Relay::choose_relay_urls(Relay::READ, |_| true)?,
|
None => Relay::choose_relay_urls(Relay::READ, |_| true)?,
|
||||||
@ -2716,7 +2716,7 @@ impl Overlord {
|
|||||||
.filter_relays(|r| r.has_usage_bits(Relay::DM) || r.has_usage_bits(Relay::INBOX))?;
|
.filter_relays(|r| r.has_usage_bits(Relay::DM) || r.has_usage_bits(Relay::INBOX))?;
|
||||||
|
|
||||||
// 30 days worth (FIXME make this a setting?)
|
// 30 days worth (FIXME make this a setting?)
|
||||||
let after = Unixtime::now().unwrap() - Duration::new(3600 * 24 * 30, 0);
|
let after = Unixtime::now() - Duration::new(3600 * 24 * 30, 0);
|
||||||
|
|
||||||
for relay in relays.iter() {
|
for relay in relays.iter() {
|
||||||
self.engage_minion(
|
self.engage_minion(
|
||||||
@ -2879,7 +2879,7 @@ impl Overlord {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
|
|
||||||
let mut txn = GLOBALS.storage.get_write_txn()?;
|
let mut txn = GLOBALS.storage.get_write_txn()?;
|
||||||
|
|
||||||
@ -3356,7 +3356,7 @@ impl Overlord {
|
|||||||
// Generate the zap request event
|
// Generate the zap request event
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey: user_pubkey,
|
pubkey: user_pubkey,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind: EventKind::ZapRequest,
|
kind: EventKind::ZapRequest,
|
||||||
tags: vec![
|
tags: vec![
|
||||||
Tag::new_event(id, None, None),
|
Tag::new_event(id, None, None),
|
||||||
|
@ -223,7 +223,7 @@ impl Pending {
|
|||||||
None => return Ok(()), // nothing pending if no identity
|
None => return Ok(()), // nothing pending if no identity
|
||||||
};
|
};
|
||||||
|
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
let t30days = 60 * 60 * 24 * 30;
|
let t30days = 60 * 60 * 24 * 30;
|
||||||
let t90days = 60 * 60 * 24 * 90;
|
let t90days = 60 * 60 * 24 * 90;
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ impl People {
|
|||||||
|
|
||||||
/// Get all the pubkeys that need relay lists (from the given set)
|
/// Get all the pubkeys that need relay lists (from the given set)
|
||||||
pub fn get_subscribed_pubkeys_needing_relay_lists(&self) -> Vec<PublicKey> {
|
pub fn get_subscribed_pubkeys_needing_relay_lists(&self) -> Vec<PublicKey> {
|
||||||
let stale = Unixtime::now().unwrap().0
|
let stale = Unixtime::now().0
|
||||||
- 60 * GLOBALS
|
- 60 * GLOBALS
|
||||||
.storage
|
.storage
|
||||||
.read_setting_relay_list_becomes_stale_minutes() as i64;
|
.read_setting_relay_list_becomes_stale_minutes() as i64;
|
||||||
@ -125,7 +125,7 @@ impl People {
|
|||||||
|
|
||||||
/// Get if a person needs a relay list
|
/// Get if a person needs a relay list
|
||||||
pub fn person_needs_relay_list(pubkey: PublicKey) -> Freshness {
|
pub fn person_needs_relay_list(pubkey: PublicKey) -> Freshness {
|
||||||
let staletime = Unixtime::now().unwrap().0
|
let staletime = Unixtime::now().0
|
||||||
- 60 * GLOBALS
|
- 60 * GLOBALS
|
||||||
.storage
|
.storage
|
||||||
.read_setting_relay_list_becomes_stale_minutes() as i64;
|
.read_setting_relay_list_becomes_stale_minutes() as i64;
|
||||||
@ -175,7 +175,7 @@ impl People {
|
|||||||
/// The overlord calls this to indicate that it is fetching metadata
|
/// The overlord calls this to indicate that it is fetching metadata
|
||||||
/// for this person from relays
|
/// for this person from relays
|
||||||
pub fn metadata_fetch_initiated(&self, pubkeys: &[PublicKey]) {
|
pub fn metadata_fetch_initiated(&self, pubkeys: &[PublicKey]) {
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
for pubkey in pubkeys {
|
for pubkey in pubkeys {
|
||||||
self.fetching_metadata.insert(*pubkey, now);
|
self.fetching_metadata.insert(*pubkey, now);
|
||||||
}
|
}
|
||||||
@ -199,7 +199,7 @@ impl People {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
let stale = Duration::from_secs(
|
let stale = Duration::from_secs(
|
||||||
60 * GLOBALS
|
60 * GLOBALS
|
||||||
.storage
|
.storage
|
||||||
@ -274,7 +274,7 @@ impl People {
|
|||||||
// Sync in from database first
|
// Sync in from database first
|
||||||
self.create_all_if_missing(&[*pubkey])?;
|
self.create_all_if_missing(&[*pubkey])?;
|
||||||
|
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
|
|
||||||
// Copy the person
|
// Copy the person
|
||||||
let mut person =
|
let mut person =
|
||||||
@ -335,7 +335,7 @@ impl People {
|
|||||||
.read_setting_nip05_becomes_stale_if_invalid_minutes(),
|
.read_setting_nip05_becomes_stale_if_invalid_minutes(),
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
Unixtime::now().unwrap() - Unixtime(last as i64) > recheck_duration
|
Unixtime::now() - Unixtime(last as i64) > recheck_duration
|
||||||
} else {
|
} else {
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
@ -701,7 +701,7 @@ impl People {
|
|||||||
|
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey: my_pubkey,
|
pubkey: my_pubkey,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind,
|
kind,
|
||||||
tags: public_tags,
|
tags: public_tags,
|
||||||
content,
|
content,
|
||||||
@ -789,7 +789,7 @@ impl People {
|
|||||||
.storage
|
.storage
|
||||||
.get_person_list_metadata(PersonList::Muted)?
|
.get_person_list_metadata(PersonList::Muted)?
|
||||||
{
|
{
|
||||||
metadata.last_edit_time = Unixtime::now().unwrap();
|
metadata.last_edit_time = Unixtime::now();
|
||||||
GLOBALS.storage.set_person_list_metadata(
|
GLOBALS.storage.set_person_list_metadata(
|
||||||
PersonList::Muted,
|
PersonList::Muted,
|
||||||
&metadata,
|
&metadata,
|
||||||
@ -833,7 +833,7 @@ impl People {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) async fn update_nip05_last_checked(&self, pubkey: PublicKey) -> Result<(), Error> {
|
pub(crate) async fn update_nip05_last_checked(&self, pubkey: PublicKey) -> Result<(), Error> {
|
||||||
let now = Unixtime::now().unwrap().0;
|
let now = Unixtime::now().0;
|
||||||
|
|
||||||
PersonTable::modify(
|
PersonTable::modify(
|
||||||
pubkey,
|
pubkey,
|
||||||
|
@ -29,7 +29,7 @@ pub fn prepare_post_normal(
|
|||||||
|
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey: author,
|
pubkey: author,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind: EventKind::TextNote,
|
kind: EventKind::TextNote,
|
||||||
tags,
|
tags,
|
||||||
content,
|
content,
|
||||||
@ -95,7 +95,7 @@ pub fn prepare_post_nip04(
|
|||||||
|
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey: author,
|
pubkey: author,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind: EventKind::EncryptedDirectMessage,
|
kind: EventKind::EncryptedDirectMessage,
|
||||||
tags,
|
tags,
|
||||||
content,
|
content,
|
||||||
@ -156,7 +156,7 @@ pub fn prepare_post_nip17(
|
|||||||
|
|
||||||
let pre_event = PreEvent {
|
let pre_event = PreEvent {
|
||||||
pubkey: author,
|
pubkey: author,
|
||||||
created_at: Unixtime::now().unwrap(),
|
created_at: Unixtime::now(),
|
||||||
kind: EventKind::DmChat,
|
kind: EventKind::DmChat,
|
||||||
tags,
|
tags,
|
||||||
content,
|
content,
|
||||||
|
@ -26,7 +26,7 @@ pub async fn process_new_event(
|
|||||||
verify: bool,
|
verify: bool,
|
||||||
process_even_if_duplicate: bool,
|
process_even_if_duplicate: bool,
|
||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let now = Unixtime::now()?;
|
let now = Unixtime::now();
|
||||||
|
|
||||||
// Bump count
|
// Bump count
|
||||||
GLOBALS.events_processed.fetch_add(1, Ordering::SeqCst);
|
GLOBALS.events_processed.fetch_add(1, Ordering::SeqCst);
|
||||||
|
@ -29,7 +29,7 @@ pub struct SeekData {
|
|||||||
impl SeekData {
|
impl SeekData {
|
||||||
fn new_event(climb: bool) -> SeekData {
|
fn new_event(climb: bool) -> SeekData {
|
||||||
SeekData {
|
SeekData {
|
||||||
start: Unixtime::now().unwrap(),
|
start: Unixtime::now(),
|
||||||
state: SeekState::WaitingEvent,
|
state: SeekState::WaitingEvent,
|
||||||
climb,
|
climb,
|
||||||
}
|
}
|
||||||
@ -37,7 +37,7 @@ impl SeekData {
|
|||||||
|
|
||||||
fn new_relay_list(pubkey: PublicKey, climb: bool) -> SeekData {
|
fn new_relay_list(pubkey: PublicKey, climb: bool) -> SeekData {
|
||||||
SeekData {
|
SeekData {
|
||||||
start: Unixtime::now().unwrap(),
|
start: Unixtime::now(),
|
||||||
state: SeekState::WaitingRelayList(pubkey),
|
state: SeekState::WaitingRelayList(pubkey),
|
||||||
climb,
|
climb,
|
||||||
}
|
}
|
||||||
@ -236,7 +236,7 @@ impl Seeker {
|
|||||||
// we save updates here and apply when the iterator is finished.
|
// we save updates here and apply when the iterator is finished.
|
||||||
let mut updates: Vec<(Id, Option<SeekData>)> = Vec::new();
|
let mut updates: Vec<(Id, Option<SeekData>)> = Vec::new();
|
||||||
|
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
|
|
||||||
for refmulti in self.events.iter() {
|
for refmulti in self.events.iter() {
|
||||||
let id = *refmulti.key();
|
let id = *refmulti.key();
|
||||||
|
@ -84,7 +84,7 @@ mod test {
|
|||||||
fn test_event_akci_key() {
|
fn test_event_akci_key() {
|
||||||
let pubkey = PrivateKey::generate().public_key();
|
let pubkey = PrivateKey::generate().public_key();
|
||||||
let kind = EventKind::TextNote;
|
let kind = EventKind::TextNote;
|
||||||
let created_at = Unixtime::now().unwrap();
|
let created_at = Unixtime::now();
|
||||||
let id = Id::try_from_hex_string(
|
let id = Id::try_from_hex_string(
|
||||||
"77f7653c67147a125cc624f695029d0557e3ab402e714680eb23dd2499f439a0",
|
"77f7653c67147a125cc624f695029d0557e3ab402e714680eb23dd2499f439a0",
|
||||||
)
|
)
|
||||||
|
@ -88,7 +88,7 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn test_event_kci_key() {
|
fn test_event_kci_key() {
|
||||||
let kind = EventKind::TextNote;
|
let kind = EventKind::TextNote;
|
||||||
let created_at = Unixtime::now().unwrap();
|
let created_at = Unixtime::now();
|
||||||
let id = Id::try_from_hex_string(
|
let id = Id::try_from_hex_string(
|
||||||
"77f7653c67147a125cc624f695029d0557e3ab402e714680eb23dd2499f439a0",
|
"77f7653c67147a125cc624f695029d0557e3ab402e714680eb23dd2499f439a0",
|
||||||
)
|
)
|
||||||
|
@ -57,7 +57,7 @@ impl Storage {
|
|||||||
last_edit_times
|
last_edit_times
|
||||||
.get(&list)
|
.get(&list)
|
||||||
.copied()
|
.copied()
|
||||||
.unwrap_or(Unixtime::now().unwrap().0),
|
.unwrap_or(Unixtime::now().0),
|
||||||
),
|
),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
@ -221,7 +221,7 @@ impl Storage {
|
|||||||
.into());
|
.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
let mut ids: HashSet<Id> = HashSet::new();
|
let mut ids: HashSet<Id> = HashSet::new();
|
||||||
let txn = self.env.read_txn()?;
|
let txn = self.env.read_txn()?;
|
||||||
|
|
||||||
|
@ -833,7 +833,7 @@ impl Storage {
|
|||||||
None => return Err(ErrorKind::ListNotFound.into()),
|
None => return Err(ErrorKind::ListNotFound.into()),
|
||||||
};
|
};
|
||||||
md.title = newname;
|
md.title = newname;
|
||||||
md.last_edit_time = Unixtime::now().unwrap();
|
md.last_edit_time = Unixtime::now();
|
||||||
self.set_person_list_metadata(list, &md, rw_txn)?;
|
self.set_person_list_metadata(list, &md, rw_txn)?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -2112,7 +2112,7 @@ impl Storage {
|
|||||||
write: bool,
|
write: bool,
|
||||||
min: usize,
|
min: usize,
|
||||||
) -> Result<Vec<(RelayUrl, u64)>, Error> {
|
) -> Result<Vec<(RelayUrl, u64)>, Error> {
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
|
|
||||||
// Load person relays, filtering out banned URLs
|
// Load person relays, filtering out banned URLs
|
||||||
let mut person_relays: Vec<PersonRelay> = self
|
let mut person_relays: Vec<PersonRelay> = self
|
||||||
@ -2499,7 +2499,7 @@ impl Storage {
|
|||||||
) -> Result<(), Error> {
|
) -> Result<(), Error> {
|
||||||
let f = |txn: &mut RwTxn<'a>| -> Result<(), Error> {
|
let f = |txn: &mut RwTxn<'a>| -> Result<(), Error> {
|
||||||
self.clear_person_list2(list, Some(txn))?;
|
self.clear_person_list2(list, Some(txn))?;
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
if let Some(mut metadata) = self.get_person_list_metadata(list)? {
|
if let Some(mut metadata) = self.get_person_list_metadata(list)? {
|
||||||
metadata.last_edit_time = now;
|
metadata.last_edit_time = now;
|
||||||
metadata.len = 0;
|
metadata.len = 0;
|
||||||
@ -2553,7 +2553,7 @@ impl Storage {
|
|||||||
let had = map.contains_key(&list);
|
let had = map.contains_key(&list);
|
||||||
map.insert(list, private);
|
map.insert(list, private);
|
||||||
self.write_person_lists(pubkey, map, Some(txn))?;
|
self.write_person_lists(pubkey, map, Some(txn))?;
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
if let Some(mut metadata) = self.get_person_list_metadata(list)? {
|
if let Some(mut metadata) = self.get_person_list_metadata(list)? {
|
||||||
if !had {
|
if !had {
|
||||||
metadata.len += 1;
|
metadata.len += 1;
|
||||||
@ -2580,7 +2580,7 @@ impl Storage {
|
|||||||
let had = map.contains_key(&list);
|
let had = map.contains_key(&list);
|
||||||
map.remove(&list);
|
map.remove(&list);
|
||||||
self.write_person_lists(pubkey, map, Some(txn))?;
|
self.write_person_lists(pubkey, map, Some(txn))?;
|
||||||
let now = Unixtime::now().unwrap();
|
let now = Unixtime::now();
|
||||||
if let Some(mut metadata) = self.get_person_list_metadata(list)? {
|
if let Some(mut metadata) = self.get_person_list_metadata(list)? {
|
||||||
if had && metadata.len > 0 {
|
if had && metadata.len > 0 {
|
||||||
metadata.len -= 1;
|
metadata.len -= 1;
|
||||||
|
@ -16,7 +16,7 @@ impl Default for PersonListMetadata1 {
|
|||||||
PersonListMetadata1 {
|
PersonListMetadata1 {
|
||||||
dtag: "".to_owned(),
|
dtag: "".to_owned(),
|
||||||
title: "".to_owned(),
|
title: "".to_owned(),
|
||||||
last_edit_time: Unixtime::now().unwrap(),
|
last_edit_time: Unixtime::now(),
|
||||||
event_created_at: Unixtime(0),
|
event_created_at: Unixtime(0),
|
||||||
event_public_len: 0,
|
event_public_len: 0,
|
||||||
event_private_len: None,
|
event_private_len: None,
|
||||||
|
@ -19,7 +19,7 @@ impl Default for PersonListMetadata2 {
|
|||||||
PersonListMetadata2 {
|
PersonListMetadata2 {
|
||||||
dtag: "".to_owned(),
|
dtag: "".to_owned(),
|
||||||
title: "".to_owned(),
|
title: "".to_owned(),
|
||||||
last_edit_time: Unixtime::now().unwrap(),
|
last_edit_time: Unixtime::now(),
|
||||||
event_created_at: Unixtime(0),
|
event_created_at: Unixtime(0),
|
||||||
event_public_len: 0,
|
event_public_len: 0,
|
||||||
event_private_len: None,
|
event_private_len: None,
|
||||||
|
@ -21,7 +21,7 @@ impl Default for PersonListMetadata3 {
|
|||||||
PersonListMetadata3 {
|
PersonListMetadata3 {
|
||||||
dtag: "".to_owned(),
|
dtag: "".to_owned(),
|
||||||
title: "".to_owned(),
|
title: "".to_owned(),
|
||||||
last_edit_time: Unixtime::now().unwrap(),
|
last_edit_time: Unixtime::now(),
|
||||||
event_created_at: Unixtime(0),
|
event_created_at: Unixtime(0),
|
||||||
event_public_len: 0,
|
event_public_len: 0,
|
||||||
event_private_len: None,
|
event_private_len: None,
|
||||||
|
@ -58,7 +58,7 @@ impl PersonRelay1 {
|
|||||||
// This ranks the relays that a person writes to, but does not consider local
|
// This ranks the relays that a person writes to, but does not consider local
|
||||||
// factors such as our relay rank or the success rate of the relay.
|
// factors such as our relay rank or the success rate of the relay.
|
||||||
pub fn write_rank(mut dbprs: Vec<PersonRelay1>) -> Vec<(RelayUrl, u64)> {
|
pub fn write_rank(mut dbprs: Vec<PersonRelay1>) -> Vec<(RelayUrl, u64)> {
|
||||||
let now = Unixtime::now().unwrap().0 as u64;
|
let now = Unixtime::now().0 as u64;
|
||||||
let mut output: Vec<(RelayUrl, u64)> = Vec::new();
|
let mut output: Vec<(RelayUrl, u64)> = Vec::new();
|
||||||
|
|
||||||
let scorefn = |when: u64, fade_period: u64, base: u64| -> u64 {
|
let scorefn = |when: u64, fade_period: u64, base: u64| -> u64 {
|
||||||
@ -110,7 +110,7 @@ impl PersonRelay1 {
|
|||||||
// This ranks the relays that a person reads from, but does not consider local
|
// This ranks the relays that a person reads from, but does not consider local
|
||||||
// factors such as our relay rank or the success rate of the relay.
|
// factors such as our relay rank or the success rate of the relay.
|
||||||
pub fn read_rank(mut dbprs: Vec<PersonRelay1>) -> Vec<(RelayUrl, u64)> {
|
pub fn read_rank(mut dbprs: Vec<PersonRelay1>) -> Vec<(RelayUrl, u64)> {
|
||||||
let now = Unixtime::now().unwrap().0 as u64;
|
let now = Unixtime::now().0 as u64;
|
||||||
let mut output: Vec<(RelayUrl, u64)> = Vec::new();
|
let mut output: Vec<(RelayUrl, u64)> = Vec::new();
|
||||||
|
|
||||||
let scorefn = |when: u64, fade_period: u64, base: u64| -> u64 {
|
let scorefn = |when: u64, fade_period: u64, base: u64| -> u64 {
|
||||||
|
@ -163,7 +163,7 @@ impl Relay3 {
|
|||||||
|
|
||||||
pub fn should_avoid(&self) -> bool {
|
pub fn should_avoid(&self) -> bool {
|
||||||
if let Some(when) = self.avoid_until {
|
if let Some(when) = self.avoid_until {
|
||||||
when >= Unixtime::now().unwrap()
|
when >= Unixtime::now()
|
||||||
} else {
|
} else {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user