Skip to content

Commit

Permalink
Faster piece getting via RPC
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Jun 15, 2024
1 parent 46730d6 commit c03d6ab
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/subspace-farmer/src/farmer_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ where
debug!(%segment_index, "Downloading potentially useful pieces");

// We do not insert pieces into cache/heap yet, so we don't know if all of these pieces
// will be included, but there is a good chance they will be and we want to acknowledge
// will be included, but there is a good chance they will be, and we want to acknowledge
// new segment header as soon as possible
let pieces_to_maybe_include = segment_index
.segment_piece_indexes()
Expand Down
13 changes: 9 additions & 4 deletions crates/subspace-farmer/src/node_client/node_rpc_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,15 @@ impl NodeClient for NodeRpcClient {
}

async fn piece(&self, piece_index: PieceIndex) -> Result<Option<Piece>, RpcError> {
Ok(self
.client
.request("subspace_piece", rpc_params![&piece_index])
.await?)
let client = Arc::clone(&self.client);
// Spawn a separate task to improve concurrency due to slow-ish JSON decoding that causes
// issues for jsonrpsee
let piece_fut = tokio::task::spawn(async move {
client
.request("subspace_piece", rpc_params![&piece_index])
.await
});
Ok(piece_fut.await??)
}

async fn acknowledge_archived_segment_header(
Expand Down

0 comments on commit c03d6ab

Please sign in to comment.