-
Notifications
You must be signed in to change notification settings - Fork 165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add iroh-sync and integrate into iroh node #1333
Changes from 113 commits
3340613
867d741
f5c51c0
230a362
350a486
e8e9158
9a9266e
b1868ad
607fd81
a0f96db
e0e062c
6347541
82d4589
94163c7
7240fc5
069a53b
ce9d809
2c9aa58
5a627b9
5899d0e
43eff25
33883f8
b487671
e56e7aa
b4358dd
c700721
6bdfaf6
27e0923
6745dfa
aeda868
4de81b6
494748b
193a33a
b0a7ab0
fb693b1
56fb90c
e4fca32
b33d3ef
cd17db8
722df34
f0d9ef2
111b117
59077b1
437c031
481b771
8da512f
c76a1da
7784510
d1caf19
f80617a
134477a
5880f50
e911696
d021455
c78fb5b
c039f72
910fd87
f03b061
1f864b5
961bd3d
67dd342
cb24396
75679db
69951d2
4d87cd3
14ce536
610d09f
a16ec9a
ac5240e
3bc1483
9d5d06a
23d138b
cc4c5a9
d05e32c
ef0892d
a285c6d
96c9a43
fbfdd27
6daef61
e596d7b
ec4e619
35f3218
4429435
d15b61d
4c649c1
ac2bd41
07653ca
925ff83
f5c0dd9
c08fef8
0287d4d
a8e8093
839a855
cde53c3
fc91c5e
ff90fe6
1fb6f8f
b666f87
4b50b64
337fc1d
4df7796
b103077
036c168
b990a72
a3bd92e
b2a92f1
5bf0e9e
05035e3
e655828
6615092
6fa839d
ab2d2db
629289b
3779d27
f6f9f9c
0968384
452059b
bbdf7bf
f571631
f065781
f00db58
5e12659
2c540be
136a994
23911fc
e44fb83
0d432da
502da40
a63fbf8
3339add
b4d2164
fe781be
264dadf
503ff23
0e3f169
c50bf53
d206252
8d803b0
248f6b3
3921eac
39fda80
7690287
0bc1efb
b7c7623
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ members = [ | |
"iroh-bytes", | ||
"iroh-gossip", | ||
"iroh-metrics", | ||
"iroh-sync", | ||
] | ||
|
||
[profile.release] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,6 +50,18 @@ impl PublicKey { | |
self.public.as_bytes() | ||
} | ||
|
||
/// Construct a `PublicKey` from a slice of bytes. | ||
/// | ||
/// # Warning | ||
/// | ||
/// This will return a [`SignatureError`] if the bytes passed into this method do not represent | ||
/// a valid `ed25519_dalek` curve point. Will never fail for bytes return from [`Self::as_bytes`]. | ||
/// See [`VerifyingKey::from_bytes`] for details. | ||
pub fn from_bytes(bytes: &[u8; 32]) -> Result<Self, SignatureError> { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really needed when we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For me having a from_bytes method seems convenient. Eg all the |
||
let public = VerifyingKey::from_bytes(bytes)?; | ||
Ok(public.into()) | ||
} | ||
|
||
fn public_crypto_box(&self) -> crypto_box::PublicKey { | ||
crypto_box::PublicKey::from_bytes(self.public_crypto_box) | ||
} | ||
|
@@ -74,6 +86,15 @@ impl TryFrom<&[u8]> for PublicKey { | |
} | ||
} | ||
|
||
impl TryFrom<&[u8; 32]> for PublicKey { | ||
type Error = SignatureError; | ||
|
||
#[inline] | ||
fn try_from(bytes: &[u8; 32]) -> Result<Self, Self::Error> { | ||
Self::from_bytes(bytes) | ||
} | ||
} | ||
|
||
impl AsRef<[u8]> for PublicKey { | ||
fn as_ref(&self) -> &[u8] { | ||
self.as_bytes() | ||
|
@@ -233,6 +254,12 @@ impl SecretKey { | |
self.secret.to_bytes() | ||
} | ||
|
||
/// Create a secret key from its byte representation. | ||
pub fn from_bytes(bytes: &[u8; 32]) -> Self { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
let secret = SigningKey::from_bytes(bytes); | ||
secret.into() | ||
} | ||
|
||
fn secret_crypto_box(&self) -> &crypto_box::SecretKey { | ||
self.secret_crypto_box | ||
.get_or_init(|| secret_ed_box(&self.secret)) | ||
|
@@ -250,8 +277,7 @@ impl From<SigningKey> for SecretKey { | |
|
||
impl From<[u8; 32]> for SecretKey { | ||
fn from(value: [u8; 32]) -> Self { | ||
let secret = SigningKey::from(value); | ||
secret.into() | ||
Self::from_bytes(&value) | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
[package] | ||
name = "iroh-sync" | ||
version = "0.5.1" | ||
edition = "2021" | ||
readme = "README.md" | ||
description = "Iroh sync" | ||
license = "MIT/Apache-2.0" | ||
authors = ["n0 team"] | ||
repository = "https://github.com/n0-computer/iroh" | ||
|
||
Frando marked this conversation as resolved.
Show resolved
Hide resolved
|
||
[dependencies] | ||
anyhow = "1" | ||
blake3 = { package = "iroh-blake3", version = "1.4.3"} | ||
crossbeam = "0.8.2" | ||
derive_more = { version = "1.0.0-beta.1", features = ["debug", "display", "from", "try_into"] } | ||
ed25519-dalek = { version = "2.0.0", features = ["serde", "rand_core"] } | ||
flume = "0.10" | ||
iroh-bytes = { version = "0.5.0", path = "../iroh-bytes" } | ||
iroh-metrics = { version = "0.5.0", path = "../iroh-metrics", optional = true } | ||
flub marked this conversation as resolved.
Show resolved
Hide resolved
|
||
once_cell = "1.18.0" | ||
postcard = { version = "1", default-features = false, features = ["alloc", "use-std", "experimental-derive"] } | ||
rand = "0.8.5" | ||
rand_core = "0.6.4" | ||
serde = { version = "1.0.164", features = ["derive"] } | ||
url = "2.4" | ||
bytes = "1" | ||
parking_lot = "0.12.1" | ||
hex = "0.4" | ||
|
||
# fs-store | ||
redb = { version = "1.0.5", optional = true } | ||
ouroboros = { version = "0.17", optional = true } | ||
|
||
[dev-dependencies] | ||
tokio = { version = "1", features = ["sync", "macros"] } | ||
tempfile = "3.4" | ||
|
||
[features] | ||
default = ["fs-store", "metrics"] | ||
fs-store = ["redb", "ouroboros"] | ||
metrics = ["iroh-metrics"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The choice to use a field for
me
but put the event in the message is odd. why not make both of them fields? (applies for all added logging calls here)Also:
is an equivalent shorthand and should probably be preferred if the field name is the same as the variable name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those were not added in this PR but in #1149.
me
is a field because it is a simple type (32 byte peer id) whereasevent
is a complex type (enum with tuple variantes and potentially a lot of data in them) so I thought debug-printing makes more sense. But also I'm not really sure when to use fields vs debug logging in tracing. I created a separate PR for this as its unrelated to this PR: #1390