MCPcopy Create free account
hub / github.com/ddimaria/rust-blockchain-tutorial / new

Method new

chain/src/storage.rs:49–55  ·  view source on GitHub ↗
(database_name: Option<&str>)

Source from the content-addressed store, hash-verified

47
48impl Storage {
49 pub(crate) fn new(database_name: Option<&str>) -> Result<Self> {
50 let database_name = database_name.unwrap_or(DATABASE_NAME);
51 let db = DB::open_default(Storage::path(database_name))
52 .map_err(|e| ChainError::StorageCannotOpenDb(e.to_string()))?;
53
54 Ok(Self { db })
55 }
56
57 pub(crate) fn _get_all_keys<K: AsRef<[u8]>>(&self) -> Result<Vec<Box<[u8]>>> {
58 let value: Vec<Box<[u8]>> = self

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected