Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

Commit

Permalink
rename protobuf3 modules to ddml
Browse files Browse the repository at this point in the history
  • Loading branch information
semenov-vladyslav committed Aug 26, 2020
1 parent 930de1c commit e617150
Show file tree
Hide file tree
Showing 35 changed files with 90 additions and 83 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ members = [
"iota-streams-core",
"iota-streams-core-edsig",
"iota-streams-core-keccak",
"iota-streams-protobuf3",
"iota-streams-ddml",
"iota-streams-app",
"iota-streams-app-channels",
"iota-streams-app-channels-example",
Expand All @@ -29,7 +29,7 @@ members = [
iota-streams-core = { version = "0.2.0", path = "iota-streams-core" }
iota-streams-core-keccak = { version = "0.2.0", path = "iota-streams-core-keccak" }
iota-streams-core-edsig = { version = "0.2.0", path = "iota-streams-core-edsig" }
iota-streams-protobuf3 = { version = "0.2.0", path = "iota-streams-protobuf3" }
iota-streams-ddml = { version = "0.2.0", path = "iota-streams-ddml" }
iota-streams-app = { version = "0.2.0", path = "iota-streams-app" }
iota-streams-app-channels = { version = "0.2.0", path = "iota-streams-app-channels" }

Expand Down
4 changes: 2 additions & 2 deletions iota-streams-app-channels/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description = "A rust implementation of the IOTA Streams Channels Application"
[features]
default = ["std", "async", "tangle"]
# enable std
std = ["iota-streams-core/std", "iota-streams-core-edsig/std", "iota-streams-protobuf3/std", "iota-streams-app/std", "anyhow/std"]
std = ["iota-streams-core/std", "iota-streams-core-edsig/std", "iota-streams-ddml/std", "iota-streams-app/std", "anyhow/std"]
async = ["iota-streams-app/async"]
tangle = ["iota-streams-app/tangle"]

Expand All @@ -23,6 +23,6 @@ path = "src/lib.rs"
iota-streams-core = { version = "0.2.0", path = "../iota-streams-core", default-features = false }
iota-streams-core-edsig = { version = "0.2.0", path = "../iota-streams-core-edsig", default-features = false }
iota-streams-core-keccak = { version = "0.2.0", path = "../iota-streams-core-keccak", default-features = false }
iota-streams-protobuf3 = { version = "0.2.0", path = "../iota-streams-protobuf3", default-features = false }
iota-streams-ddml = { version = "0.2.0", path = "../iota-streams-ddml", default-features = false }
iota-streams-app = { version = "0.2.0", path = "../iota-streams-app", default-features = false }
anyhow = { version = "1.0.26", default-features = false }
2 changes: 1 addition & 1 deletion iota-streams-app-channels/examples/basic_scenario.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use iota_streams_app_channels::{
message,
};
use iota_streams_core::tbits::Tbits;
use iota_streams_protobuf3::types::Trytes;
use iota_streams_ddml::types::Trytes;
use std::str::FromStr;

fn example<T: Transport>(transport: &mut T, send_opt: T::SendOptions, recv_opt: T::RecvOptions) -> Result<()>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use iota_streams_app_channels::{
},
message,
};
use iota_streams_protobuf3::types::*;
use iota_streams_ddml::types::*;

use anyhow::{
ensure,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use iota_streams_app_channels::{
},
message,
};
use iota_streams_protobuf3::types::*;
use iota_streams_ddml::types::*;

use anyhow::{
ensure,
Expand Down
14 changes: 6 additions & 8 deletions iota-streams-app-channels/src/api/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use iota_streams_app::message::{
header::Header,
*,
};
use iota_streams_protobuf3::types::*;
use iota_streams_ddml::types::*;

use super::*;
use crate::message::*;
Expand Down Expand Up @@ -561,8 +561,8 @@ where
}
}

pub fn get_branching_flag<'a>(&self) -> &u8 {
&self.multi_branching
pub fn get_branching_flag(&self) -> u8 {
self.multi_branching
}

pub fn gen_msg_id(&mut self, link: &<Link as HasLink>::Rel, pk: x25519::PublicKey, seq: usize) -> Link {
Expand All @@ -579,11 +579,9 @@ where
self.seq_states.insert(pubkey.as_bytes().to_vec(), (msg_link, seq_num));
}

/// Retrieve the sequence state fo a given publisher
pub fn get_seq_state(&self, pubkey: x25519::PublicKey) -> Result<(Link, usize)> {
let seq_link = self.seq_states.get(&pubkey.as_bytes().to_vec()).unwrap().0.clone();
let seq_num = self.seq_states.get(&pubkey.as_bytes().to_vec()).unwrap().1;
Ok((seq_link, seq_num))
/// Retrieve the sequence state for a given publisher
pub fn get_seq_state(&self, pubkey: x25519::PublicKey) -> Option<(Link, usize)> {
self.seq_states.get(&pubkey.as_bytes().to_vec()).cloned()
}

pub fn get_seq_num(&self) -> usize {
Expand Down
2 changes: 1 addition & 1 deletion iota-streams-app-channels/src/api/subscriber.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use iota_streams_app::message::{
header::Header,
*,
};
use iota_streams_protobuf3::types::*;
use iota_streams_ddml::types::*;

use super::*;
use crate::message::*;
Expand Down
6 changes: 3 additions & 3 deletions iota-streams-app-channels/src/api/tangle/author.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl Author {
let sequenced: Option<Message>;
let (seq_link, seq_num) = self.imp.get_seq_state(self.imp.ke_kp.1).unwrap();

if self.imp.get_branching_flag() == &1_u8 {
if self.imp.get_branching_flag() == 1_u8 {
let msg = self
.imp
.sequence(
Expand Down Expand Up @@ -115,7 +115,7 @@ impl Author {
self.imp.store_state(pk, link, seq_num);
}

pub fn get_seq_state(&mut self, pk: x25519::PublicKey) -> Result<(Address, usize)> {
pub fn get_seq_state(&mut self, pk: x25519::PublicKey) -> Option<(Address, usize)> {
self.imp.get_seq_state(pk)
}

Expand Down Expand Up @@ -174,7 +174,7 @@ impl Author {
Ok(msg_id)
}

pub fn get_branching_flag<'a>(&self) -> &u8 {
pub fn get_branching_flag(&self) -> u8 {
self.imp.get_branching_flag()
}

Expand Down
4 changes: 2 additions & 2 deletions iota-streams-app-channels/src/api/tangle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use iota_streams_core_edsig::{
signature::ed25519,
};
use iota_streams_core_keccak::sponge::prp::keccak::KeccakF1600;
use iota_streams_protobuf3::{
use iota_streams_ddml::{
types as pb3_types,
types::DefaultLinkStore,
};
Expand Down Expand Up @@ -69,4 +69,4 @@ pub use author::Author;
/// Tangle-specific Channel Subscriber type.
pub use subscriber::Subscriber;

mod test;
pub mod test;
19 changes: 10 additions & 9 deletions iota-streams-app-channels/src/api/tangle/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@ use anyhow::{
Result,
};
use iota_streams_app::message::HasLink;
use iota_streams_protobuf3::types::*;
use iota_streams_core::prelude::str::FromStr;
use iota_streams_ddml::types::*;
use core::str::FromStr;
use iota_streams_core::prelude::string::ToString;

fn example<T: Transport>(transport: &mut T) -> Result<()>
pub fn example<T: Transport>(transport: &mut T) -> Result<()>
where
T::SendOptions: Default,
T::RecvOptions: Default,
{
let mut author = Author::new("AUTHOR9SEED");
let mut author = Author::new("AUTHOR9SEED", false);

let mut subscriberA = Subscriber::new("SUBSCRIBERA9SEED");
let mut subscriberB = Subscriber::new("SUBSCRIBERB9SEED");
Expand Down Expand Up @@ -77,7 +78,7 @@ where

println!("sign packet");
let signed_packet_link = {
let msg = author.sign_packet(&announcement_link, &public_payload, &masked_payload)?;
let (msg, _) = author.sign_packet(&announcement_link, &public_payload, &masked_payload)?;
println!(" {}", msg);
transport.send_message(&msg)?;
msg.link.clone()
Expand Down Expand Up @@ -116,7 +117,7 @@ where

println!("share keyload for everyone");
let keyload_link = {
let msg = author.share_keyload_for_everyone(&announcement_link)?;
let (msg, _) = author.share_keyload_for_everyone(&announcement_link)?;
println!(" {}", msg);
transport.send_message(&msg)?;
msg.link
Expand All @@ -136,7 +137,7 @@ where

println!("tag packet");
let tagged_packet_link = {
let msg = author.tag_packet(&keyload_link, &public_payload, &masked_payload)?;
let (msg, _) = author.tag_packet(&keyload_link, &public_payload, &masked_payload)?;
println!(" {}", msg);
transport.send_message(&msg)?;
msg.link.clone()
Expand Down Expand Up @@ -165,14 +166,14 @@ where

// println!("unsubscribe");
// let unsubscribe_link = {
// let msg = subscriberB.unsubscribe(&subscribeB_link)?;
// let (msg, _) = subscriberB.unsubscribe(&subscribeB_link)?;
// println!(" {}", msg);
// transport.send_message(&msg)?;
// msg.link
// };
//
// {
// let msg = transport.recv_message(&unsubscribe_link)?;
// let (msg, _) = transport.recv_message(&unsubscribe_link)?;
// let preparsed = msg.parse_header()?;
// ensure!(preparsed.check_content_type(message::unsubscribe::TYPE));
// author.unwrap_unsubscribe(preparsed)?;
Expand Down
2 changes: 1 addition & 1 deletion iota-streams-app-channels/src/message/announce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use iota_streams_core_edsig::{
key_exchange::x25519,
signature::ed25519,
};
use iota_streams_protobuf3::{
use iota_streams_ddml::{
command::*,
io,
types::*,
Expand Down
2 changes: 1 addition & 1 deletion iota-streams-app-channels/src/message/keyload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ use iota_streams_core::{
},
};
use iota_streams_core_edsig::key_exchange::x25519;
use iota_streams_protobuf3::{
use iota_streams_ddml::{
command::*,
io,
types::*,
Expand Down
2 changes: 1 addition & 1 deletion iota-streams-app-channels/src/message/sequence.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use anyhow::Result;

use iota_streams_core::sponge::prp::PRP;
use iota_streams_core_edsig::key_exchange::x25519;
use iota_streams_protobuf3::{
use iota_streams_ddml::{
command::*,
io,
types::*,
Expand Down
2 changes: 1 addition & 1 deletion iota-streams-app-channels/src/message/signed_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ use iota_streams_app::message::{
};
use iota_streams_core::sponge::prp::PRP;
use iota_streams_core_edsig::signature::ed25519;
use iota_streams_protobuf3::{
use iota_streams_ddml::{
command::*,
io,
types::*,
Expand Down
2 changes: 1 addition & 1 deletion iota-streams-app-channels/src/message/subscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ use iota_streams_core_edsig::{
key_exchange::x25519,
signature::ed25519,
};
use iota_streams_protobuf3::{
use iota_streams_ddml::{
command::*,
io,
types::*,
Expand Down
2 changes: 1 addition & 1 deletion iota-streams-app-channels/src/message/tagged_packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ use iota_streams_core::sponge::{
prp::PRP,
spongos,
};
use iota_streams_protobuf3::{
use iota_streams_ddml::{
command::*,
io,
types::*,
Expand Down
2 changes: 1 addition & 1 deletion iota-streams-app-channels/src/message/unsubscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ use iota_streams_core::{
word::SpongosTbitWord,
},
};
use iota_streams_protobuf3::{
use iota_streams_ddml::{
command::*,
io,
types::*,
Expand Down
4 changes: 2 additions & 2 deletions iota-streams-app/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description = "A rust implementation of the IOTA Streams applications"
[features]
default = ["std", "async", "tangle"]
# enable std
std = ["iota-streams-core/std", "iota-streams-core-edsig/std", "iota-streams-protobuf3/std", "anyhow/std", "hex/std", "chrono/std"]
std = ["iota-streams-core/std", "iota-streams-core-edsig/std", "iota-streams-ddml/std", "anyhow/std", "hex/std", "chrono/std"]
async = ["iota-core", "iota-constants", "chrono", "smol", "num_cpus"]
#TODO: move to a separate crate
# iota-core currently provides async only API
Expand All @@ -24,7 +24,7 @@ path = "src/lib.rs"
[dependencies]
iota-streams-core = { version = "0.2.0", path = "../iota-streams-core", default-features = false }
iota-streams-core-edsig = { version = "0.2.0", path = "../iota-streams-core-edsig", default-features = false }
iota-streams-protobuf3 = { version = "0.2.0", path = "../iota-streams-protobuf3", default-features = false }
iota-streams-ddml = { version = "0.2.0", path = "../iota-streams-ddml", default-features = false }
# `iota-core` crate is WIP with unstable API atm of writing.
iota-core = { git = "https://github.com/iotaledger/iota.rs", rev = "03cf531", optional = true }
iota-constants = { version = "0.2.1", optional = true }
Expand Down
8 changes: 4 additions & 4 deletions iota-streams-app/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
//! # Streams Application
//! Streams Application is a message-oriented cryptographic protocol. Application
//! defines protocol parties, their roles, syntax and semantic of protocol messages.
//! Messages are declared in Protobuf3 syntax and are processed according to
//! Protobuf3 rules. Streams Message consists of Header and Application-specific Content.
//! Messages are declared in DDML syntax and are processed according to
//! DDML rules. Streams Message consists of Header and Application-specific Content.
//!
//! # Channel Application
//! Channel Application has evolved from previous versions of Streams. There are two
Expand All @@ -18,8 +18,8 @@
//! There are a few known issues that araise in practice. Streams v1.1 makes an attempt
//! at tackling them by tweaking run-time and compile-time parameters. If Channel
//! Application is not suitable for your needs you can implement your own Application,
//! and Protobuf3 implementation as a EDSL allows you to easily wrap and unwrap
//! messages of your Application. And when Protobuf3 is not powerful enough,
//! and DDML implementation as a EDSL allows you to easily wrap and unwrap
//! messages of your Application. And when DDML is not powerful enough,
//! it can be extended with custom commands.
#![no_std]
Expand Down
4 changes: 2 additions & 2 deletions iota-streams-app/src/message/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ use iota_streams_core::{
prelude::Vec,
sponge::prp::PRP,
};
use iota_streams_protobuf3 as protobuf3;
use protobuf3::{
use iota_streams_ddml as ddml;
use ddml::{
command::*,
io,
types::*,
Expand Down
2 changes: 1 addition & 1 deletion iota-streams-app/src/message/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use anyhow::Result;

use iota_streams_protobuf3::{
use iota_streams_ddml::{
command::{
sizeof,
unwrap,
Expand Down
2 changes: 1 addition & 1 deletion iota-streams-app/src/message/prepared.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use core::cell::Ref;

use super::*;
use iota_streams_core::sponge::prp::PRP;
use iota_streams_protobuf3::types::*;
use iota_streams_ddml::types::*;

/// Message context prepared for wrapping.
pub struct PreparedMessage<'a, F, Link, Store: 'a, Content> {
Expand Down
2 changes: 1 addition & 1 deletion iota-streams-app/src/message/preparsed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use anyhow::Result;

use super::*;
use iota_streams_core::prelude::String;
use iota_streams_protobuf3::command::unwrap;
use iota_streams_ddml::command::unwrap;

/// Message context preparsed for unwrapping.
pub struct PreparsedMessage<'a, F, Link> {
Expand Down
2 changes: 1 addition & 1 deletion iota-streams-app/src/message/tbinary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use iota_streams_core::{
prelude::Vec,
sponge::prp::PRP,
};
use iota_streams_protobuf3::{
use iota_streams_ddml::{
command::unwrap,
types::*,
};
Expand Down
2 changes: 1 addition & 1 deletion iota-streams-app/src/message/unwrapped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use iota_streams_core::sponge::{
prp::PRP,
spongos::Spongos,
};
use iota_streams_protobuf3::types::*;
use iota_streams_ddml::types::*;

/// Result of wrapping the message.
pub struct UnwrappedMessage<F, Link, Content> {
Expand Down
6 changes: 3 additions & 3 deletions iota-streams-app/src/message/version.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//! Streams message syntax version distinguished between incompatible changes in Protobuf3
//! syntax and/or rules of processing Protobuf3 messages. It usually means that a new
//! Streams message syntax version distinguished between incompatible changes in DDML
//! syntax and/or rules of processing DDML messages. It usually means that a new
//! command or type is added, or command proceeds in a different manner than before.
//! It can also signify changes in the `Header` message.
//!
Expand All @@ -11,7 +11,7 @@
//!
//! Backwards compatibility of the Streams implementations is welcome and not mandatory.
use iota_streams_protobuf3::types::Uint8;
use iota_streams_ddml::types::Uint8;

/// Streams version number.
pub const STREAMS_1_VER: Uint8 = Uint8(0);
2 changes: 1 addition & 1 deletion iota-streams-app/src/message/wrapped.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use iota_streams_core::sponge::{
prp::PRP,
spongos::Spongos,
};
use iota_streams_protobuf3::types::*;
use iota_streams_ddml::types::*;

/// Result of wrapping the message.
pub struct WrappedMessage<F, Link> {
Expand Down
Loading

0 comments on commit e617150

Please sign in to comment.