Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: chunk files only once when making payment for their storage #501

Conversation

bochaco
Copy link
Member

@bochaco bochaco commented Jul 10, 2023

Resolves #340 .

Description

Summary generated by Reviewpad on 10 Jul 23 17:45 UTC

This pull request refactors the code related to making payments for storage when chunking files. It includes changes to the files.rs and wallet.rs files.

In the files.rs file, the upload_files function has been modified to chunk and store files in a more efficient way. Instead of chunking files and making payments for each chunk individually, now the files are chunked only once and stored using the chunk_and_pay_for_storage function from the wallet.rs file. The upload_file function has been renamed to upload_chunks to reflect this change.

The upload_files function now takes care of storing the chunks and generating the proofs for payment. It also creates a directory to store the uploaded files and saves information about the uploaded files in a file for future reference.

The chunk_and_pay_for_storage function in the wallet.rs file has been modified to accommodate the changes in the files.rs file. It now takes an additional parameter pay to indicate whether payment should be made for storage. It chunks the files, stores the chunks, and generates the payment proofs if pay is true.

Overall, these changes improve the efficiency of chunking and storing files by reducing the number of times chunks are created and payments are made.

@reviewpad reviewpad bot added the Medium Medium sized PR label Jul 10, 2023
let client = self.client.clone();
let chunk_addr = *chunk.address();
let payment = payment_proofs.get(chunk_addr.name()).cloned();
// TODO: re-enable requirement to always provide payment proof

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
@bochaco bochaco force-pushed the refactor-chunk-files-once-when-making-storage-payment branch 4 times, most recently from f56da96 to c58db73 Compare July 11, 2023 14:38
@reviewpad reviewpad bot added Large Large sized PR and removed Medium Medium sized PR labels Jul 11, 2023
value: Bytes::from(file),
}),
(_, Err(err)) => {
// FIXME: this error won't be seen/reported, thus assumed all chunks were read and stored.

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
client: &Client,
root_dir: &Path,
files_path: &Path,
) -> Result<PaymentProofsMap> {
pay: bool, // TODO: to be removed; temporarily payment is optional

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
@bochaco bochaco marked this pull request as ready for review July 11, 2023 14:44
@reviewpad reviewpad bot requested a review from maqi July 11, 2023 14:45
@bochaco bochaco force-pushed the refactor-chunk-files-once-when-making-storage-payment branch 3 times, most recently from fcb4001 to b46fcdc Compare July 11, 2023 16:40
@bochaco bochaco force-pushed the refactor-chunk-files-once-when-making-storage-payment branch from b46fcdc to 722ac36 Compare July 11, 2023 18:28
@joshuef joshuef added this pull request to the merge queue Jul 12, 2023
Merged via the queue into maidsafe:main with commit b3c8fc1 Jul 12, 2023
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Large Large sized PR
Projects
None yet
2 participants