@@ -6,11 +6,10 @@ use std::error::Error;
66use std:: sync:: Arc ;
77use tokio:: sync:: RwLock ;
88
9- use mithril_common:: crypto_helper :: ProtocolStakeDistribution ;
9+ use mithril_common:: chain_observer :: FakeObserver ;
1010use mithril_common:: digesters:: ImmutableDigester ;
11- use mithril_common:: fake_data;
1211use mithril_common:: store:: adapter:: JsonFileStoreAdapter ;
13- use mithril_common:: store:: stake_store:: { StakeStore , StakeStorer } ;
12+ use mithril_common:: store:: stake_store:: StakeStore ;
1413use mithril_signer:: { CertificateHandlerHTTPClient , Config , MithrilSingleSigner , Runtime } ;
1514
1615/// CLI args
@@ -74,35 +73,17 @@ async fn main() -> Result<(), Box<dyn Error>> {
7473 let stake_store = Arc :: new ( RwLock :: new ( StakeStore :: new ( Box :: new (
7574 JsonFileStoreAdapter :: new ( config. stake_store_directory . clone ( ) ) ?,
7675 ) ) ) ) ;
77- setup_dependencies_fake_data ( stake_store . clone ( ) ) . await ;
76+ let chain_observer = Arc :: new ( RwLock :: new ( FakeObserver :: new ( ) ) ) ;
7877
7978 // Should the runtime loop returns an error ? If yes should we abort the loop at the first error or is their some tolerance ?
8079 let mut runtime = Runtime :: new (
8180 Box :: new ( certificate_handler) ,
8281 Box :: new ( single_signer) ,
8382 Box :: new ( digester) ,
8483 stake_store. clone ( ) ,
84+ chain_observer. clone ( ) ,
8585 ) ;
8686 runtime. infinite_loop ( config. run_interval ) . await ;
8787
8888 Ok ( ( ) )
8989}
90-
91- /// Setup dependencies with fake data
92- // TODO: remove this function when new runtime is implemented
93- async fn setup_dependencies_fake_data ( stake_store : Arc < RwLock < dyn StakeStorer > > ) {
94- // Update stake distribution
95- let mut stake_store = stake_store. write ( ) . await ;
96- let total_signers = 5 ;
97- let epoch = 0 ; // TODO: to remove once the runtime feeds the stake distribution
98- let stakes: ProtocolStakeDistribution = fake_data:: signers_with_stakes ( total_signers)
99- . into_iter ( )
100- . map ( |signer| signer. into ( ) )
101- . collect :: < _ > ( ) ;
102- for stake in stakes {
103- stake_store
104- . save_stake ( epoch, stake. into ( ) )
105- . await
106- . expect ( "fake stake distribution update failed" ) ;
107- }
108- }
0 commit comments