mirror of
https://github.com/fluencelabs/trust-graph-test
synced 2025-04-24 23:02:32 +00:00
fmt
This commit is contained in:
parent
3a9530b92d
commit
5889ad77a3
@ -1,9 +1,9 @@
|
|||||||
use fluence::WasmLoggerBuilder;
|
use fluence::WasmLoggerBuilder;
|
||||||
|
|
||||||
|
mod proxy_structs;
|
||||||
|
mod results;
|
||||||
mod service_api;
|
mod service_api;
|
||||||
mod storage_impl;
|
mod storage_impl;
|
||||||
mod results;
|
|
||||||
mod proxy_structs;
|
|
||||||
|
|
||||||
pub fn main() {
|
pub fn main() {
|
||||||
WasmLoggerBuilder::new()
|
WasmLoggerBuilder::new()
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use trust_graph::{Trust as TGTrust, Certificate as TGCertificate};
|
|
||||||
use fluence::fce;
|
use fluence::fce;
|
||||||
|
use trust_graph::{Certificate as TGCertificate, Trust as TGTrust};
|
||||||
|
|
||||||
#[fce]
|
#[fce]
|
||||||
pub struct Certificate {
|
pub struct Certificate {
|
||||||
@ -7,12 +7,9 @@ pub struct Certificate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<TGCertificate> for Certificate {
|
impl From<TGCertificate> for Certificate {
|
||||||
|
|
||||||
fn from(t: TGCertificate) -> Self {
|
fn from(t: TGCertificate) -> Self {
|
||||||
let chain: Vec<Trust> = t.chain.into_iter().map(|t| t.into()).collect();
|
let chain: Vec<Trust> = t.chain.into_iter().map(|t| t.into()).collect();
|
||||||
return Certificate {
|
return Certificate { chain };
|
||||||
chain
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,7 +27,6 @@ pub struct Trust {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl From<TGTrust> for Trust {
|
impl From<TGTrust> for Trust {
|
||||||
|
|
||||||
fn from(t: TGTrust) -> Self {
|
fn from(t: TGTrust) -> Self {
|
||||||
let issued_for = bs58::encode(t.issued_for.to_bytes()).into_string();
|
let issued_for = bs58::encode(t.issued_for.to_bytes()).into_string();
|
||||||
let signature = bs58::encode(t.signature.to_bytes()).into_string();
|
let signature = bs58::encode(t.signature.to_bytes()).into_string();
|
||||||
@ -40,7 +36,7 @@ impl From<TGTrust> for Trust {
|
|||||||
issued_for,
|
issued_for,
|
||||||
expires_at,
|
expires_at,
|
||||||
signature,
|
signature,
|
||||||
issued_at
|
issued_at,
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
use fluence::fce;
|
|
||||||
use crate::proxy_structs::Certificate;
|
use crate::proxy_structs::Certificate;
|
||||||
|
use fluence::fce;
|
||||||
|
|
||||||
#[fce]
|
#[fce]
|
||||||
pub struct InsertResult {
|
pub struct InsertResult {
|
||||||
@ -26,7 +26,7 @@ impl From<Result<(), String>> for InsertResult {
|
|||||||
pub struct WeightResult {
|
pub struct WeightResult {
|
||||||
pub ret_code: u32,
|
pub ret_code: u32,
|
||||||
pub weight: Vec<u32>,
|
pub weight: Vec<u32>,
|
||||||
pub error: String
|
pub error: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Result<Option<u32>, String>> for WeightResult {
|
impl From<Result<Option<u32>, String>> for WeightResult {
|
||||||
@ -50,7 +50,7 @@ impl From<Result<Option<u32>, String>> for WeightResult {
|
|||||||
pub struct AllCertsResult {
|
pub struct AllCertsResult {
|
||||||
pub ret_code: u32,
|
pub ret_code: u32,
|
||||||
pub certificates: Vec<Certificate>,
|
pub certificates: Vec<Certificate>,
|
||||||
pub error: String
|
pub error: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<Result<Vec<Certificate>, String>> for AllCertsResult {
|
impl From<Result<Vec<Certificate>, String>> for AllCertsResult {
|
||||||
@ -68,4 +68,4 @@ impl From<Result<Vec<Certificate>, String>> for AllCertsResult {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
use crate::proxy_structs::Certificate;
|
||||||
|
use crate::results::{AllCertsResult, InsertResult, WeightResult};
|
||||||
use crate::storage_impl::get_data;
|
use crate::storage_impl::get_data;
|
||||||
use fluence::fce;
|
use fluence::fce;
|
||||||
use fluence_identity::{KeyPair, PublicKey};
|
use fluence_identity::{KeyPair, PublicKey};
|
||||||
@ -5,9 +7,7 @@ use std::convert::{From, Into};
|
|||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
use trust_graph::{Certificate as TGCertificate};
|
use trust_graph::Certificate as TGCertificate;
|
||||||
use crate::proxy_structs::Certificate;
|
|
||||||
use crate::results::{WeightResult, InsertResult, AllCertsResult};
|
|
||||||
|
|
||||||
fn insert_cert_impl(certificate: String, duration: u64) -> Result<(), String> {
|
fn insert_cert_impl(certificate: String, duration: u64) -> Result<(), String> {
|
||||||
let duration = Duration::from_millis(duration);
|
let duration = Duration::from_millis(duration);
|
||||||
@ -41,7 +41,8 @@ fn get_weight(public_key: String) -> WeightResult {
|
|||||||
|
|
||||||
fn string_to_public_key(public_key: String) -> Result<PublicKey, String> {
|
fn string_to_public_key(public_key: String) -> Result<PublicKey, String> {
|
||||||
let public_key = bs58::decode(public_key)
|
let public_key = bs58::decode(public_key)
|
||||||
.into_vec().map_err(|e| format!("Couldn't decode public_key from base58: {}", e))?;
|
.into_vec()
|
||||||
|
.map_err(|e| format!("Couldn't decode public_key from base58: {}", e))?;
|
||||||
let public_key = PublicKey::from_bytes(&public_key)
|
let public_key = PublicKey::from_bytes(&public_key)
|
||||||
.map_err(|e| format!("Couldn't decode public_key: {}", e))?;
|
.map_err(|e| format!("Couldn't decode public_key: {}", e))?;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user