@@ -11,8 +11,8 @@ use serde::Serialize;
1111use sim_core:: {
1212 clock:: Timestamp ,
1313 config:: { NodeId , SimConfiguration } ,
14- events:: Event ,
15- model:: { EndorserBlockId , InputBlockId , TransactionId , VoteBundleId } ,
14+ events:: { Event , Node } ,
15+ model:: TransactionId ,
1616} ;
1717use tokio:: {
1818 fs:: { self , File } ,
@@ -21,6 +21,10 @@ use tokio::{
2121} ;
2222use tracing:: { info, info_span} ;
2323
24+ type InputBlockId = sim_core:: model:: InputBlockId < Node > ;
25+ type EndorserBlockId = sim_core:: model:: EndorserBlockId < Node > ;
26+ type VoteBundleId = sim_core:: model:: VoteBundleId < Node > ;
27+
2428#[ derive( Clone , Serialize ) ]
2529struct OutputEvent {
2630 time : Timestamp ,
@@ -206,16 +210,16 @@ impl EventMonitor {
206210 }
207211 if let Some ( ( old_producer, old_vrf) ) = blocks. get ( & slot) {
208212 if * old_vrf > vrf {
209- * blocks_published. entry ( producer) . or_default ( ) += 1 ;
213+ * blocks_published. entry ( producer. id ) . or_default ( ) += 1 ;
210214 * blocks_published. entry ( * old_producer) . or_default ( ) -= 1 ;
211215 * blocks_rejected. entry ( * old_producer) . or_default ( ) += 1 ;
212- blocks. insert ( slot, ( producer, vrf) ) ;
216+ blocks. insert ( slot, ( producer. id , vrf) ) ;
213217 } else {
214- * blocks_rejected. entry ( producer) . or_default ( ) += 1 ;
218+ * blocks_rejected. entry ( producer. id ) . or_default ( ) += 1 ;
215219 }
216220 } else {
217- * blocks_published. entry ( producer) . or_default ( ) += 1 ;
218- blocks. insert ( slot, ( producer, vrf) ) ;
221+ * blocks_published. entry ( producer. id ) . or_default ( ) += 1 ;
222+ blocks. insert ( slot, ( producer. id , vrf) ) ;
219223 }
220224 for published_tx in all_txs {
221225 let tx = txs. get_mut ( & published_tx) . unwrap ( ) ;
@@ -229,33 +233,30 @@ impl EventMonitor {
229233 Event :: PraosBlockSent { .. } => { }
230234 Event :: PraosBlockReceived { .. } => { }
231235 Event :: InputBlockLotteryWon { .. } => { }
232- Event :: InputBlockGenerated {
233- header,
234- transactions,
235- } => {
236+ Event :: InputBlockGenerated { id, transactions } => {
236237 generated_ibs += 1 ;
237238 if transactions. is_empty ( ) {
238239 empty_ibs += 1 ;
239240 }
240- pending_ibs. insert ( header . id ) ;
241- ib_txs. insert ( header . id , transactions. clone ( ) ) ;
241+ pending_ibs. insert ( id . clone ( ) ) ;
242+ ib_txs. insert ( id . clone ( ) , transactions. clone ( ) ) ;
242243 let mut ib_bytes = 0 ;
243244 for tx_id in & transactions {
244- * txs_in_ib. entry ( header . id ) . or_default ( ) += 1. ;
245+ * txs_in_ib. entry ( id . clone ( ) ) . or_default ( ) += 1. ;
245246 * ibs_containing_tx. entry ( * tx_id) . or_default ( ) += 1. ;
246247 let tx = txs. get_mut ( tx_id) . unwrap ( ) ;
247248 ib_bytes += tx. bytes ;
248- * bytes_in_ib. entry ( header . id ) . or_default ( ) += tx. bytes as f64 ;
249+ * bytes_in_ib. entry ( id . clone ( ) ) . or_default ( ) += tx. bytes as f64 ;
249250 if tx. included_in_ib . is_none ( ) {
250251 tx. included_in_ib = Some ( time) ;
251252 }
252253 }
253- * seen_ibs. entry ( header . id . producer ) . or_default ( ) += 1. ;
254+ * seen_ibs. entry ( id. producer . id ) . or_default ( ) += 1. ;
254255 info ! (
255256 "Pool {} generated an IB with {} transaction(s) in slot {} ({})." ,
256- header . id. producer,
257+ id. producer,
257258 transactions. len( ) ,
258- header . id. slot,
259+ id. slot,
259260 pretty_bytes( ib_bytes, pbo. clone( ) ) ,
260261 )
261262 }
@@ -264,15 +265,15 @@ impl EventMonitor {
264265 }
265266 Event :: InputBlockReceived { recipient, .. } => {
266267 ib_messages. received += 1 ;
267- * seen_ibs. entry ( recipient) . or_default ( ) += 1. ;
268+ * seen_ibs. entry ( recipient. id ) . or_default ( ) += 1. ;
268269 }
269270 Event :: EndorserBlockLotteryWon { .. } => { }
270271 Event :: EndorserBlockGenerated { id, input_blocks } => {
271272 generated_ebs += 1 ;
272- eb_ibs. insert ( id, input_blocks. clone ( ) ) ;
273+ eb_ibs. insert ( id. clone ( ) , input_blocks. clone ( ) ) ;
273274 for ib_id in & input_blocks {
274- * ibs_in_eb. entry ( id) . or_default ( ) += 1.0 ;
275- * ebs_containing_ib. entry ( * ib_id) . or_default ( ) += 1.0 ;
275+ * ibs_in_eb. entry ( id. clone ( ) ) . or_default ( ) += 1.0 ;
276+ * ebs_containing_ib. entry ( ib_id. clone ( ) ) . or_default ( ) += 1.0 ;
276277 pending_ibs. remove ( ib_id) ;
277278 for tx_id in ib_txs. get ( ib_id) . unwrap ( ) {
278279 let tx = txs. get_mut ( tx_id) . unwrap ( ) ;
@@ -298,9 +299,9 @@ impl EventMonitor {
298299 Event :: VotesGenerated { id, votes } => {
299300 for ( eb, count) in votes. 0 {
300301 total_votes += count as u64 ;
301- * votes_per_bundle. entry ( id) . or_default ( ) += count as f64 ;
302+ * votes_per_bundle. entry ( id. clone ( ) ) . or_default ( ) += count as f64 ;
302303 * eb_votes. entry ( eb) . or_default ( ) += count as f64 ;
303- * votes_per_pool. entry ( id. producer ) . or_default ( ) += count as f64 ;
304+ * votes_per_pool. entry ( id. producer . id ) . or_default ( ) += count as f64 ;
304305 }
305306 }
306307 Event :: NoVote { .. } => { }
0 commit comments