1
- use crate :: utils:: archive_block:: archive;
2
- use crate :: utils:: planetscale:: { ps_archive_block, ps_get_latest_block_id} ;
1
+ use crate :: utils:: archive_block:: sprint_blocks_archiving;
3
2
use crate :: utils:: schema:: Network ;
4
3
use crate :: utils:: server_handlers:: { handle_block, handle_block_raw, handle_info, handle_weave_gm} ;
5
4
use axum:: { routing:: get, Router } ;
6
- use std:: thread;
7
- use std:: time:: Duration ;
8
5
use tokio:: task;
9
6
10
7
mod utils;
11
8
#[ shuttle_runtime:: main]
12
9
async fn main ( ) -> shuttle_axum:: ShuttleAxum {
13
10
let network = Network :: config ( ) ;
14
- let block_time = network. block_time ;
15
- let ps_latest_archived_block = ps_get_latest_block_id ( ) . await ;
16
- // it defaults to network.start_block if planestcale fails
17
- let mut start_block = ps_latest_archived_block;
18
11
19
12
println ! ( "\n {:#?}\n \n " , network) ;
20
13
// server routes
@@ -24,21 +17,9 @@ async fn main() -> shuttle_axum::ShuttleAxum {
24
17
. route ( "/block/:id" , get ( handle_block) )
25
18
. route ( "/block/raw/:id" , get ( handle_block_raw) ) ;
26
19
27
- // poll blocks & archive in parallel
20
+ // poll blocks & sprint archiving in parallel
28
21
task:: spawn ( async move {
29
- loop {
30
- println ! ( "\n {}" , "#" . repeat( 100 ) ) ;
31
- println ! (
32
- "\n ARCHIVING BLOCK #{} of Network {} -- ChainId: {}\n " ,
33
- start_block, network. name, network. network_chain_id
34
- ) ;
35
- let archive_txid = archive ( Some ( start_block) ) . await . unwrap ( ) ;
36
- let _ = ps_archive_block ( & start_block, & archive_txid) . await ;
37
- start_block += 1 ;
38
- println ! ( "\n {}" , "#" . repeat( 100 ) ) ;
39
- thread:: sleep ( Duration :: from_secs ( block_time. into ( ) ) ) ;
40
- }
22
+ sprint_blocks_archiving ( ) . await ;
41
23
} ) ;
42
-
43
24
Ok ( router. into ( ) )
44
25
}
0 commit comments