Migrate to `localtime` from `nakamoto`

The only thing we needed nakamoto for was `LocalTime`.

Signed-off-by: Alexis Sellier <self@cloudhead.io>
This commit is contained in:
Alexis Sellier 2023-01-18 18:03:11 +01:00
parent d25c47ad0e
commit 3bc07195f5
No known key found for this signature in database
11 changed files with 16 additions and 30 deletions

19
Cargo.lock generated
View File

@ -1570,6 +1570,12 @@ version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f"
[[package]]
name = "localtime"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b58b1a2626b0920eec1d591e94c4feb3d1353695faad25c38f2a3c3efaf3db19"
[[package]]
name = "log"
version = "0.4.17"
@ -1645,17 +1651,6 @@ dependencies = [
"data-encoding-macro",
]
[[package]]
name = "nakamoto-net"
version = "0.3.0"
source = "git+https://github.com/cloudhead/nakamoto?rev=90cc3eac67aa5cfd5f42cf7cb1e2b155af3214fb#90cc3eac67aa5cfd5f42cf7cb1e2b155af3214fb"
dependencies = [
"crossbeam-channel",
"fastrand",
"log",
"thiserror",
]
[[package]]
name = "netservices"
version = "0.1.0"
@ -2290,8 +2285,8 @@ dependencies = [
"git-ref-format",
"io-reactor",
"lexopt",
"localtime",
"log",
"nakamoto-net",
"netservices",
"nonempty 0.8.1",
"qcheck",

View File

@ -28,11 +28,6 @@ inherits = "release"
debug = true
incremental = false
[patch.crates-io.nakamoto-net]
git = "https://github.com/cloudhead/nakamoto"
rev = "90cc3eac67aa5cfd5f42cf7cb1e2b155af3214fb"
version = "0.3.0"
[patch.crates-io.io-reactor]
git = "https://github.com/rust-amplify/io-reactor"
rev = "6148aec926c82f08373687d1a9da07a2bca67ea3"

View File

@ -21,7 +21,7 @@ fastrand = { version = "1.8.0" }
git-ref-format = { version = "0", features = ["serde", "macro"] }
lexopt = { version = "0.2.1" }
log = { version = "0.4.17", features = ["std"] }
nakamoto-net = { version = "0.3.0" }
localtime = { version = "1" }
netservices = { version = "0", features = ["io-reactor", "socket2", "log"] }
nonempty = { version = "0.8.1", features = ["serialize"] }
io-reactor = { version = "0", features = ["popol", "socket2"] }

View File

@ -46,9 +46,6 @@ pub enum Error {
/// An I/O error.
#[error("i/o error: {0}")]
Io(#[from] io::Error),
/// A networking error.
#[error("network error: {0}")]
Net(#[from] nakamoto_net::error::Error),
/// A control socket error.
#[error("control socket error: {0}")]
Control(#[from] control::Error),

View File

@ -14,7 +14,7 @@ pub mod tests;
pub mod wire;
pub mod worker;
pub use nakamoto_net::{Io, LocalDuration, LocalTime};
pub use localtime::{LocalDuration, LocalTime};
pub use netservices::LinkDirection as Link;
pub use radicle::{collections, crypto, git, identity, node, profile, rad, storage};

View File

@ -2,7 +2,7 @@ use std::{env, net, process};
use anyhow::Context as _;
use cyphernet::addr::PeerAddr;
use nakamoto_net::LocalDuration;
use localtime::LocalDuration;
use radicle::profile;
use radicle_node::client::Runtime;

View File

@ -16,9 +16,8 @@ use std::{fmt, io, net, str};
use crossbeam_channel as chan;
use fastrand::Rng;
use localtime::{LocalDuration, LocalTime};
use log::*;
use nakamoto::{LocalDuration, LocalTime};
use nakamoto_net as nakamoto;
use nonempty::NonEmpty;
use radicle::node::{Address, Features};
use radicle::storage::{Namespaces, ReadStorage};
@ -395,7 +394,7 @@ where
Ok(())
}
pub fn tick(&mut self, now: nakamoto::LocalTime) {
pub fn tick(&mut self, now: LocalTime) {
trace!("Tick +{}", now - self.start_time);
self.clock = now;

View File

@ -1,4 +1,4 @@
use super::nakamoto::LocalDuration;
use localtime::LocalDuration;
use radicle::node::Address;

View File

@ -196,7 +196,7 @@ impl Store for Table {
#[cfg(test)]
mod test {
use nakamoto_net::LocalTime;
use localtime::LocalTime;
use super::*;
use crate::test::arbitrary;

View File

@ -9,8 +9,8 @@ use std::rc::Rc;
use std::sync::Arc;
use std::{fmt, io};
use localtime::{LocalDuration, LocalTime};
use log::*;
use nakamoto_net::{LocalDuration, LocalTime};
use crate::crypto::Signer;
use crate::prelude::Address;

View File

@ -12,7 +12,7 @@ use std::{fmt, io, net};
use amplify::Wrapper as _;
use crossbeam_channel as chan;
use cyphernet::{Cert, Digest, EcSign, Sha256};
use nakamoto_net::LocalTime;
use localtime::LocalTime;
use netservices::resource::{ListenerEvent, NetAccept, NetTransport, SessionEvent};
use netservices::session::ProtocolArtifact;
use netservices::session::{CypherReader, CypherSession, CypherWriter};