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

fix(node): replicate fresh scratchpad if got repaid #2477

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions ant-node/src/put_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ impl Node {
// if we already have the data we can return early
if already_exists {
// if we're receiving this chunk PUT again, and we have been paid,
// we eagery retry replicaiton as it seems like other nodes are having trouble
// we eagerly retry replicaiton as it seems like other nodes are having trouble
// did not manage to get this chunk as yet
self.replicate_valid_fresh_record(record_key, RecordType::Chunk);

Expand Down Expand Up @@ -111,25 +111,34 @@ impl Node {
// Finally before we store, lets bail for any payment issues
payment_res?;

// Writing chunk to disk takes time, hence try to execute it first.
// Writing records to disk takes time, hence try to execute it first.
// So that when the replicate target asking for the copy,
// the node can have a higher chance to respond.
let store_scratchpad_result = self
.validate_and_store_scratchpad_record(scratchpad, record_key.clone(), true)
.await;

if store_scratchpad_result.is_ok() {
Marker::ValidScratchpadRecordPutFromClient(&PrettyPrintRecordKey::from(
&record_key,
))
.log();
self.replicate_valid_fresh_record(record_key.clone(), RecordType::Scratchpad);

// Notify replication_fetcher to mark the attempt as completed.
// Send the notification earlier to avoid it got skipped due to:
// the record becomes stored during the fetch because of other interleaved process.
self.network()
.notify_fetch_completed(record_key, RecordType::Scratchpad);
match store_scratchpad_result {
// if we're receiving this scratchpad PUT again, and we have been paid,
// we eagerly retry replicaiton as it seems like other nodes are having trouble
// did not manage to get this scratchpad as yet.
Ok(_) | Err(Error::IgnoringOutdatedScratchpadPut) => {
Marker::ValidScratchpadRecordPutFromClient(&PrettyPrintRecordKey::from(
&record_key,
))
.log();
self.replicate_valid_fresh_record(
record_key.clone(),
RecordType::Scratchpad,
);

// Notify replication_fetcher to mark the attempt as completed.
// Send the notification earlier to avoid it got skipped due to:
// the record becomes stored during the fetch because of other interleaved process.
self.network()
.notify_fetch_completed(record_key, RecordType::Scratchpad);
}
Err(_) => {}
}

store_scratchpad_result
Expand Down
Loading