Commit ca3c303e authored by Benjamin Kampmann's avatar Benjamin Kampmann Committed by Hero Bird

Rename Enzyme project to Subpeep

parent bc711cb8
......@@ -4,7 +4,7 @@ members = [
"pdsl_core",
# "pdsl_derive",
"pdsl_tests",
"examples/enzyme",
"examples/subpeep",
]
[profile.release]
......
[package]
name = "enzyme"
name = "subpeep"
version = "0.1.0"
authors = ["Robin Freyler <robin@parity.io>", "Parity Technologies <admin@parity.io>"]
edition = "2018"
......@@ -14,7 +14,7 @@ wee_alloc = "0.4"
lazy_static = "1.2"
[lib]
name = "enzyme"
name = "subpeep"
[features]
default = []
......
# Enzyme
# Subpeep
Decentralized message distribution inspired by Twitter.
......
......@@ -41,7 +41,7 @@ impl UserData {
///
/// The `CellChunkAlloc` should be preferred here since
/// allocations of this type are dynamic. For this reason
/// the `Enzyme` type has a built-in `CellChunkAlloc`.
/// the `Subpeep` type has a built-in `CellChunkAlloc`.
pub unsafe fn new_using_alloc<A>(alloc: &mut A) -> Self
where
A: storage::Allocator
......@@ -53,8 +53,8 @@ impl UserData {
}
}
/// The entire enzyme contract.
pub struct Enzyme {
/// The entire subpeep contract.
pub struct Subpeep {
/// All tweets done by all users.
tweets: storage::Vec<Tweet>,
/// Database of all registered users and their data.
......@@ -63,18 +63,18 @@ pub struct Enzyme {
alloc: storage::alloc::CellChunkAlloc,
}
impl Default for Enzyme {
impl Default for Subpeep {
fn default() -> Self {
unsafe {
Enzyme::new_using_alloc(
Subpeep::new_using_alloc(
&mut* utils::STORAGE_ALLOC.lock().unwrap()
)
}
}
}
impl Enzyme {
/// Creates new enzyme platform using the given allocator.
impl Subpeep {
/// Creates new subpeep platform using the given allocator.
///
/// # Note
///
......
......@@ -2,30 +2,30 @@ use super::*;
#[test]
fn deploy() {
let enzyme = Enzyme::default();
let subpeep = Subpeep::default();
assert_eq!(
enzyme.recent_tweets(10),
subpeep.recent_tweets(10),
vec![]
);
assert_eq!(
enzyme.recent_user_tweets(10, "alice"),
subpeep.recent_user_tweets(10, "alice"),
None
);
}
#[test]
fn tweet_message() {
let mut enzyme = Enzyme::default();
let mut subpeep = Subpeep::default();
let test_user = "Alice";
let test_message = "Hello, World!";
enzyme.register(test_user.into());
enzyme.tweet_message(test_user.into(), test_message.into());
subpeep.register(test_user.into());
subpeep.tweet_message(test_user.into(), test_message.into());
assert_eq!(
enzyme.recent_tweets(10),
subpeep.recent_tweets(10),
vec![Tweet::new(test_user.into(), test_message.into())],
);
assert_eq!(
enzyme.recent_user_tweets(10, test_user.into()),
subpeep.recent_user_tweets(10, test_user.into()),
Some(vec![
Tweet::new(test_user.into(), test_message.into())
])
......
......@@ -37,7 +37,7 @@ lazy_static! {
};
}
/// Enzyme API.
/// Subpeep API.
#[derive(Encode, Decode)]
enum Action {
/// Register a new user.
......@@ -61,16 +61,16 @@ pub extern "C" fn call() {
let input = ContractEnv::input();
let action = Action::decode(&mut &input[..]).unwrap();
let mut enzyme = crate::Enzyme::default();
let mut subpeep = crate::Subpeep::default();
match action {
Action::Register{username} => {
enzyme.register(&username);
subpeep.register(&username);
}
Action::TweetMessage{username, message} => {
enzyme.tweet_message(&username, &message)
subpeep.tweet_message(&username, &message)
}
Action::Follow{following, followed} => {
enzyme.follow(&following, &followed)
subpeep.follow(&following, &followed)
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment