@@ -25,6 +25,11 @@ use crate::metrics;
2525use crate :: types:: ShardSyncStatus ;
2626use crate :: SyncStatus ;
2727
28+ pub struct ValidatorInfoHelper {
29+ pub is_validator : bool ,
30+ pub num_validators : usize ,
31+ }
32+
2833/// A helper that prints information about current chain and reports to telemetry.
2934pub struct InfoHelper {
3035 /// Nearcore agent (executable) version
@@ -39,8 +44,6 @@ pub struct InfoHelper {
3944 num_blocks_processed : u64 ,
4045 /// Total gas used during period.
4146 gas_used : u64 ,
42- /// Total gas limit during period.
43- gas_limit : u64 ,
4447 /// Sign telemetry with block producer key if available.
4548 validator_signer : Option < Arc < dyn ValidatorSigner > > ,
4649 /// Telemetry actor.
@@ -61,16 +64,14 @@ impl InfoHelper {
6164 started : Instant :: now ( ) ,
6265 num_blocks_processed : 0 ,
6366 gas_used : 0 ,
64- gas_limit : 0 ,
6567 telemetry_actor,
6668 validator_signer,
6769 }
6870 }
6971
70- pub fn block_processed ( & mut self , gas_used : Gas , gas_limit : Gas ) {
72+ pub fn block_processed ( & mut self , gas_used : Gas ) {
7173 self . num_blocks_processed += 1 ;
7274 self . gas_used += gas_used;
73- self . gas_limit += gas_limit;
7475 }
7576
7677 pub fn info (
@@ -80,9 +81,7 @@ impl InfoHelper {
8081 sync_status : & SyncStatus ,
8182 node_id : & PeerId ,
8283 network_info : & NetworkInfo ,
83- is_validator : bool ,
84- is_fisherman : bool ,
85- num_validators : usize ,
84+ validator_info : Option < ValidatorInfoHelper > ,
8685 ) {
8786 let ( cpu_usage, memory_usage) = if let Some ( pid) = self . pid {
8887 if self . sys . refresh_process ( pid) {
@@ -104,15 +103,25 @@ impl InfoHelper {
104103 * 1000.0 ;
105104 let avg_gas_used =
106105 ( ( self . gas_used as f64 ) / ( self . started . elapsed ( ) . as_millis ( ) as f64 ) * 1000.0 ) as u64 ;
106+ let validator_info_log = if let Some ( ref validator_info) = validator_info {
107+ White . bold ( ) . paint ( format ! (
108+ "{}/{}" ,
109+ if validator_info. is_validator { "V" } else { "-" } ,
110+ validator_info. num_validators
111+ ) )
112+ } else {
113+ White . bold ( ) . paint ( "" )
114+ } ;
107115 info ! ( target: "stats" , "{} {} {} {} {} {}" ,
108116 Yellow . bold( ) . paint( display_sync_status( & sync_status, & head, genesis_height) ) ,
109- White . bold ( ) . paint ( format! ( "{}/{}" , if is_validator { "V" } else if is_fisherman { "F" } else { "-" } , num_validators ) ) ,
117+ validator_info_log ,
110118 Cyan . bold( ) . paint( format!( "{:2}/{:?}/{:2} peers" , network_info. num_active_peers, network_info. highest_height_peers. len( ) , network_info. peer_max_count) ) ,
111119 Cyan . bold( ) . paint( format!( "⬇ {} ⬆ {}" , pretty_bytes_per_sec( network_info. received_bytes_per_sec) , pretty_bytes_per_sec( network_info. sent_bytes_per_sec) ) ) ,
112120 Green . bold( ) . paint( format!( "{:.2} bps {}" , avg_bls, gas_used_per_sec( avg_gas_used) ) ) ,
113121 Blue . bold( ) . paint( format!( "CPU: {:.0}%, Mem: {}" , cpu_usage, pretty_bytes( memory_usage * 1024 ) ) )
114122 ) ;
115123
124+ let is_validator = validator_info. map ( |v| v. is_validator ) . unwrap_or_default ( ) ;
116125 set_gauge ( & metrics:: IS_VALIDATOR , is_validator as i64 ) ;
117126 set_gauge ( & metrics:: RECEIVED_BYTES_PER_SECOND , network_info. received_bytes_per_sec as i64 ) ;
118127 set_gauge ( & metrics:: SENT_BYTES_PER_SECOND , network_info. sent_bytes_per_sec as i64 ) ;
@@ -123,7 +132,6 @@ impl InfoHelper {
123132 self . started = Instant :: now ( ) ;
124133 self . num_blocks_processed = 0 ;
125134 self . gas_used = 0 ;
126- self . gas_limit = 0 ;
127135
128136 let info = TelemetryInfo {
129137 agent : TelemetryAgentInfo {
0 commit comments