Update nostr-types: Unixtime::now() without .unwrap()

This commit is contained in:
Mike Dilger 2024-07-09 08:52:51 +12:00
parent f4cf662ccf
commit f51a2877cd
30 changed files with 87 additions and 96 deletions

4
Cargo.lock generated
View File

@ -2240,7 +2240,7 @@ dependencies = [
[[package]]
name = "gossip-relay-picker"
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 = [
"async-trait",
"dashmap",
@ -3233,7 +3233,7 @@ dependencies = [
[[package]]
name = "nostr-types"
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 = [
"aes",
"base64 0.22.1",

View File

@ -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 = { 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 }
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" }
humansize = "2.1"
image = { version = "0.24.6", features = [ "png", "jpeg" ] }
lazy_static = "1.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"
qrcode = { git = "https://github.com/mikedilger/qrcode-rust", rev = "519b77b3efa3f84961169b47d3de08c5ddd86548" }
resvg = "0.35.0"

View File

@ -313,7 +313,7 @@ pub fn add_person_list(cmd: Command, mut args: env::Args) -> 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;
GLOBALS.storage.modify_all_relays(
@ -573,7 +573,7 @@ pub fn delete_spam_by_content(
let public_key = GLOBALS.identity.public_key().unwrap();
let pre_event = PreEvent {
pubkey: public_key,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind: EventKind::EventDeletion,
tags,
content: "spam".to_owned(),
@ -917,7 +917,7 @@ pub fn reprocess_recent(_cmd: Command, runtime: &Runtime) -> Result<(), Error> {
login()?;
let job = tokio::task::spawn(async move {
let mut ago = Unixtime::now().unwrap();
let mut ago = Unixtime::now();
ago.0 -= 86400;
let mut filter = Filter::new();

View File

@ -1,7 +1,7 @@
use nostr_types::Unixtime;
pub fn date_ago(then: Unixtime) -> String {
let now = Unixtime::now().unwrap();
let now = Unixtime::now();
let seconds = now.0 - then.0;
let minutes: f32 = seconds as f32 / 60.0;
let hours: f32 = minutes / 60.0;

View File

@ -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();
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 {
dtag,
title: app.new_list_name.to_owned(),

View File

@ -313,13 +313,9 @@ impl RelayEntry {
// show remaining time on timeout
if let Some(timeout) = self.timeout_until {
let color = egui::Color32::from_rgb(0xf4, 0xbf, 0x4f); // orange
if let Ok(now) = Unixtime::now() {
let remain = timeout - now.0;
let text = format!("Timeout, retry in {} seconds", remain);
(color, text)
} else {
(color, "Timeout, retry soon".to_string())
}
let remain = timeout - Unixtime::now().0;
let text = format!("Timeout, retry in {} seconds", remain);
(color, text)
} else {
(egui::Color32::GRAY, "Not connected".to_string())
}

View File

@ -50,7 +50,7 @@ fallible-iterator = "0.2"
filetime = "0.2"
futures = "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"
hex = "0.4"
http = "1.0"
@ -59,7 +59,7 @@ kamadak-exif = "0.5"
lazy_static = "1.4"
linkify = "0.10"
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"
paste = "1.0"
rand = "0.8"

View File

@ -147,7 +147,7 @@ impl BookmarkList {
let pre_event = PreEvent {
pubkey: public_key,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind: EventKind::BookmarkList,
tags,
content,

View File

@ -79,7 +79,7 @@ impl Feed {
let anchor_key = self.current_feed_kind.read().anchor_key();
match self.feed_anchors.get(&anchor_key) {
Some(r) => *r,
None => Unixtime::now().unwrap(),
None => Unixtime::now(),
}
}
@ -124,7 +124,7 @@ impl Feed {
Some(refanchor) => *refanchor,
None => {
// 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);
now
}
@ -390,7 +390,7 @@ impl Feed {
where
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 dismissed = GLOBALS.dismissed.read().await.clone();
@ -424,7 +424,7 @@ impl Feed {
#[inline]
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
&& (include_replies || e.replies_to().is_none())

View File

@ -104,7 +104,7 @@ impl Fetcher {
}
}
let now = Unixtime::now().unwrap();
let now = Unixtime::now();
let mut count = 0;
@ -512,7 +512,7 @@ impl Fetcher {
}
fn sinbin(&self, url: &Url, duration: Duration) {
let now = Unixtime::now().unwrap();
let now = Unixtime::now();
let later = now + duration;
let host = match self.host(url) {
Some(h) => h,

View File

@ -11,7 +11,7 @@ pub async fn validate_nip05(person: Person) -> Result<(), Error> {
return Ok(());
}
let now = Unixtime::now().unwrap();
let now = Unixtime::now();
// invalid if their nip-05 is not set
if person.metadata().is_none()
@ -113,12 +113,7 @@ pub async fn get_and_follow_nip05(
// Save person
GLOBALS
.people
.upsert_nip05_validity(
&pubkey,
Some(nip05.clone()),
true,
Unixtime::now().unwrap().0 as u64,
)
.upsert_nip05_validity(&pubkey, Some(nip05.clone()), true, Unixtime::now().0 as u64)
.await?;
update_relays(&nip05, nip05file, &pubkey).await?;

View File

@ -76,7 +76,7 @@ impl Approval {
true
}
Approval::Until(time) => {
let approved = Unixtime::now().unwrap() < *time;
let approved = Unixtime::now() < *time;
if !approved {
*self = Approval::None;
}
@ -221,7 +221,7 @@ impl Nip46Server {
let pre_event: PreEvent = PreEvent {
pubkey: public_key,
created_at: created_at.unwrap_or(Unixtime::now().unwrap()),
created_at: created_at.unwrap_or(Unixtime::now()),
kind,
tags,
content,
@ -310,7 +310,7 @@ pub struct Nip46PreEvent {
}
fn default_now() -> Option<Unixtime> {
Some(Unixtime::now().unwrap())
Some(Unixtime::now())
}
#[derive(Debug, Clone, Hash, PartialEq)]
@ -405,7 +405,7 @@ fn send_response(
let pre_event = PreEvent {
pubkey: public_key,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind: EventKind::NostrConnect,
tags: vec![Tag::new_pubkey(peer_pubkey, None, None)],
content: e,

View File

@ -123,7 +123,7 @@ impl Minion {
}
if handle == "general_feed" {
// 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 =
Some(match self.dbrelay.last_general_eose_at {
Some(old) => old.max(now),
@ -180,7 +180,7 @@ impl Minion {
GLOBALS.storage.add_event_seen_on_relay(
id,
&self.url,
Unixtime::now().unwrap(),
Unixtime::now(),
None,
)?;
} else {
@ -309,7 +309,7 @@ impl Minion {
// cork and retry once auth completes
self.subscriptions_waiting_for_auth
.insert(handle, Unixtime::now().unwrap());
.insert(handle, Unixtime::now());
// return now, don't remove sub from map
return Ok(());
@ -317,7 +317,7 @@ impl Minion {
AuthState::Waiting(_) => {
// cork and retry once auth completes
self.subscriptions_waiting_for_auth
.insert(handle, Unixtime::now().unwrap());
.insert(handle, Unixtime::now());
// return now, don't remove sub from map
return Ok(());

View File

@ -190,7 +190,7 @@ impl Minion {
let websocket_stream = {
// Fetch NIP-11 data (if not fetched recently)
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 matches!(e.kind, ErrorKind::ShuttingDown) {
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();
match Self::text_with_charset(response, "utf-8").await {
Ok(text) => {
@ -514,7 +514,7 @@ impl Minion {
&& self.subscriptions_waiting_for_metadata.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 now - when > Duration::from_secs(10) {
// 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
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);
@ -1075,7 +1075,7 @@ impl Minion {
if self.auth_state == AuthState::Authenticated {
// Apply subscriptions that were 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() {
// Do not try if we just inserted it within the last second
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
// where we left off instead of potentially loading a bunch of events
// yet again.
let now = Unixtime::now().unwrap();
let now = Unixtime::now();
// Update last general EOSE
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(_)) {
// Save this, subscribe after AUTH completes
self.subscriptions_waiting_for_auth
.insert(handle.to_owned(), Unixtime::now().unwrap());
.insert(handle.to_owned(), Unixtime::now());
return Ok(());
}
@ -1311,7 +1311,7 @@ impl Minion {
};
let pre_event = PreEvent {
pubkey,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind: EventKind::Auth,
tags: vec![
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) {
let now = Unixtime::now().unwrap().0 as u64;
let now = Unixtime::now().0 as u64;
// Update in self
self.dbrelay.success_count += 1;

View File

@ -560,7 +560,7 @@ impl Overlord {
// Record the exclusion in the relay record
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);
let _ = GLOBALS.storage.write_relay(&relay, None);
}
@ -861,7 +861,7 @@ impl Overlord {
let pre_event = PreEvent {
pubkey: public_key,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind: EventKind::RelayList,
tags,
content: "".to_string(),
@ -881,7 +881,7 @@ impl Overlord {
let pre_event = PreEvent {
pubkey: public_key,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind: EventKind::DmRelayList,
tags,
content: "".to_string(),
@ -1215,7 +1215,7 @@ impl Overlord {
let pre_event = PreEvent {
pubkey: public_key,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind: EventKind::EventDeletion,
tags,
content: "Deleting person list".to_owned(),
@ -1293,7 +1293,7 @@ impl Overlord {
let pre_event = PreEvent {
pubkey: public_key,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind: EventKind::EventDeletion,
tags,
content: "".to_owned(), // FIXME, option to supply a delete reason
@ -1476,7 +1476,7 @@ impl Overlord {
nprofile.pubkey,
&relay_url,
|pr| {
pr.last_suggested = Some(Unixtime::now().unwrap().0 as u64);
pr.last_suggested = Some(Unixtime::now().0 as u64);
},
None,
)?
@ -1595,7 +1595,7 @@ impl Overlord {
let pre_event = PreEvent {
pubkey: public_key,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind: EventKind::Reaction,
tags,
content: "+".to_owned(),
@ -1913,7 +1913,7 @@ impl Overlord {
.write()
.write("Pruning database, please be patient..".to_owned());
let now = Unixtime::now().unwrap();
let now = Unixtime::now();
let then = now
- Duration::new(
GLOBALS.storage.read_setting_prune_period_days() * 60 * 60 * 24,
@ -1972,7 +1972,7 @@ impl Overlord {
let pre_event = PreEvent {
pubkey: public_key,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind: EventKind::Metadata,
tags: vec![],
content: serde_json::to_string(&metadata)?,
@ -2121,7 +2121,7 @@ impl Overlord {
let pre_event = PreEvent {
pubkey: public_key,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind,
tags,
content: serde_json::to_string(&reposted_event)?,
@ -2656,7 +2656,7 @@ impl Overlord {
// Mark for each person that we are seeking their relay list
// 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()?;
for pk in pubkeys.iter() {
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
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 {
Some(r) => r,
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))?;
// 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() {
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()?;
@ -3356,7 +3356,7 @@ impl Overlord {
// Generate the zap request event
let pre_event = PreEvent {
pubkey: user_pubkey,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind: EventKind::ZapRequest,
tags: vec![
Tag::new_event(id, None, None),

View File

@ -223,7 +223,7 @@ impl Pending {
None => return Ok(()), // nothing pending if no identity
};
let now = Unixtime::now().unwrap();
let now = Unixtime::now();
let t30days = 60 * 60 * 24 * 30;
let t90days = 60 * 60 * 24 * 90;

View File

@ -108,7 +108,7 @@ impl People {
/// Get all the pubkeys that need relay lists (from the given set)
pub fn get_subscribed_pubkeys_needing_relay_lists(&self) -> Vec<PublicKey> {
let stale = Unixtime::now().unwrap().0
let stale = Unixtime::now().0
- 60 * GLOBALS
.storage
.read_setting_relay_list_becomes_stale_minutes() as i64;
@ -125,7 +125,7 @@ impl People {
/// Get if a person needs a relay list
pub fn person_needs_relay_list(pubkey: PublicKey) -> Freshness {
let staletime = Unixtime::now().unwrap().0
let staletime = Unixtime::now().0
- 60 * GLOBALS
.storage
.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
/// for this person from relays
pub fn metadata_fetch_initiated(&self, pubkeys: &[PublicKey]) {
let now = Unixtime::now().unwrap();
let now = Unixtime::now();
for pubkey in pubkeys {
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(
60 * GLOBALS
.storage
@ -274,7 +274,7 @@ impl People {
// Sync in from database first
self.create_all_if_missing(&[*pubkey])?;
let now = Unixtime::now().unwrap();
let now = Unixtime::now();
// Copy the person
let mut person =
@ -335,7 +335,7 @@ impl People {
.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 {
true
}
@ -701,7 +701,7 @@ impl People {
let pre_event = PreEvent {
pubkey: my_pubkey,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind,
tags: public_tags,
content,
@ -789,7 +789,7 @@ impl People {
.storage
.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(
PersonList::Muted,
&metadata,
@ -833,7 +833,7 @@ impl People {
}
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(
pubkey,

View File

@ -29,7 +29,7 @@ pub fn prepare_post_normal(
let pre_event = PreEvent {
pubkey: author,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind: EventKind::TextNote,
tags,
content,
@ -95,7 +95,7 @@ pub fn prepare_post_nip04(
let pre_event = PreEvent {
pubkey: author,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind: EventKind::EncryptedDirectMessage,
tags,
content,
@ -156,7 +156,7 @@ pub fn prepare_post_nip17(
let pre_event = PreEvent {
pubkey: author,
created_at: Unixtime::now().unwrap(),
created_at: Unixtime::now(),
kind: EventKind::DmChat,
tags,
content,

View File

@ -26,7 +26,7 @@ pub async fn process_new_event(
verify: bool,
process_even_if_duplicate: bool,
) -> Result<(), Error> {
let now = Unixtime::now()?;
let now = Unixtime::now();
// Bump count
GLOBALS.events_processed.fetch_add(1, Ordering::SeqCst);

View File

@ -29,7 +29,7 @@ pub struct SeekData {
impl SeekData {
fn new_event(climb: bool) -> SeekData {
SeekData {
start: Unixtime::now().unwrap(),
start: Unixtime::now(),
state: SeekState::WaitingEvent,
climb,
}
@ -37,7 +37,7 @@ impl SeekData {
fn new_relay_list(pubkey: PublicKey, climb: bool) -> SeekData {
SeekData {
start: Unixtime::now().unwrap(),
start: Unixtime::now(),
state: SeekState::WaitingRelayList(pubkey),
climb,
}
@ -236,7 +236,7 @@ impl Seeker {
// we save updates here and apply when the iterator is finished.
let mut updates: Vec<(Id, Option<SeekData>)> = Vec::new();
let now = Unixtime::now().unwrap();
let now = Unixtime::now();
for refmulti in self.events.iter() {
let id = *refmulti.key();

View File

@ -84,7 +84,7 @@ mod test {
fn test_event_akci_key() {
let pubkey = PrivateKey::generate().public_key();
let kind = EventKind::TextNote;
let created_at = Unixtime::now().unwrap();
let created_at = Unixtime::now();
let id = Id::try_from_hex_string(
"77f7653c67147a125cc624f695029d0557e3ab402e714680eb23dd2499f439a0",
)

View File

@ -88,7 +88,7 @@ mod test {
#[test]
fn test_event_kci_key() {
let kind = EventKind::TextNote;
let created_at = Unixtime::now().unwrap();
let created_at = Unixtime::now();
let id = Id::try_from_hex_string(
"77f7653c67147a125cc624f695029d0557e3ab402e714680eb23dd2499f439a0",
)

View File

@ -57,7 +57,7 @@ impl Storage {
last_edit_times
.get(&list)
.copied()
.unwrap_or(Unixtime::now().unwrap().0),
.unwrap_or(Unixtime::now().0),
),
..Default::default()
};

View File

@ -221,7 +221,7 @@ impl Storage {
.into());
}
let now = Unixtime::now().unwrap();
let now = Unixtime::now();
let mut ids: HashSet<Id> = HashSet::new();
let txn = self.env.read_txn()?;

View File

@ -833,7 +833,7 @@ impl Storage {
None => return Err(ErrorKind::ListNotFound.into()),
};
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)?;
Ok(())
}
@ -2112,7 +2112,7 @@ impl Storage {
write: bool,
min: usize,
) -> Result<Vec<(RelayUrl, u64)>, Error> {
let now = Unixtime::now().unwrap();
let now = Unixtime::now();
// Load person relays, filtering out banned URLs
let mut person_relays: Vec<PersonRelay> = self
@ -2499,7 +2499,7 @@ impl Storage {
) -> Result<(), Error> {
let f = |txn: &mut RwTxn<'a>| -> Result<(), Error> {
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)? {
metadata.last_edit_time = now;
metadata.len = 0;
@ -2553,7 +2553,7 @@ impl Storage {
let had = map.contains_key(&list);
map.insert(list, private);
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 !had {
metadata.len += 1;
@ -2580,7 +2580,7 @@ impl Storage {
let had = map.contains_key(&list);
map.remove(&list);
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 had && metadata.len > 0 {
metadata.len -= 1;

View File

@ -16,7 +16,7 @@ impl Default for PersonListMetadata1 {
PersonListMetadata1 {
dtag: "".to_owned(),
title: "".to_owned(),
last_edit_time: Unixtime::now().unwrap(),
last_edit_time: Unixtime::now(),
event_created_at: Unixtime(0),
event_public_len: 0,
event_private_len: None,

View File

@ -19,7 +19,7 @@ impl Default for PersonListMetadata2 {
PersonListMetadata2 {
dtag: "".to_owned(),
title: "".to_owned(),
last_edit_time: Unixtime::now().unwrap(),
last_edit_time: Unixtime::now(),
event_created_at: Unixtime(0),
event_public_len: 0,
event_private_len: None,

View File

@ -21,7 +21,7 @@ impl Default for PersonListMetadata3 {
PersonListMetadata3 {
dtag: "".to_owned(),
title: "".to_owned(),
last_edit_time: Unixtime::now().unwrap(),
last_edit_time: Unixtime::now(),
event_created_at: Unixtime(0),
event_public_len: 0,
event_private_len: None,

View File

@ -58,7 +58,7 @@ impl PersonRelay1 {
// 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.
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 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
// factors such as our relay rank or the success rate of the relay.
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 scorefn = |when: u64, fade_period: u64, base: u64| -> u64 {

View File

@ -163,7 +163,7 @@ impl Relay3 {
pub fn should_avoid(&self) -> bool {
if let Some(when) = self.avoid_until {
when >= Unixtime::now().unwrap()
when >= Unixtime::now()
} else {
false
}