Skip to content

Commit

Permalink
feat(storage): new store implementation (ethereum#1183)
Browse files Browse the repository at this point in the history
  • Loading branch information
morph-dev authored Feb 27, 2024
1 parent 476cb76 commit 9c05c64
Show file tree
Hide file tree
Showing 27 changed files with 1,647 additions and 266 deletions.
114 changes: 41 additions & 73 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ utp-rs = { git = "https://github.com/ethereum/utp", tag = "v0.1.0-alpha.9" }
ethers-core = { version = "2.0", default-features = false}
ethers-providers = { version = "2.0", default-features = false, features = ["ipc"] }
ethportal-peertest = { path = "ethportal-peertest" }
serde_yaml = "0.9.25"
serde_yaml = "0.9"
serial_test = "0.5.1"
ureq = { version = "2.5.0", features = ["json"] }

Expand Down
4 changes: 2 additions & 2 deletions ethportal-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ ruint = { version = "1.9.0", features = ["primitive-types"] }
serde = { version = "1.0.150", features = ["derive"] }
serde_json = "1.0.89"
serde-this-or-that = "0.4.2"
serde_yaml = "0.9.17"
serde_yaml = "0.9"
sha2 = "0.10.1"
sha3 = "0.9.1"
snap = "1.1.0"
Expand All @@ -53,7 +53,7 @@ validator = { version = "0.13.0", features = ["derive"] }
[dev-dependencies]
env_logger = "0.9.0"
quickcheck = "1.0.3"
rstest = "0.16.0"
rstest = "0.18.2"
test-log = { version = "0.2.11", features = ["trace"] }
tracing = "0.1.36"
tracing-subscriber = "0.3.15"
16 changes: 14 additions & 2 deletions ethportal-api/src/types/content_key/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{
utils::bytes::{hex_decode, hex_encode, hex_encode_compact},
};
use quickcheck::{Arbitrary, Gen};
use std::fmt;
use std::{fmt, ops::Deref};

/// Types whose values represent keys to lookup content items in an overlay network.
/// Keys are serializable.
Expand All @@ -29,7 +29,7 @@ pub trait OverlayContentKey:

/// A content key type whose content id is the inner value. Allows for the construction
/// of a content key with an arbitrary content ID.
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct IdentityContentKey {
value: [u8; 32],
}
Expand All @@ -39,6 +39,10 @@ impl IdentityContentKey {
pub fn new(value: [u8; 32]) -> Self {
Self { value }
}

pub fn random() -> Self {
Self::new(rand::random())
}
}

impl Arbitrary for IdentityContentKey {
Expand Down Expand Up @@ -88,6 +92,14 @@ impl Into<Vec<u8>> for IdentityContentKey {
}
}

impl Deref for IdentityContentKey {
type Target = [u8; 32];

fn deref(&self) -> &Self::Target {
&self.value
}
}

impl OverlayContentKey for IdentityContentKey {
fn content_id(&self) -> [u8; 32] {
self.value
Expand Down
Loading

0 comments on commit 9c05c64

Please sign in to comment.