Expand description
Storage module for persisting TAP messages and transactions
This module provides comprehensive persistent storage capabilities for the TAP Node, maintaining both business transaction records and a complete message audit trail in a SQLite database for compliance, debugging, and operational purposes.
§Architecture
The storage system uses a dual-table design:
- transactions: Stores Transfer and Payment messages for business logic
- messages: Stores all messages (incoming/outgoing) for audit trail
§Features
- Automatic Schema Migration: Database schema is created and migrated automatically
- Connection Pooling: Uses sqlx’s built-in async connection pool
- Async API: Native async operations without blocking threads
- WASM Compatibility: Storage is automatically disabled in WASM builds
- Idempotent Operations: Duplicate messages are silently ignored
- Direction Tracking: Messages are tagged as incoming or outgoing
- Thread Tracking: Full support for DIDComm thread and parent thread IDs
§Usage
Storage is automatically initialized when creating a TapNode with the storage feature enabled:
use tap_node::{NodeConfig, TapNode};
use tap_node::storage::MessageDirection;
use std::path::PathBuf;
let config = NodeConfig {
#[cfg(feature = "storage")]
storage_path: Some(PathBuf::from("./my-database.db")),
..Default::default()
};
let node = TapNode::new(config);
// Access storage functionality
if let Some(storage) = node.storage() {
// Query transactions
let txs = storage.list_transactions(10, 0).await?;
// Query message audit trail
let messages = storage.list_messages(20, 0, Some(MessageDirection::Incoming)).await?;
}§Environment Variables
TAP_NODE_DB_PATH: Override the default database path
§Automatic Message Logging
The TapNode automatically logs all messages:
- Incoming messages are logged when
receive_message()is called - Outgoing messages are logged when
send_message()is called - Transfer and Payment messages are additionally stored in the transactions table
Re-exports§
pub use agent_storage_manager::AgentStorageManager;pub use db::Storage;pub use error::StorageError;pub use models::Customer;pub use models::CustomerIdentifier;pub use models::CustomerRelationship;pub use models::DecisionLogEntry;pub use models::DecisionStatus;pub use models::DecisionType;pub use models::Delivery;pub use models::DeliveryStatus;pub use models::DeliveryType;pub use models::IdentifierType;pub use models::Message;pub use models::MessageDirection;pub use models::Received;pub use models::ReceivedStatus;pub use models::SchemaType;pub use models::SourceType;pub use models::Transaction;pub use models::TransactionStatus;pub use models::TransactionType;
Modules§
- agent_
storage_ manager - Agent-specific storage management
- db
- error
- models