@@ -48,6 +48,11 @@ pub struct NewBlock {
4848 // burn_amount: u32,
4949}
5050
51+ #[ derive( Deserialize ) ]
52+ pub struct NewMicroBlock {
53+ transactions : Vec < NewTransaction > ,
54+ }
55+
5156#[ derive( Deserialize ) ]
5257pub struct NewTransaction {
5358 txid : String ,
@@ -459,11 +464,38 @@ pub fn handle_new_block(
459464 } ) )
460465}
461466
462- #[ post( "/new_microblocks" , format = "application/json" ) ]
467+ #[ post( "/new_microblocks" , format = "application/json" , data = "<new_microblock>" ) ]
463468pub fn handle_new_microblocks (
464- _config : State < Arc < RwLock < EventObserverConfig > > > ,
465- _devnet_events_tx : State < Arc < Mutex < Sender < DevnetEvent > > > > ,
469+ config : State < Arc < RwLock < EventObserverConfig > > > ,
470+ devnet_events_tx : State < Arc < Mutex < Sender < DevnetEvent > > > > ,
471+ new_microblock : Json < NewMicroBlock > ,
466472) -> Json < Value > {
473+
474+ let devnet_events_tx = devnet_events_tx. inner ( ) ;
475+ let config = config. inner ( ) ;
476+
477+ if let Ok ( tx) = devnet_events_tx. lock ( ) {
478+ let _ = tx. send ( DevnetEvent :: info ( format ! (
479+ "Microblock received including {} transactions" ,
480+ new_microblock. transactions. len( ) ,
481+ ) ) ) ;
482+ }
483+
484+ // let transactions = new_block
485+ // .transactions
486+ // .iter()
487+ // .map(|t| {
488+ // let description = get_tx_description(&t.raw_tx);
489+ // Transaction {
490+ // txid: t.txid.clone(),
491+ // success: t.status == "success",
492+ // result: get_value_description(&t.raw_result),
493+ // events: vec![],
494+ // description,
495+ // }
496+ // })
497+ // .collect();
498+
467499 Json ( json ! ( {
468500 "status" : 200 ,
469501 "result" : "Ok" ,
0 commit comments