From 6e114ca7af44cfe40b106a43a3f4140f1770d659 Mon Sep 17 00:00:00 2001 From: Alexey Proshutinskiy Date: Thu, 16 Sep 2021 16:24:46 +0300 Subject: [PATCH] minor fixes --- builtin-package/blueprint.json | 2 +- keypair/src/lib.rs | 24 +++++++------- service/.repl_history | 3 -- service/Cargo.toml | 2 +- service/src/service_api.rs | 5 ++- service/trust-graph.aqua | 58 ---------------------------------- 6 files changed, 16 insertions(+), 78 deletions(-) delete mode 100644 service/.repl_history delete mode 100644 service/trust-graph.aqua diff --git a/builtin-package/blueprint.json b/builtin-package/blueprint.json index c77f06a..3e0d9c3 100644 --- a/builtin-package/blueprint.json +++ b/builtin-package/blueprint.json @@ -4,4 +4,4 @@ "name:sqlite3", "name:trust-graph" ] -} \ No newline at end of file +} diff --git a/keypair/src/lib.rs b/keypair/src/lib.rs index 5498856..18b22dd 100644 --- a/keypair/src/lib.rs +++ b/keypair/src/lib.rs @@ -26,39 +26,39 @@ unreachable_patterns )] -mod secp256k1; mod ed25519; +pub mod error; +pub mod key_pair; +pub mod public_key; #[cfg(not(target_arch = "wasm32"))] mod rsa; -pub mod key_pair; -pub mod error; -pub mod public_key; +mod secp256k1; pub mod signature; -pub use key_pair::KeyPair; -pub use key_pair::KeyFormat; pub use crate::public_key::PublicKey; pub use crate::signature::Signature; +pub use key_pair::KeyFormat; +pub use key_pair::KeyPair; pub mod peerid_serializer { + use libp2p_core::PeerId; use serde::{Deserialize, Deserializer, Serialize, Serializer}; use std::str::FromStr; - use libp2p_core::PeerId; pub fn serialize(value: &PeerId, serializer: S) -> Result - where - S: Serializer, + where + S: Serializer, { value.to_base58().serialize(serializer) } pub fn deserialize<'de, D>(deserializer: D) -> Result - where - D: Deserializer<'de>, + where + D: Deserializer<'de>, { let str = String::deserialize(deserializer)?; PeerId::from_str(&str).map_err(|e| { serde::de::Error::custom(format!("peer id deserialization failed for {:?}", e)) }) } -} \ No newline at end of file +} diff --git a/service/.repl_history b/service/.repl_history deleted file mode 100644 index 3b4374d..0000000 --- a/service/.repl_history +++ /dev/null @@ -1,3 +0,0 @@ -#V2 -in -interface diff --git a/service/Cargo.toml b/service/Cargo.toml index 25f47c5..0398374 100644 --- a/service/Cargo.toml +++ b/service/Cargo.toml @@ -31,4 +31,4 @@ serde_bencode = "^0.2.3" thiserror = "1.0.23" [dev-dependencies] -marine-rs-sdk-test = "0.1.11" \ No newline at end of file +marine-rs-sdk-test = "0.1.11" diff --git a/service/src/service_api.rs b/service/src/service_api.rs index 76ea161..7a053a2 100644 --- a/service/src/service_api.rs +++ b/service/src/service_api.rs @@ -12,7 +12,6 @@ use marine_rs_sdk::{marine, CallParameters}; #[marine] /// add a certificate in string representation to trust graph if it is valid /// see `trust_graph::Certificate` class for string encoding/decoding -// TODO change `timestamp_sec` to time service fn insert_cert_raw(certificate: String, timestamp_sec: u64) -> InsertResult { insert_cert_impl_raw(certificate, timestamp_sec).into() } @@ -24,7 +23,7 @@ fn insert_cert(certificate: Certificate, timestamp_sec: u64) -> InsertResult { insert_cert_impl(certificate, timestamp_sec).into() } -// TODO: pass current timestamp, return only valid, delete expired, return max weight +// TODO: return only valid, delete expired, return max weight #[marine] fn get_weight(peer_id: String, timestamp_sec: u64) -> WeightResult { get_weight_impl(peer_id.clone(), timestamp_sec) @@ -32,7 +31,7 @@ fn get_weight(peer_id: String, timestamp_sec: u64) -> WeightResult { .into() } -// TODO: pass current timestamp, return only valid, delete expired +// TODO: return only valid, delete expired #[marine] fn get_all_certs(issued_for: String, timestamp_sec: u64) -> AllCertsResult { get_all_certs_impl(issued_for, timestamp_sec).into() diff --git a/service/trust-graph.aqua b/service/trust-graph.aqua deleted file mode 100644 index 2e8e70f..0000000 --- a/service/trust-graph.aqua +++ /dev/null @@ -1,58 +0,0 @@ -data AddRootResult: - success: bool - error: string - -data AddTrustResult: - success: bool - error: string - weight: u32 - -data Trust: - issued_for: string - expires_at: u64 - signature: string - sig_type: string - issued_at: u64 - -data Certificate: - chain: []Trust - -data AllCertsResult: - success: bool - certificates: []Certificate - error: string - -data GetTrustMetadataResult: - success: bool - error: string - result: []u8 - -data InsertResult: - success: bool - error: string - -data IssueTrustResult: - success: bool - error: string - trust: Trust - -data VerifyTrustResult: - success: bool - error: string - -data WeightResult: - success: bool - weight: u32 - peer_id: string - error: string - -service TrustGraph("trust-graph"): - add_root(peer_id: string, weight: u32) -> AddRootResult - add_trust(trust: Trust, issuer_peer_id: string, timestamp_sec: u64) -> AddTrustResult - get_all_certs(issued_for: string, timestamp_sec: u64) -> AllCertsResult - get_trust_metadata(issued_for_peer_id: string, expires_at_sec: u64, issued_at_sec: u64) -> GetTrustMetadataResult - get_weight(peer_id: string, timestamp_sec: u64) -> WeightResult - insert_cert(certificate: Certificate, timestamp_sec: u64) -> InsertResult - insert_cert_raw(certificate: string, timestamp_sec: u64) -> InsertResult - issue_trust(issued_for_peer_id: string, expires_at_sec: u64, issued_at_sec: u64, signed_metadata: []u8) -> IssueTrustResult - verify_trust(trust: Trust, issuer_peer_id: string, timestamp_sec: u64) -> VerifyTrustResult