pokt-network / pocket

Official implementation of the Pocket Network Protocol v1
https://pokt.network
MIT License
61 stars 33 forks source link

[Consensus] Add Nil Check Before Calling Method in Hotstuff Handler #929

Closed innocent-saeed36 closed 11 months ago

innocent-saeed36 commented 11 months ago

Problem

Currently, in the hotstuff_handler.go file, we're calling a method on a variable m without first checking if m is nil. Specifically, in the line with if m.shouldElectNextLeader() {, if m is nil, this will cause a runtime panic.

Solution

To prevent this, we can add a nil check before calling the method. So, instead of if m.shouldElectNextLeader() {, we can use if m != nil && m.shouldElectNextLeader() {. This will ensure that the method is only called if m is not nil, preventing a potential runtime panic.

What This Pull Request Changes

This pull request adds a nil check before a method call in hotstuff_handler.go to prevent a potential runtime panic.