Don't mine when node is not connected (#1338)

This commit is contained in:
Ori Newman 2021-01-03 14:57:09 +02:00 committed by GitHub
parent d6fe9a3017
commit 97fddeff4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -59,6 +59,12 @@ func (f *FlowContext) isSyncRateBelowMinimum() bool {
// ShouldMine returns whether it's ok to use block template from this node
// for mining purposes.
func (f *FlowContext) ShouldMine() (bool, error) {
peers := f.Peers()
if len(peers) == 0 {
log.Debugf("The node is not connected, so ShouldMine returns false")
return false, nil
}
if f.isSyncRateBelowMinimum() {
log.Debugf("The sync rate is below the minimum, so ShouldMine returns true")
return true, nil