diff --git a/teos-ldk-client/src/ser.rs b/teos-ldk-client/src/ser.rs index d0c2e9b..50a9ef8 100644 --- a/teos-ldk-client/src/ser.rs +++ b/teos-ldk-client/src/ser.rs @@ -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 where @@ -34,37 +31,3 @@ where deserializer.deserialize_any(TransactionVisitor) } - -pub fn serialize_receipts(hm: &HashMap, s: S) -> Result -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(v: &Vec, s: S) -> Result -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() -} diff --git a/teos-ldk-client/src/storage/encryption.rs b/teos-ldk-client/src/storage/encryption.rs index ec8a6d9..44b5e9a 100644 --- a/teos-ldk-client/src/storage/encryption.rs +++ b/teos-ldk-client/src/storage/encryption.rs @@ -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, + secret: &[u8], ) -> Result, chacha20poly1305::aead::Error> { // Defaults is [0; 12] let nonce = Nonce::default(); diff --git a/teos-ldk-client/src/storage/memory_store.rs b/teos-ldk-client/src/storage/memory_store.rs index cc8766e..123a85c 100644 --- a/teos-ldk-client/src/storage/memory_store.rs +++ b/teos-ldk-client/src/storage/memory_store.rs @@ -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>; +/// Type alias for the storage data structure +type StorageMap = HashMap; +/// Type alias for thread-safe storage +type ThreadSafeStorage = Arc>; + /// In-memory key-value store implementation for testing #[derive(Clone, Debug)] pub struct MemoryStore { - data: Arc>>>>, + data: ThreadSafeStorage, } impl MemoryStore {