@@ -143,6 +143,14 @@ func monitor(ctx context.Context) error {
143143 zkEVMBatchesSupported = true
144144 }
145145
146+ // check if net peerCount is supported
147+ peerCountSupported := false
148+ if _ , err = ec .PeerCount (ctx ); err != nil {
149+ log .Debug ().Err (err ).Msg ("Unable to fake peer count" )
150+ } else {
151+ peerCountSupported = true
152+ }
153+
146154 ms := new (monitorStatus )
147155 ms .BlocksLock .Lock ()
148156 ms .BlockCache , err = lru .New (blockCacheLimit )
@@ -171,7 +179,7 @@ func monitor(ctx context.Context) error {
171179 return
172180 default :
173181 for {
174- err = fetchCurrentBlockData (ctx , ec , ms , isUiRendered , txPoolStatusSupported , zkEVMBatchesSupported )
182+ err = fetchCurrentBlockData (ctx , ec , ms , isUiRendered , txPoolStatusSupported , zkEVMBatchesSupported , peerCountSupported )
175183 if err != nil {
176184 log .Error ().Msg (fmt .Sprintf ("Error: unable to fetch current block data: %v" , err ))
177185 // Send the error to the errChan channel to return.
@@ -202,7 +210,7 @@ func monitor(ctx context.Context) error {
202210 return err
203211}
204212
205- func getChainState (ctx context.Context , ec * ethclient.Client , txPoolStatusSupported , zkEVMBatchesSupported bool ) (* chainState , error ) {
213+ func getChainState (ctx context.Context , ec * ethclient.Client , txPoolStatusSupported , zkEVMBatchesSupported , peerCountSupported bool ) (* chainState , error ) {
206214 var err error
207215 cs := new (chainState )
208216 cs .HeadBlock , err = ec .BlockNumber (ctx )
@@ -215,10 +223,12 @@ func getChainState(ctx context.Context, ec *ethclient.Client, txPoolStatusSuppor
215223 return nil , fmt .Errorf ("couldn't fetch chain id: %s" , err .Error ())
216224 }
217225
218- cs .PeerCount , err = ec .PeerCount (ctx )
219- if err != nil {
220- log .Debug ().Err (err ).Msg ("Using fake peer count" )
221- cs .PeerCount = 0
226+ if peerCountSupported {
227+ cs .PeerCount , err = ec .PeerCount (ctx )
228+ if err != nil {
229+ log .Debug ().Err (err ).Msg ("Using fake peer count" )
230+ cs .PeerCount = 0
231+ }
222232 }
223233
224234 cs .GasPrice , err = ec .SuggestGasPrice (ctx )
@@ -269,9 +279,9 @@ func (h historicalRange) getValues(limit int) []float64 {
269279 return values
270280}
271281
272- func fetchCurrentBlockData (ctx context.Context , ec * ethclient.Client , ms * monitorStatus , isUiRendered , txPoolStatusSupported , zkEVMBatchesSupported bool ) (err error ) {
282+ func fetchCurrentBlockData (ctx context.Context , ec * ethclient.Client , ms * monitorStatus , isUiRendered , txPoolStatusSupported , zkEVMBatchesSupported , peerCountSupported bool ) (err error ) {
273283 var cs * chainState
274- cs , err = getChainState (ctx , ec , txPoolStatusSupported , zkEVMBatchesSupported )
284+ cs , err = getChainState (ctx , ec , txPoolStatusSupported , zkEVMBatchesSupported , peerCountSupported )
275285 if err != nil {
276286 log .Error ().Err (err ).Msg ("Encountered issue fetching network information" )
277287 time .Sleep (interval )
@@ -499,6 +509,14 @@ func renderMonitorUI(ctx context.Context, ec *ethclient.Client, ms *monitorStatu
499509 termui .Render (selectGrid )
500510 return
501511 } else if currentMode == monitorModeBlock {
512+ if ms .SelectedBlock == nil {
513+ currentMode = monitorModeExplorer
514+ blockTable .SelectedRow = 0
515+ termui .Clear ()
516+ termui .Render (grid )
517+ return
518+ }
519+
502520 // render a block
503521 skeleton .BlockInfo .Rows = ui .GetSimpleBlockFields (ms .SelectedBlock )
504522 rows , title := ui .GetTransactionsList (ms .SelectedBlock , ms .ChainID )
@@ -933,7 +951,7 @@ func renderMonitorUI(ctx context.Context, ec *ethclient.Client, ms *monitorStatu
933951 log .Debug ().
934952 Int ("TopDisplayedBlock" , int (ms .TopDisplayedBlock .Int64 ())).
935953 Int ("toBlockNumber" , int (toBlockNumber .Int64 ())).
936- Msg ("PageDown " )
954+ Msg ("PageUp " )
937955
938956 forceRedraw = true
939957 redraw (ms , true )
0 commit comments