Skip to content

Commit

Permalink
fix(verkle): store generics refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
morph-dev committed Jul 7, 2024
1 parent 7f36df5 commit a62240c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions trin-verkle/src/storage.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use ethportal_api::{
types::{distance::Distance, portal_wire::ProtocolId, verkle::PaginateLocalContentInfo},
OverlayContentKey,
OverlayContentKey, VerkleContentKey,
};
use trin_storage::{
error::ContentStoreError,
Expand All @@ -11,26 +11,24 @@ use trin_storage::{
/// Storage layer for the verkle network. Encapsulates verkle network specific data and logic.
#[derive(Debug)]
pub struct VerkleStorage {
store: IdIndexedV1Store,
store: IdIndexedV1Store<VerkleContentKey>,
}

impl ContentStore for VerkleStorage {
fn get<K: OverlayContentKey>(&self, key: &K) -> Result<Option<Vec<u8>>, ContentStoreError> {
type Key = VerkleContentKey;

fn get(&self, key: &Self::Key) -> Result<Option<Vec<u8>>, ContentStoreError> {
self.store.lookup_content_value(&key.content_id().into())
}

fn put<K: OverlayContentKey, V: AsRef<[u8]>>(
&mut self,
_key: K,
_value: V,
) -> Result<(), ContentStoreError> {
fn put<V: AsRef<[u8]>>(&mut self, _key: Self::Key, _value: V) -> Result<(), ContentStoreError> {
// TODO: add verkle specific implementation
todo!()
}

fn is_key_within_radius_and_unavailable<K: OverlayContentKey>(
fn is_key_within_radius_and_unavailable(
&self,
key: &K,
key: &Self::Key,
) -> Result<ShouldWeStoreContent, ContentStoreError> {
let content_id = ContentId::from(key.content_id());
if self.store.distance_to_content_id(&content_id) > self.store.radius() {
Expand Down

0 comments on commit a62240c

Please sign in to comment.