mirror of
https://github.com/fluencelabs/trust-graph
synced 2024-12-04 15:20:19 +00:00
chore: Update CI and fix clippy warnings [fixes FLU-251] (#62)
* Add release-please and renovate
* Update ci
* Revert "Add release-please and renovate"
This reverts commit a37a4e2a59
.
* Allow unnecessary_lazy_evaluations
This commit is contained in:
parent
664552d4f9
commit
8e58f56190
35
.github/workflows/run-tests.yml
vendored
Normal file
35
.github/workflows/run-tests.yml
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
name: Run tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- "**.md"
|
||||
|
||||
push:
|
||||
branches:
|
||||
- "master"
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.workflow }}-${{ github.ref }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
trust-graph:
|
||||
uses: ./.github/workflows/tests.yml
|
||||
|
||||
lints:
|
||||
name: lints
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup rust toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
|
||||
- name: Run cargo fmt
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
83
.github/workflows/rust_ci.yml
vendored
83
.github/workflows/rust_ci.yml
vendored
@ -1,83 +0,0 @@
|
||||
name: Rust CI
|
||||
on:
|
||||
push:
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: "${{ github.workflow }}-${{ github.ref }}"
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: cargo nextest
|
||||
runs-on: builder
|
||||
defaults:
|
||||
run:
|
||||
working-directory: service
|
||||
shell: bash
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Install toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
|
||||
- name: Add wasm32-wasi target
|
||||
run: rustup target add wasm32-wasi
|
||||
|
||||
- name: Install Marine
|
||||
uses: baptiste0928/cargo-install@v1.3.0
|
||||
with:
|
||||
crate: marine
|
||||
|
||||
- name: Build
|
||||
run: ./build.sh
|
||||
|
||||
- run: cargo install --locked cargo-nextest --version 0.9.22
|
||||
- run: cargo nextest run --release --all-features --no-fail-fast --retries 10 --test-threads 10
|
||||
|
||||
lints:
|
||||
name: Lints
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout sources
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- uses: actions/cache@v2
|
||||
with:
|
||||
path: |
|
||||
~/.cargo/registry
|
||||
~/.cargo/git
|
||||
target
|
||||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||
|
||||
- name: Install toolchain
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
profile: minimal
|
||||
toolchain: nightly
|
||||
override: true
|
||||
components: rustfmt, clippy
|
||||
|
||||
- name: Run cargo fmt
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: fmt
|
||||
args: --all -- --check
|
||||
|
||||
- name: Run cargo clippy
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: -Z unstable-options --all
|
||||
continue-on-error: true # do not fail for now
|
70
.github/workflows/tests.yml
vendored
Normal file
70
.github/workflows/tests.yml
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
name: Run tests with workflow_call
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
|
||||
jobs:
|
||||
trust-graph:
|
||||
name: "cargo nextest"
|
||||
runs-on: builder
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
id-token: write
|
||||
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup Rust toolchain
|
||||
uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
|
||||
- name: Install marine
|
||||
uses: baptiste0928/cargo-install@v1.3.0
|
||||
with:
|
||||
crate: marine
|
||||
|
||||
- name: Build
|
||||
working-directory: ./service
|
||||
run: ./build.sh
|
||||
|
||||
- name: Run cargo clippy
|
||||
uses: actions-rs/cargo@v1
|
||||
with:
|
||||
command: clippy
|
||||
args: -Z unstable-options --all
|
||||
|
||||
- name: Install cargo-nextest
|
||||
uses: baptiste0928/cargo-install@v1.3.0
|
||||
with:
|
||||
crate: cargo-nextest
|
||||
version: 0.9.22
|
||||
|
||||
- name: Run cargo nextest
|
||||
env:
|
||||
NEXTEST_RETRIES: 10
|
||||
NEXTEST_TEST_THREADS: 10
|
||||
run: cargo nextest run --release --all-features --no-fail-fast
|
||||
|
||||
- name: Setup node
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: "16"
|
||||
registry-url: "https://registry.npmjs.org"
|
||||
cache-dependency-path: "aqua/package-lock.json"
|
||||
cache: "npm"
|
||||
|
||||
- run: npm i
|
||||
working-directory: aqua
|
||||
|
||||
- run: npm run build
|
||||
working-directory: aqua
|
||||
|
||||
- name: Create distribution package
|
||||
run: ./builtin-package/package.sh
|
||||
|
||||
- name: Upload trust-graph
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: trust-graph
|
||||
path: trust-graph.tar.gz
|
@ -2,7 +2,7 @@
|
||||
name = "trust-graph"
|
||||
version = "0.3.0"
|
||||
authors = ["Fluence Labs"]
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
description = "trust graph"
|
||||
license = "Apache-2.0"
|
||||
repository = "https://github.com/fluencelabs/trust-graph"
|
||||
|
@ -2,7 +2,7 @@
|
||||
name = "fluence-keypair"
|
||||
version = "0.9.0"
|
||||
authors = ["Fluence Labs"]
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
description = "identity"
|
||||
license = "Apache-2.0"
|
||||
repository = "https://github.com/fluencelabs/trust-graph"
|
||||
|
@ -58,7 +58,7 @@ pub mod peerid_serializer {
|
||||
{
|
||||
let str = String::deserialize(deserializer)?;
|
||||
PeerId::from_str(&str).map_err(|e| {
|
||||
serde::de::Error::custom(format!("peer id deserialization failed for {:?}", e))
|
||||
serde::de::Error::custom(format!("peer id deserialization failed for {e:?}"))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ mod tests {
|
||||
let kp = KeyPair::generate_secp256k1();
|
||||
let fluence_pk = kp.public();
|
||||
let libp2p_pk: libp2p_core::PublicKey = fluence_pk.clone().into();
|
||||
let peer_id = PeerId::from_public_key(libp2p_pk);
|
||||
let peer_id = PeerId::from_public_key(&libp2p_pk);
|
||||
let fluence_pk_converted = PublicKey::try_from(peer_id).unwrap();
|
||||
|
||||
assert_eq!(fluence_pk, fluence_pk_converted);
|
||||
|
@ -127,7 +127,7 @@ impl fmt::Debug for PublicKey {
|
||||
let mut hex = String::with_capacity(bytes.len() * 2);
|
||||
|
||||
for byte in bytes {
|
||||
write!(hex, "{:02x}", byte).expect("Can't fail on writing to string");
|
||||
write!(hex, "{byte:02x}").expect("Can't fail on writing to string");
|
||||
}
|
||||
|
||||
f.debug_struct("PublicKey").field("pkcs1", &hex).finish()
|
||||
|
@ -122,7 +122,7 @@ impl SecretKey {
|
||||
// TODO: Stricter parsing.
|
||||
let der_obj = der.as_mut();
|
||||
let obj: Vec<DerObject> =
|
||||
FromDerObject::deserialize((&*der_obj).iter()).map_err(|_| DecodingError::Secp256k1)?;
|
||||
FromDerObject::deserialize((*der_obj).iter()).map_err(|_| DecodingError::Secp256k1)?;
|
||||
der_obj.zeroize();
|
||||
let sk_obj = obj.into_iter().nth(1).ok_or(DecodingError::Secp256k1)?;
|
||||
let mut sk_bytes: Vec<u8> =
|
||||
|
@ -1,3 +1,4 @@
|
||||
[toolchain]
|
||||
channel = "nightly-2022-12-06"
|
||||
targets = [ "x86_64-apple-darwin", "wasm32-wasi", "wasm32-unknown-unknown", "x86_64-unknown-linux-gnu" ]
|
||||
components = [ "rustfmt", "clippy" ]
|
||||
|
@ -2,7 +2,7 @@
|
||||
name = "trust-graph-wasm"
|
||||
version = "0.3.1"
|
||||
authors = ["Fluence Labs"]
|
||||
edition = "2018"
|
||||
edition = "2021"
|
||||
description = "trust graph wasm"
|
||||
license = "Apache-2.0"
|
||||
publish = false
|
||||
|
@ -13,7 +13,7 @@ mkdir -p artifacts
|
||||
cp ../target/wasm32-wasi/release/trust-graph.wasm artifacts/
|
||||
|
||||
# download SQLite 3 to use in tests
|
||||
curl -L https://github.com/fluencelabs/sqlite/releases/download/v0.15.0_w/sqlite3.wasm -o artifacts/sqlite3.wasm
|
||||
curl -sS -L https://github.com/fluencelabs/sqlite/releases/download/v0.15.0_w/sqlite3.wasm -o artifacts/sqlite3.wasm
|
||||
|
||||
# generate Aqua bindings
|
||||
marine aqua artifacts/trust-graph.wasm -s TrustGraph -i trust-graph > ../aqua/trust-graph.aqua
|
||||
|
@ -78,7 +78,7 @@ impl TryFrom<Trust> for trust_graph::Trust {
|
||||
|
||||
fn try_from(t: Trust) -> Result<Self, Self::Error> {
|
||||
let issued_for = PublicKey::try_from(
|
||||
PeerId::from_str(&t.issued_for).map_err(|e| PeerIdDecodeError(format!("{:?}", e)))?,
|
||||
PeerId::from_str(&t.issued_for).map_err(|e| PeerIdDecodeError(format!("{e:?}")))?,
|
||||
)
|
||||
.map_err(|e| DtoConversionError::PeerIdDecodeError(e.to_string()))?;
|
||||
let signature = bs58::decode(&t.signature).into_vec()?;
|
||||
@ -132,11 +132,11 @@ impl TryFrom<Revocation> for trust_graph::Revocation {
|
||||
fn try_from(r: Revocation) -> Result<Self, Self::Error> {
|
||||
let revoked_pk = PublicKey::try_from(
|
||||
PeerId::from_str(&r.revoked_peer_id)
|
||||
.map_err(|e| PeerIdDecodeError(format!("{:?}", e)))?,
|
||||
.map_err(|e| PeerIdDecodeError(format!("{e:?}")))?,
|
||||
)
|
||||
.map_err(|e| DtoConversionError::PeerIdDecodeError(e.to_string()))?;
|
||||
let revoked_by_pk = PublicKey::try_from(
|
||||
PeerId::from_str(&r.revoked_by).map_err(|e| PeerIdDecodeError(format!("{:?}", e)))?,
|
||||
PeerId::from_str(&r.revoked_by).map_err(|e| PeerIdDecodeError(format!("{e:?}")))?,
|
||||
)
|
||||
.map_err(|e| DtoConversionError::PeerIdDecodeError(e.to_string()))?;
|
||||
let signature = bs58::decode(&r.signature).into_vec()?;
|
||||
|
@ -27,6 +27,7 @@ use std::str::FromStr;
|
||||
use trust_graph::TrustGraph;
|
||||
|
||||
/// Check timestamps are generated on the current host with builtin ("peer" "timestamp_sec")
|
||||
#[allow(clippy::unnecessary_lazy_evaluations)]
|
||||
pub(crate) fn check_timestamp_tetraplets(
|
||||
call_parameters: &CallParameters,
|
||||
arg_number: usize,
|
||||
@ -41,12 +42,12 @@ pub(crate) fn check_timestamp_tetraplets(
|
||||
(TRUSTED_TIMESTAMP.eq(&(&tetraplet.service_id, &tetraplet.function_name))
|
||||
&& tetraplet.peer_pk == call_parameters.host_id)
|
||||
.then(|| ())
|
||||
.ok_or_else(|| InvalidTimestampTetraplet(format!("{:?}", tetraplet)))
|
||||
.ok_or_else(|| InvalidTimestampTetraplet(format!("{tetraplet:?}")))
|
||||
}
|
||||
|
||||
fn parse_peer_id(peer_id: String) -> Result<PeerId, ServiceError> {
|
||||
libp2p_core::PeerId::from_str(&peer_id)
|
||||
.map_err(|e| ServiceError::PeerIdParseError(format!("{:?}", e)))
|
||||
.map_err(|e| ServiceError::PeerIdParseError(format!("{e:?}")))
|
||||
}
|
||||
|
||||
thread_local!(static INSTANCE: RefCell<TrustGraph<SQLiteStorage>> = RefCell::new(TrustGraph::new(
|
||||
|
@ -17,7 +17,7 @@ impl From<Result<(), ServiceError>> for InsertResult {
|
||||
},
|
||||
Err(e) => InsertResult {
|
||||
success: false,
|
||||
error: format!("{}", e),
|
||||
error: format!("{e}"),
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -44,7 +44,7 @@ impl From<Result<(u32, String), ServiceError>> for WeightResult {
|
||||
success: false,
|
||||
weight: 0u32,
|
||||
peer_id: "".to_string(),
|
||||
error: format!("{}", e),
|
||||
error: format!("{e}"),
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -68,7 +68,7 @@ impl From<Result<Vec<Certificate>, ServiceError>> for AllCertsResult {
|
||||
Err(e) => AllCertsResult {
|
||||
success: false,
|
||||
certificates: vec![],
|
||||
error: format!("{}", e),
|
||||
error: format!("{e}"),
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -89,7 +89,7 @@ impl From<Result<(), ServiceError>> for SetRootResult {
|
||||
},
|
||||
Err(e) => SetRootResult {
|
||||
success: false,
|
||||
error: format!("{}", e),
|
||||
error: format!("{e}"),
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -112,7 +112,7 @@ impl From<Result<Vec<u8>, ServiceError>> for GetTrustBytesResult {
|
||||
},
|
||||
Err(e) => GetTrustBytesResult {
|
||||
success: false,
|
||||
error: format!("{}", e),
|
||||
error: format!("{e}"),
|
||||
result: vec![],
|
||||
},
|
||||
}
|
||||
@ -136,7 +136,7 @@ impl From<Result<Trust, ServiceError>> for IssueTrustResult {
|
||||
},
|
||||
Err(e) => IssueTrustResult {
|
||||
success: false,
|
||||
error: format!("{}", e),
|
||||
error: format!("{e}"),
|
||||
trust: Trust::default(),
|
||||
},
|
||||
}
|
||||
@ -158,7 +158,7 @@ impl From<Result<(), ServiceError>> for VerifyTrustResult {
|
||||
},
|
||||
Err(e) => VerifyTrustResult {
|
||||
success: false,
|
||||
error: format!("{}", e),
|
||||
error: format!("{e}"),
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -181,7 +181,7 @@ impl From<Result<u32, ServiceError>> for AddTrustResult {
|
||||
},
|
||||
Err(e) => AddTrustResult {
|
||||
success: false,
|
||||
error: format!("{}", e),
|
||||
error: format!("{e}"),
|
||||
weight: u32::default(),
|
||||
},
|
||||
}
|
||||
@ -205,7 +205,7 @@ impl From<Result<Vec<u8>, ServiceError>> for GetRevokeBytesResult {
|
||||
},
|
||||
Err(e) => GetRevokeBytesResult {
|
||||
success: false,
|
||||
error: format!("{}", e),
|
||||
error: format!("{e}"),
|
||||
result: vec![],
|
||||
},
|
||||
}
|
||||
@ -229,7 +229,7 @@ impl From<Result<Revocation, ServiceError>> for IssueRevocationResult {
|
||||
},
|
||||
Err(e) => IssueRevocationResult {
|
||||
success: false,
|
||||
error: format!("{}", e),
|
||||
error: format!("{e}"),
|
||||
revocation: Revocation::default(),
|
||||
},
|
||||
}
|
||||
@ -251,7 +251,7 @@ impl From<Result<(), ServiceError>> for RevokeResult {
|
||||
},
|
||||
Err(e) => RevokeResult {
|
||||
success: false,
|
||||
error: format!("{}", e),
|
||||
error: format!("{e}"),
|
||||
},
|
||||
}
|
||||
}
|
||||
@ -275,7 +275,7 @@ impl From<Result<Vec<Revocation>, ServiceError>> for ExportRevocationsResult {
|
||||
Err(e) => ExportRevocationsResult {
|
||||
success: false,
|
||||
revocations: vec![],
|
||||
error: format!("{}", e),
|
||||
error: format!("{e}"),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -100,7 +100,7 @@ impl SQLiteStorage {
|
||||
.cursor();
|
||||
|
||||
cursor.bind(&[
|
||||
Value::String(format!("{}", issued_for)),
|
||||
Value::String(format!("{issued_for}")),
|
||||
Value::Integer(relation_type),
|
||||
])?;
|
||||
let mut relations: Vec<TrustRelation> = vec![];
|
||||
@ -206,8 +206,8 @@ impl Storage for SQLiteStorage {
|
||||
.cursor();
|
||||
|
||||
cursor.bind(&[
|
||||
Value::String(format!("{}", issued_by)),
|
||||
Value::String(format!("{}", issued_for)),
|
||||
Value::String(format!("{issued_by}")),
|
||||
Value::String(format!("{issued_for}")),
|
||||
])?;
|
||||
|
||||
if let Some(row) = cursor.next()? {
|
||||
@ -281,7 +281,7 @@ impl Storage for SQLiteStorage {
|
||||
.prepare("SELECT public_key, weight_factor FROM roots WHERE public_key = ?")?
|
||||
.cursor();
|
||||
|
||||
cursor.bind(&[Value::String(format!("{}", pk))])?;
|
||||
cursor.bind(&[Value::String(format!("{pk}"))])?;
|
||||
|
||||
if let Some(row) = cursor.next()? {
|
||||
let w = u32::try_from(row[1].as_integer().ok_or(WeightFactorConversionDB)?)
|
||||
@ -304,7 +304,7 @@ impl Storage for SQLiteStorage {
|
||||
.cursor();
|
||||
|
||||
cursor.bind(&[
|
||||
Value::String(format!("{}", pk)),
|
||||
Value::String(format!("{pk}")),
|
||||
Value::Integer(i64::from(weight_factor)),
|
||||
])?;
|
||||
|
||||
|
@ -160,8 +160,8 @@ impl Certificate {
|
||||
) -> Result<Self, CertificateError> {
|
||||
if expires_at.lt(&issued_at) {
|
||||
return Err(ExpirationError {
|
||||
expires_at: format!("{:?}", expires_at),
|
||||
issued_at: format!("{:?}", issued_at),
|
||||
expires_at: format!("{expires_at:?}"),
|
||||
issued_at: format!("{issued_at:?}"),
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ mod single {
|
||||
{
|
||||
let str = String::deserialize(deserializer)?;
|
||||
Certificate::from_str(&str)
|
||||
.map_err(|e| Error::custom(format!("certificate deserialization failed for {:?}", e)))
|
||||
.map_err(|e| Error::custom(format!("certificate deserialization failed for {e:?}")))
|
||||
}
|
||||
}
|
||||
|
||||
@ -63,7 +63,7 @@ pub mod vec {
|
||||
v.into_iter()
|
||||
.map(|e| {
|
||||
Certificate::from_str(&e).map_err(|e| {
|
||||
Error::custom(format!("certificate deserialization failed for {:?}", e))
|
||||
Error::custom(format!("certificate deserialization failed for {e:?}"))
|
||||
})
|
||||
})
|
||||
.collect()
|
||||
|
@ -5,6 +5,6 @@ pub fn current_time() -> Duration {
|
||||
SystemTime::now()
|
||||
.duration_since(UNIX_EPOCH)
|
||||
.unwrap()
|
||||
.as_secs() as u64,
|
||||
.as_secs(),
|
||||
)
|
||||
}
|
||||
|
@ -120,10 +120,10 @@ impl<'de> serde::Deserialize<'de> for PublicKeyHashable {
|
||||
{
|
||||
bs58::decode(s)
|
||||
.into_vec()
|
||||
.map_err(|err| Error::custom(format!("Invalid string '{}': {}", s, err)))
|
||||
.map_err(|err| Error::custom(format!("Invalid string '{s}': {err}")))
|
||||
.and_then(|v| self.visit_bytes(v.as_slice()))
|
||||
.map_err(|err: E| {
|
||||
Error::custom(format!("Parsed string '{}' as base58, but {}", s, err))
|
||||
Error::custom(format!("Parsed string '{s}' as base58, but {err}"))
|
||||
})
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ impl<'de> serde::Deserialize<'de> for PublicKeyHashable {
|
||||
E: Error,
|
||||
{
|
||||
let pk = PublicKey::decode(b)
|
||||
.map_err(|err| Error::custom(format!("Invalid bytes {:?}: {}", b, err)))?;
|
||||
.map_err(|err| Error::custom(format!("Invalid bytes {b:?}: {err}")))?;
|
||||
Ok(PublicKeyHashable::from(pk))
|
||||
}
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ impl Revocation {
|
||||
let pk_bytes = &pk.encode();
|
||||
metadata.push(pk_bytes.len() as u8);
|
||||
metadata.extend(pk_bytes);
|
||||
metadata.extend_from_slice(&(revoked_at.as_secs() as u64).to_le_bytes());
|
||||
metadata.extend_from_slice(&revoked_at.as_secs().to_le_bytes());
|
||||
|
||||
sha2::Sha256::digest(&metadata).to_vec()
|
||||
}
|
||||
|
17
src/trust.rs
17
src/trust.rs
@ -144,8 +144,8 @@ impl Trust {
|
||||
|
||||
pub fn signature_bytes(pk: &PublicKey, expires_at: Duration, issued_at: Duration) -> Vec<u8> {
|
||||
let pk_encoded = pk.encode();
|
||||
let expires_at_encoded: [u8; EXPIRATION_LEN] = (expires_at.as_secs() as u64).to_le_bytes();
|
||||
let issued_at_encoded: [u8; ISSUED_LEN] = (issued_at.as_secs() as u64).to_le_bytes();
|
||||
let expires_at_encoded: [u8; EXPIRATION_LEN] = expires_at.as_secs().to_le_bytes();
|
||||
let issued_at_encoded: [u8; ISSUED_LEN] = issued_at.as_secs().to_le_bytes();
|
||||
let mut metadata = Vec::new();
|
||||
|
||||
metadata.extend(pk_encoded);
|
||||
@ -165,8 +165,8 @@ impl Trust {
|
||||
vec.append(&mut issued_for);
|
||||
vec.push(signature.len() as u8);
|
||||
vec.append(&mut signature);
|
||||
vec.extend_from_slice(&(self.expires_at.as_secs() as u64).to_le_bytes());
|
||||
vec.extend_from_slice(&(self.issued_at.as_secs() as u64).to_le_bytes());
|
||||
vec.extend_from_slice(&self.expires_at.as_secs().to_le_bytes());
|
||||
vec.extend_from_slice(&self.issued_at.as_secs().to_le_bytes());
|
||||
|
||||
vec
|
||||
}
|
||||
@ -260,13 +260,10 @@ impl ToString for Trust {
|
||||
fn to_string(&self) -> String {
|
||||
let issued_for = bs58::encode(self.issued_for.encode()).into_string();
|
||||
let signature = bs58::encode(self.signature.encode()).into_string();
|
||||
let expires_at = (self.expires_at.as_secs() as u64).to_string();
|
||||
let issued_at = (self.issued_at.as_secs() as u64).to_string();
|
||||
let expires_at = self.expires_at.as_secs().to_string();
|
||||
let issued_at = self.issued_at.as_secs().to_string();
|
||||
|
||||
format!(
|
||||
"{}\n{}\n{}\n{}",
|
||||
issued_for, signature, expires_at, issued_at
|
||||
)
|
||||
format!("{issued_for}\n{signature}\n{expires_at}\n{issued_at}")
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ impl<T: StorageError + 'static> From<T> for TrustGraphError {
|
||||
|
||||
impl From<TrustGraphError> for String {
|
||||
fn from(err: TrustGraphError) -> Self {
|
||||
format!("{}", err)
|
||||
format!("{err}")
|
||||
}
|
||||
}
|
||||
|
||||
@ -374,8 +374,7 @@ where
|
||||
// Certificate with one trust means nothing, gotta be a bug. Checking for it here.
|
||||
debug_assert!(
|
||||
c.chain.len() > 1,
|
||||
"certificate with chain of len 1 arose: {:#?}",
|
||||
c
|
||||
"certificate with chain of len 1 arose: {c:#?}",
|
||||
);
|
||||
c.chain.len() > 1
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user