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

Method write_compressed_data

bridge/src/client/data_store/data_store.rs:152–175  ·  view source on GitHub ↗
(
        &self,
        contents: &Vec<u8>,
        file_path: Option<&str>,
    )

Source from the content-addressed store, hash-verified

150 }
151
152 pub async fn write_compressed_data(
153 &self,
154 contents: &Vec<u8>,
155 file_path: Option<&str>,
156 ) -> Result<(String, usize), String> {
157 match self.get_driver() {
158 Ok(driver) => {
159 let time = SystemTime::now()
160 .duration_since(UNIX_EPOCH)
161 .unwrap()
162 .as_millis();
163 let file_name = self.create_file_name(time);
164 let response = driver
165 .upload_compressed_object(&file_name, contents, file_path)
166 .await;
167
168 match response {
169 Ok(size) => Ok((file_name, size)),
170 Err(_) => Err(String::from("Failed to save data file")),
171 }
172 }
173 Err(err) => Err(err.to_string()),
174 }
175 }
176
177 pub fn get_past_max_file_name_by_timestamp(
178 &self,

Callers 1

save_to_data_storeMethod · 0.80

Calls 3

get_driverMethod · 0.80
create_file_nameMethod · 0.80

Tested by

no test coverage detected