I’m reading store_blob
because @joshuef mentioned the PUT command (I assume this is what the command does). And I can’t quite understand it, in particular, it seems to only store the data map to the network, but not the data itself? I haven’t looked into self-encryption yet, but I assume data map only stores info about where to find each piece of the data, but not the data itself?
Here’s the code for reference, in sn_client/src/client/blob_apis.rs
:
pub async fn store_blob(&mut self, the_blob: Blob) -> Result<Blob, ClientError> {
info!("Storing blob at given address: {:?}", the_blob.address());
let is_pub = the_blob.is_pub();
let data_map = self.generate_data_map(&the_blob).await?;
let serialised_data_map = serialize(&data_map)?;
let data_to_write_to_network =
serialize(&DataTypeEncoding::Serialised(serialised_data_map))
.map_err(ClientError::from)?;
let blob_to_write = self
.pack(self.public_key().await, data_to_write_to_network, is_pub)
.await?;
let cmd = DataCmd::Blob(BlobWrite::New(blob_to_write.clone()));
self.pay_and_send_data_command(cmd).await?;
Ok(blob_to_write)
}
Another minor question I have is, why so many serializations? E.g. first the data map is serialized, and then the serialized data map is wrapped and serialized again, and in pack()
there is a third serialization. So it seems like each step requires serializing the previous data, and I’m a bit curious what makes this a necessity?
Again I thank everyone for their time reading my questions, I know the team is really busy now. But I guess reading the code is one of the better ways to understand the project, and I hope my inquiry is not too much burden on you guys.