Skip to content

Commit 839ce6c

Browse files
committed
apollo_batcher: perform commitment tasks
1 parent 2e05557 commit 839ce6c

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

crates/apollo_batcher/src/commitment_manager/state_committer.rs

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#![allow(dead_code, unused_variables, unused_mut)]
22

3-
use apollo_committer_types::communication::SharedCommitterClient;
3+
use apollo_committer_types::communication::{
4+
CommitterClientResponse,
5+
CommitterRequest,
6+
SharedCommitterClient,
7+
};
48
use tokio::sync::mpsc::{Receiver, Sender};
59
use tokio::task::JoinHandle;
610

@@ -44,8 +48,20 @@ impl StateCommitter {
4448
mut results_sender: Sender<CommitmentTaskOutput>,
4549
committer_client: SharedCommitterClient,
4650
) {
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+
}
5066
}
5167
}

0 commit comments

Comments
 (0)