More networking work, adding found keys saving.

This commit is contained in:
Kirill Shakirov
2026-03-05 17:26:16 +01:00
parent 10ab14d698
commit fc356982c7
4 changed files with 61 additions and 6 deletions
+10 -1
View File
@@ -31,6 +31,7 @@ fn work_rec_to_work_data(work_rec: database::JobRecord) -> WorkData {
#[derive(Debug, Default)]
pub struct NyashService {
db: redb::Database,
progress: f64,
}
#[tonic::async_trait]
@@ -63,7 +64,15 @@ impl NyashLuks for NyashService {
async fn commit_work(&self, request: Request<WorkCommit>) -> Result<Response<CommitReply>, Status> {
println!("Got a request: {:?}", request);
let work_id: u64 = request.into_inner().work_id;
match database::db_commit_job(&self.db, work_id) {
Ok(true) => Ok(Response::new(CommitReply {status_code: 0, progress: self.progress})),
Ok(false) => Ok(Response::new(CommitReply {status_code: 1, progress: self.progress})),
Err(_) => Err(Status::internal("DB error"))
}
}
async fn request_progress(&self, _request: Request<ProgressRequest>) -> Result<Response<ProgressReply>, Status> {
Ok(Response::new(ProgressReply {progress: self.progress}))
}
}