consensus: change os.Exit to return error (#1653)

This commit is contained in:
Wanwiset Peerapatanapokin 2025-11-10 21:55:45 +04:00 committed by GitHub
parent 44b7ea8081
commit 845137849d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -22,7 +22,6 @@ import (
"fmt" "fmt"
"io" "io"
"math/big" "math/big"
"os"
"sync" "sync"
"sync/atomic" "sync/atomic"
"time" "time"
@ -2757,12 +2756,12 @@ func (bc *BlockChain) UpdateM1() error {
// get masternodes information from smart contract // get masternodes information from smart contract
client, err := bc.GetClient() client, err := bc.GetClient()
if err != nil { if err != nil {
return err return fmt.Errorf("failed to get client: %w", err)
} }
addr := common.MasternodeVotingSMCBinary addr := common.MasternodeVotingSMCBinary
validator, err := contractValidator.NewXDCValidator(addr, client) validator, err := contractValidator.NewXDCValidator(addr, client)
if err != nil { if err != nil {
return err return fmt.Errorf("failed to create validator contract: %w", err)
} }
opts := new(bind.CallOpts) opts := new(bind.CallOpts)
@ -2794,7 +2793,7 @@ func (bc *BlockChain) UpdateM1() error {
} }
if len(ms) == 0 { if len(ms) == 0 {
log.Error("No masternode found. Stopping node") log.Error("No masternode found. Stopping node")
os.Exit(1) return errors.New("no masternode found")
} else { } else {
sort.Slice(ms, func(i, j int) bool { sort.Slice(ms, func(i, j int) bool {
return ms[i].Stake.Cmp(ms[j].Stake) >= 0 return ms[i].Stake.Cmp(ms[j].Stake) >= 0