generated from PaulRBerg/hardhat-template
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setup repositries struct for finding repositories
- Loading branch information
ktdlr
committed
Oct 18, 2024
1 parent
c8f31ea
commit 05e6d14
Showing
27 changed files
with
192 additions
and
348 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,8 @@ | ||
mod plaintext_aggregator; | ||
mod plaintext_repository; | ||
mod publickey_aggregator; | ||
mod publickey_repository; | ||
pub use plaintext_aggregator::{ | ||
PlaintextAggregator, PlaintextAggregatorParams, PlaintextAggregatorState, | ||
}; | ||
pub use plaintext_repository::*; | ||
pub use publickey_aggregator::{ | ||
PublicKeyAggregator, PublicKeyAggregatorParams, PublicKeyAggregatorState, | ||
}; | ||
pub use publickey_repository::*; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
packages/ciphernode/aggregator/src/plaintext_repository.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
packages/ciphernode/aggregator/src/publickey_repository.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,55 @@ | ||
use std::{marker::PhantomData, ops::Deref}; | ||
|
||
use anyhow::Result; | ||
use async_trait::async_trait; | ||
|
||
use crate::DataStore; | ||
|
||
#[async_trait] | ||
pub trait Repository { | ||
type State: for<'de> serde::Deserialize<'de> + serde::Serialize; | ||
fn store(&self) -> DataStore; | ||
pub struct Repository<S> { | ||
store: DataStore, | ||
_p: PhantomData<S>, | ||
} | ||
|
||
impl<S> Repository<S> { | ||
pub fn new(store: DataStore) -> Self { | ||
Self { | ||
store, | ||
_p: PhantomData, | ||
} | ||
} | ||
} | ||
|
||
impl<S> Deref for Repository<S>{ | ||
type Target = DataStore; | ||
fn deref(&self) -> &Self::Target { | ||
&self.store | ||
} | ||
} | ||
|
||
impl<S> From<Repository<S>> for DataStore { | ||
fn from(value: Repository<S>) -> Self { | ||
value.store | ||
} | ||
} | ||
|
||
/// Clone without phantom data | ||
impl<S> Clone for Repository<S> { | ||
fn clone(&self) -> Self { | ||
Self { | ||
store: self.store.clone(), | ||
_p: PhantomData, | ||
} | ||
} | ||
} | ||
|
||
async fn read(&self) -> Result<Option<Self::State>> { | ||
self.store().read().await | ||
impl<T> Repository<T> | ||
where | ||
T: for<'de> serde::Deserialize<'de> + serde::Serialize, | ||
{ | ||
pub async fn read(&self) -> Result<Option<T>> { | ||
self.store.read().await | ||
} | ||
|
||
fn write(&self, value: &Self::State) { | ||
self.store().write(value) | ||
pub fn write(&self, value: &T) { | ||
self.store.write(value) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
mod fhe; | ||
mod repository; | ||
mod utils; | ||
|
||
pub use fhe::*; | ||
pub use repository::*; | ||
pub use utils::*; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
mod keyshare; | ||
mod repository; | ||
pub use keyshare::*; | ||
pub use repository::*; |
Oops, something went wrong.