clippy fix

Signed-off-by: dzdidi <dzdidi@protonmail.com>
This commit is contained in:
dzdidi 2025-02-25 10:19:56 +01:00
parent 246e29700c
commit 05604a4e2b
No known key found for this signature in database
GPG key ID: 1FFF5A7760BD933D
3 changed files with 10 additions and 40 deletions

View file

@ -1,11 +1,8 @@
use bitcoin::consensus::encode;
use bitcoin::Transaction;
use teos_common::appointment::{Appointment, Locator};
use hex::FromHex;
use serde::{de, ser::SerializeMap, Deserializer, Serialize, Serializer};
use std::collections::HashMap;
use serde::{de, Deserializer};
pub fn deserialize_tx<'de, D>(deserializer: D) -> Result<Transaction, D::Error>
where
@ -34,37 +31,3 @@ where
deserializer.deserialize_any(TransactionVisitor)
}
pub fn serialize_receipts<S>(hm: &HashMap<Locator, String>, s: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut map = s.serialize_map(Some(hm.len()))?;
for (locator, sig) in hm {
map.serialize_entry(&hex::encode(locator), sig)?;
}
map.end()
}
#[derive(Serialize)]
struct AppointmentInners {
encrypted_blob: String,
to_self_delay: u32,
}
pub fn serialize_appointments<S>(v: &Vec<Appointment>, s: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut map = s.serialize_map(Some(v.len()))?;
for a in v {
map.serialize_entry(
&hex::encode(a.locator),
&AppointmentInners {
encrypted_blob: hex::encode(&a.encrypted_blob),
to_self_delay: a.to_self_delay,
},
)?;
}
map.end()
}

View file

@ -38,7 +38,7 @@ pub(crate) fn encrypt(
/// The result is expected to be a penalty transaction.
pub(crate) fn decrypt(
encrypted_blob: &[u8],
secret: &Vec<u8>,
secret: &[u8],
) -> Result<Vec<u8>, chacha20poly1305::aead::Error> {
// Defaults is [0; 12]
let nonce = Nonce::default();

View file

@ -5,10 +5,17 @@ use std::sync::{Arc, Mutex};
pub(crate) type DynStore = dyn KVStore + Sync + Send;
/// Type alias for the namespace to key-value mapping
type NamespaceMap = HashMap<String, Vec<u8>>;
/// Type alias for the storage data structure
type StorageMap = HashMap<String, NamespaceMap>;
/// Type alias for thread-safe storage
type ThreadSafeStorage = Arc<Mutex<StorageMap>>;
/// In-memory key-value store implementation for testing
#[derive(Clone, Debug)]
pub struct MemoryStore {
data: Arc<Mutex<HashMap<String, HashMap<String, Vec<u8>>>>>,
data: ThreadSafeStorage,
}
impl MemoryStore {