MCPcopy Create free account
hub / github.com/BitVM/BitVM / write_data

Method write_data

bridge/src/client/data_store/data_store.rs:109–130  ·  view source on GitHub ↗
(
        &self,
        contents: &String,
        file_path: Option<&str>,
    )

Source from the content-addressed store, hash-verified

107 }
108
109 pub async fn write_data(
110 &self,
111 contents: &String,
112 file_path: Option<&str>,
113 ) -> Result<String, String> {
114 match self.get_driver() {
115 Ok(driver) => {
116 let time = SystemTime::now()
117 .duration_since(UNIX_EPOCH)
118 .unwrap()
119 .as_millis();
120 let file_name = self.create_file_name(time);
121 let response = driver.upload_object(&file_name, contents, file_path).await;
122
123 match response {
124 Ok(_) => Ok(file_name),
125 Err(_) => Err(String::from("Failed to save data file")),
126 }
127 }
128 Err(err) => Err(err.to_string()),
129 }
130 }
131
132 pub async fn fetch_compressed_data_by_key(
133 &self,

Callers

nothing calls this directly

Calls 3

get_driverMethod · 0.80
create_file_nameMethod · 0.80
upload_objectMethod · 0.45

Tested by

no test coverage detected