[−][src]Module networking::database
provides access to essentially a HashMap that can be written to disk implements peer list so this struct can be used to verify peers
Example
use networking::database::HashDatabase; use networking::ArtificePeer; use networking::{random_string, test_config}; let key = random_string(16).into_bytes(); let (peer, _config) = test_config(); let mut database: HashDatabase<ArtificePeer> = HashDatabase::new("./test_db", key.clone()).unwrap(); database.insert(peer.global_peer_hash().to_string(), peer.clone()).unwrap(); let mut second_database: HashDatabase<ArtificePeer> = HashDatabase::new("./test_db", key).unwrap(); second_database.load(&peer.global_peer_hash().to_string()).unwrap(); let newpeer = second_database.get(&peer.global_peer_hash().to_string()).unwrap(); assert_eq!(*newpeer, peer);
Structs
HashDatabase |
Traits
HashKey | this is a marker trait for any key value of HashDatabase |
HashValue | this is marker trait for any value of HashDatabase |