|
1 | 1 | #![allow(dead_code, unused_variables, unused_mut)] |
2 | 2 |
|
3 | | -use apollo_committer_types::communication::SharedCommitterClient; |
| 3 | +use apollo_committer_types::communication::{ |
| 4 | + CommitterClientResponse, |
| 5 | + CommitterRequest, |
| 6 | + SharedCommitterClient, |
| 7 | +}; |
4 | 8 | use tokio::sync::mpsc::{Receiver, Sender}; |
5 | 9 | use tokio::task::JoinHandle; |
6 | 10 |
|
@@ -44,8 +48,20 @@ impl StateCommitter { |
44 | 48 | mut results_sender: Sender<CommitmentTaskOutput>, |
45 | 49 | committer_client: SharedCommitterClient, |
46 | 50 | ) { |
47 | | - // Placeholder: simply drain the receiver and do nothing. |
48 | | - // TODO(Amos): Implement the actual commitment tasks logic. |
49 | | - while let Some(_task) = tasks_receiver.recv().await {} |
| 51 | + while let Some(CommitmentTaskInput(request)) = tasks_receiver.recv().await { |
| 52 | + let (committer_response, height) = match request { |
| 53 | + CommitterRequest::CommitBlock(commit_block_request) => { |
| 54 | + let height = commit_block_request.height; |
| 55 | + let response = committer_client.commit_block(commit_block_request).await; |
| 56 | + (CommitterClientResponse::CommitBlock(response), height) |
| 57 | + } |
| 58 | + CommitterRequest::RevertBlock(revert_block_request) => { |
| 59 | + let height = revert_block_request.height; |
| 60 | + let response = committer_client.revert_block(revert_block_request).await; |
| 61 | + (CommitterClientResponse::RevertBlock(response), height) |
| 62 | + } |
| 63 | + }; |
| 64 | + results_sender.send(CommitmentTaskOutput { committer_response, height }).await.unwrap() |
| 65 | + } |
50 | 66 | } |
51 | 67 | } |
0 commit comments