-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
71 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// TODO(Tsabary/Yael/Dafna): Replace with actual batcher code. | ||
pub struct Batcher {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
use std::net::IpAddr; | ||
|
||
use async_trait::async_trait; | ||
use starknet_batcher_types::communication::{ | ||
BatcherRequest, | ||
BatcherRequestAndResponseSender, | ||
BatcherResponse, | ||
}; | ||
use starknet_mempool_infra::component_definitions::ComponentRequestHandler; | ||
use starknet_mempool_infra::component_runner::ComponentStarter; | ||
use starknet_mempool_infra::component_server::{LocalComponentServer, RemoteComponentServer}; | ||
use tokio::sync::mpsc::Receiver; | ||
|
||
use crate::batcher::Batcher; | ||
|
||
pub type LocalBatcherServer = LocalComponentServer<Batcher, BatcherRequest, BatcherResponse>; | ||
pub type RemoteBatcherServer = RemoteComponentServer<Batcher, BatcherRequest, BatcherResponse>; | ||
|
||
pub fn create_local_batcher_server( | ||
batcher: Batcher, | ||
rx_batcher: Receiver<BatcherRequestAndResponseSender>, | ||
) -> LocalBatcherServer { | ||
LocalComponentServer::new(batcher, rx_batcher) | ||
} | ||
|
||
pub fn create_remote_batcher_server( | ||
batcher: Batcher, | ||
ip_address: IpAddr, | ||
port: u16, | ||
) -> RemoteBatcherServer { | ||
RemoteComponentServer::new(batcher, ip_address, port) | ||
} | ||
|
||
#[async_trait] | ||
impl ComponentRequestHandler<BatcherRequest, BatcherResponse> for Batcher { | ||
async fn handle_request(&mut self, request: BatcherRequest) -> BatcherResponse { | ||
match request { | ||
BatcherRequest::BatcherFnOne(_batcher_input) => { | ||
// TODO(Tsabary/Yael/Dafna): Invoke a function that returns a | ||
// BatcherResult<BatcherFnOneReturnValue>, and return | ||
// the BatcherResponse::BatcherFnOneInput accordingly. | ||
unimplemented!() | ||
} | ||
BatcherRequest::BatcherFnTwo(_batcher_input) => { | ||
// TODO(Tsabary/Yael/Dafna): Invoke a function that returns a | ||
// BatcherResult<BatcherFnTwoReturnValue>, and return | ||
// the BatcherResponse::BatcherFnTwoInput accordingly. | ||
unimplemented!() | ||
} | ||
} | ||
} | ||
} | ||
|
||
#[async_trait] | ||
impl ComponentStarter for Batcher {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
|
||
pub mod batcher; | ||
pub mod communication; |