11
2- use super :: DevnetEvent ;
2+ use super :: { DevnetEvent , NodeObserverEvent } ;
33use crate :: integrate:: { BlockData , MempoolAdmissionData , ServiceStatusData , Status , Transaction } ;
44use crate :: poke:: load_session;
55use crate :: publish:: { publish_contract, Network } ;
@@ -17,6 +17,7 @@ use rocket::config::{Config, Environment, LoggingLevel};
1717use rocket:: State ;
1818use rocket_contrib:: json:: Json ;
1919use serde_json:: Value ;
20+ use tracing:: info;
2021use std:: collections:: { BTreeMap , VecDeque } ;
2122use std:: convert:: { TryFrom , TryInto } ;
2223use std:: error:: Error ;
@@ -74,7 +75,7 @@ pub struct EventObserverConfig {
7475
7576impl EventObserverConfig {
7677 pub fn new ( devnet_config : DevnetConfig , manifest_path : PathBuf , accounts : BTreeMap < String , AccountConfig > ) -> Self {
77- println ! ( "Checking contracts..." ) ;
78+ info ! ( "Checking contracts..." ) ;
7879 let session_settings = match load_session ( manifest_path. clone ( ) , false , Network :: Devnet ) {
7980 Ok ( settings) => settings,
8081 Err ( e) => {
@@ -130,13 +131,15 @@ pub async fn start_events_observer(
130131 events_config : EventObserverConfig ,
131132 devnet_event_tx : Sender < DevnetEvent > ,
132133 terminator_rx : Receiver < bool > ,
134+ event_tx : Option < Sender < NodeObserverEvent > > ,
133135) -> Result < ( ) , Box < dyn Error > > {
134136 let port = events_config. devnet_config . orchestrator_port ;
135137 let manifest_path = events_config. manifest_path . clone ( ) ;
136138 let rw_lock = Arc :: new ( RwLock :: new ( events_config) ) ;
137139
138140 let moved_rw_lock = rw_lock. clone ( ) ;
139141 let moved_tx = Arc :: new ( Mutex :: new ( devnet_event_tx. clone ( ) ) ) ;
142+ let moved_node_tx = Arc :: new ( Mutex :: new ( event_tx. clone ( ) ) ) ;
140143 let config = Config :: build ( Environment :: Production )
141144 . address ( "127.0.0.1" )
142145 . port ( port)
@@ -149,6 +152,7 @@ pub async fn start_events_observer(
149152 rocket:: custom ( config)
150153 . manage ( moved_rw_lock)
151154 . manage ( moved_tx)
155+ . manage ( moved_node_tx)
152156 . mount (
153157 "/" ,
154158 routes ! [
@@ -212,6 +216,7 @@ pub async fn start_events_observer(
212216pub fn handle_new_burn_block (
213217 devnet_events_tx : State < Arc < Mutex < Sender < DevnetEvent > > > > ,
214218 new_burn_block : Json < NewBurnBlock > ,
219+ node_event_tx : State < Arc < Mutex < Option < Sender < NodeObserverEvent > > > > > ,
215220) -> Json < Value > {
216221 let devnet_events_tx = devnet_events_tx. inner ( ) ;
217222
@@ -246,6 +251,7 @@ pub fn handle_new_block(
246251 config : State < Arc < RwLock < EventObserverConfig > > > ,
247252 devnet_events_tx : State < Arc < Mutex < Sender < DevnetEvent > > > > ,
248253 new_block : Json < NewBlock > ,
254+ node_event_tx : State < Arc < Mutex < Option < Sender < NodeObserverEvent > > > > > ,
249255) -> Json < Value > {
250256 let devnet_events_tx = devnet_events_tx. inner ( ) ;
251257 let config = config. inner ( ) ;
@@ -469,6 +475,7 @@ pub fn handle_new_microblocks(
469475 config : State < Arc < RwLock < EventObserverConfig > > > ,
470476 devnet_events_tx : State < Arc < Mutex < Sender < DevnetEvent > > > > ,
471477 new_microblock : Json < NewMicroBlock > ,
478+ node_event_tx : State < Arc < Mutex < Option < Sender < NodeObserverEvent > > > > > ,
472479) -> Json < Value > {
473480
474481 let devnet_events_tx = devnet_events_tx. inner ( ) ;
@@ -506,6 +513,7 @@ pub fn handle_new_microblocks(
506513pub fn handle_new_mempool_tx (
507514 devnet_events_tx : State < Arc < Mutex < Sender < DevnetEvent > > > > ,
508515 raw_txs : Json < Vec < String > > ,
516+ node_event_tx : State < Arc < Mutex < Option < Sender < NodeObserverEvent > > > > > ,
509517) -> Json < Value > {
510518 let decoded_transactions = raw_txs. iter ( ) . map ( |t| get_tx_description ( t) ) . collect :: < Vec < String > > ( ) ;
511519
0 commit comments