Skip to content

Commit 8451378

Browse files
authored
consensus: change os.Exit to return error (XinFinOrg#1653)
1 parent 44b7ea8 commit 8451378

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

core/blockchain.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"fmt"
2323
"io"
2424
"math/big"
25-
"os"
2625
"sync"
2726
"sync/atomic"
2827
"time"
@@ -2757,12 +2756,12 @@ func (bc *BlockChain) UpdateM1() error {
27572756
// get masternodes information from smart contract
27582757
client, err := bc.GetClient()
27592758
if err != nil {
2760-
return err
2759+
return fmt.Errorf("failed to get client: %w", err)
27612760
}
27622761
addr := common.MasternodeVotingSMCBinary
27632762
validator, err := contractValidator.NewXDCValidator(addr, client)
27642763
if err != nil {
2765-
return err
2764+
return fmt.Errorf("failed to create validator contract: %w", err)
27662765
}
27672766
opts := new(bind.CallOpts)
27682767

@@ -2794,7 +2793,7 @@ func (bc *BlockChain) UpdateM1() error {
27942793
}
27952794
if len(ms) == 0 {
27962795
log.Error("No masternode found. Stopping node")
2797-
os.Exit(1)
2796+
return errors.New("no masternode found")
27982797
} else {
27992798
sort.Slice(ms, func(i, j int) bool {
28002799
return ms[i].Stake.Cmp(ms[j].Stake) >= 0

0 commit comments

Comments
 (0)