-
Notifications
You must be signed in to change notification settings - Fork 5
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
feat: msp check previous block #337
base: main
Are you sure you want to change the base?
Changes from all commits
5c0e1f2
0bccfb6
d7c056a
3fdb907
ee2c27b
5b4461a
327be01
95adc49
0bd3cb2
680bca7
aceacad
43a883d
5b6ecc4
302a0ff
9dc8846
dff7e02
a09b3b2
d046d26
6eb9df6
8ca3749
db47403
51039c4
b17af7f
643be98
b9e8149
0ed2221
aefdf1a
c202fcf
158bd85
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -317,7 +317,7 @@ where | |
{ | ||
warn!( | ||
target: LOG_TARGET, | ||
"Batch upload rejected by peer {:?}, retrying... (attempt {})", | ||
"Final batch upload rejected by peer {:?}, retrying... (attempt {})", | ||
peer_id, | ||
retry_attempts + 1 | ||
); | ||
|
@@ -326,7 +326,27 @@ where | |
// Wait for a short time before retrying | ||
tokio::time::sleep(std::time::Duration::from_secs(1)).await; | ||
} | ||
Err(RequestError::RequestFailure(RequestFailure::Refused)) => { | ||
Err(RequestError::RequestFailure(RequestFailure::Network(_))) | ||
| Err(RequestError::RequestFailure(RequestFailure::NotConnected)) | ||
if retry_attempts < 10 => | ||
{ | ||
warn!( | ||
target: LOG_TARGET, | ||
"Unable to upload final batch to peer {:?}, retrying... (attempt {})", | ||
peer_id, | ||
retry_attempts + 1 | ||
); | ||
retry_attempts += 1; | ||
|
||
// Wait a bit for the MSP to be online | ||
self.storage_hub_handler | ||
.blockchain | ||
.wait_for_num_blocks(5) | ||
.await?; | ||
} | ||
Err(RequestError::RequestFailure(RequestFailure::Refused)) | ||
| Err(RequestError::RequestFailure(RequestFailure::Network(_))) | ||
| Err(RequestError::RequestFailure(RequestFailure::NotConnected)) => { | ||
// Return an error if the provider refused to answer. | ||
return Err(anyhow::anyhow!("Failed to send file {:?}", file_key)); | ||
} | ||
|
@@ -388,7 +408,7 @@ where | |
.upload_request(peer_id, file_key.as_ref().into(), proof.clone(), None) | ||
.await; | ||
|
||
match upload_response { | ||
match upload_response.as_ref() { | ||
Ok(r) => { | ||
debug!( | ||
target: LOG_TARGET, | ||
|
@@ -421,7 +441,27 @@ where | |
// Wait for a short time before retrying | ||
tokio::time::sleep(std::time::Duration::from_secs(1)).await; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In order to standardize the retrying logic, should we also wait for one block here instead of one second ? Because And because of latency and block propagation time, one second could be too short in a real network. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this flow independent from the blockchain. The user here is trying to send data to a peer (provider). |
||
} | ||
Err(RequestError::RequestFailure(RequestFailure::Refused)) => { | ||
Err(RequestError::RequestFailure(RequestFailure::Network(_))) | ||
| Err(RequestError::RequestFailure(RequestFailure::NotConnected)) | ||
if retry_attempts < 10 => | ||
{ | ||
warn!( | ||
target: LOG_TARGET, | ||
"Unable to upload final batch to peer {:?}, retrying... (attempt {})", | ||
peer_id, | ||
retry_attempts + 1 | ||
); | ||
retry_attempts += 1; | ||
|
||
// Wait a bit for the MSP to be online | ||
self.storage_hub_handler | ||
.blockchain | ||
.wait_for_num_blocks(5) | ||
.await?; | ||
} | ||
Err(RequestError::RequestFailure(RequestFailure::Refused)) | ||
| Err(RequestError::RequestFailure(RequestFailure::Network(_))) | ||
| Err(RequestError::RequestFailure(RequestFailure::NotConnected)) => { | ||
// Return an error if the provider refused to answer. | ||
return Err(anyhow::anyhow!("Failed to send file {:?}", file_key)); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe ignore since it's personal preference
Can you rename
sr
tostorage_request
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is hard to differentiate
storage_requests
andstorage_request
when browsing the code. I realize thatsr
is not a good name but we can quickly understand what it is by looking at the loop. It is a trade off and I guess linked to programming habits.Maybe to improve readability I could add a comment ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a comment is fine by me, btw.