File tree Expand file tree Collapse file tree 2 files changed +24
-10
lines changed Expand file tree Collapse file tree 2 files changed +24
-10
lines changed Original file line number Diff line number Diff line change
1
+ use std:: { io, net:: SocketAddr } ;
2
+
1
3
use proto:: internal:: internal_api_server:: InternalApi ;
2
4
use timeboost_builder:: { CertifierDown , Handle } ;
3
5
use timeboost_types:: Block ;
4
6
use tonic:: { Request , Response , Status } ;
5
7
6
- use timeboost_proto as proto;
8
+ use timeboost_proto:: { self as proto, internal :: internal_api_server :: InternalApiServer } ;
7
9
8
- pub struct InternalApiService {
9
- block_handler : Handle ,
10
+ pub struct GrpcServer {
11
+ service : InternalApiService ,
10
12
}
11
13
12
- impl InternalApiService {
14
+ impl GrpcServer {
13
15
pub fn new ( block_handler : Handle ) -> Self {
14
- Self { block_handler }
16
+ Self {
17
+ service : InternalApiService { block_handler } ,
18
+ }
19
+ }
20
+
21
+ pub async fn serve ( self , addr : SocketAddr ) -> io:: Result < ( ) > {
22
+ tonic:: transport:: Server :: builder ( )
23
+ . add_service ( InternalApiServer :: new ( self . service ) )
24
+ . serve ( addr)
25
+ . await
26
+ . map_err ( io:: Error :: other)
15
27
}
16
28
}
17
29
30
+ struct InternalApiService {
31
+ block_handler : Handle ,
32
+ }
33
+
18
34
#[ tonic:: async_trait]
19
35
impl InternalApi for InternalApiService {
20
36
async fn submit_block ( & self , r : Request < proto:: block:: Block > ) -> Result < Response < ( ) > , Status > {
Original file line number Diff line number Diff line change @@ -7,7 +7,6 @@ use anyhow::Result;
7
7
use metrics:: TimeboostMetrics ;
8
8
use multisig:: PublicKey ;
9
9
use timeboost_builder:: { Certifier , CertifierDown , Submitter } ;
10
- use timeboost_proto:: internal:: internal_api_server:: InternalApiServer ;
11
10
use timeboost_sequencer:: { Output , Sequencer } ;
12
11
use timeboost_types:: BundleVariant ;
13
12
use timeboost_utils:: types:: prometheus:: PrometheusMetrics ;
@@ -23,7 +22,7 @@ pub use timeboost_sequencer as sequencer;
23
22
pub use timeboost_types as types;
24
23
25
24
use crate :: api:: ApiServer ;
26
- use crate :: api:: internal:: InternalApiService ;
25
+ use crate :: api:: internal:: GrpcServer ;
27
26
use crate :: forwarder:: nitro_forwarder:: NitroForwarder ;
28
27
29
28
pub mod api;
@@ -82,9 +81,8 @@ impl Timeboost {
82
81
. build ( )
83
82
}
84
83
85
- pub fn internal_grpc_api ( & self ) -> tonic:: transport:: server:: Router {
86
- let svc = InternalApiService :: new ( self . certifier . handle ( ) ) ;
87
- tonic:: transport:: Server :: builder ( ) . add_service ( InternalApiServer :: new ( svc) )
84
+ pub fn internal_grpc_api ( & self ) -> GrpcServer {
85
+ GrpcServer :: new ( self . certifier . handle ( ) )
88
86
}
89
87
90
88
pub async fn go ( mut self ) -> Result < ( ) > {
You can’t perform that action at this time.
0 commit comments