mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-06-20 13:44:31 +00:00
skip changes if no candidates found
This commit is contained in:
parent
ae9d4ec558
commit
cd59b922ed
1 changed files with 14 additions and 8 deletions
|
|
@ -368,14 +368,14 @@ func startNode(ctx *cli.Context, stack *node.Node) {
|
|||
opts := new(bind.CallOpts)
|
||||
candidates, err := validator.GetCandidates(opts)
|
||||
if err != nil {
|
||||
utils.Fatalf("Can't get list of candidates: %v", err)
|
||||
utils.Fatalf("Can't get list of masternode candidates: %v", err)
|
||||
}
|
||||
|
||||
var ms []clique.Masternode
|
||||
for _, candidate := range candidates {
|
||||
v, err := validator.GetCandidateCap(opts, candidate)
|
||||
if err != nil {
|
||||
log.Warn("Can't get cap of a candidate. Will ignore him", "address", candidate, "error", err)
|
||||
log.Warn("Can't get cap of a masternode candidate. Will ignore him", "address", candidate, "error", err)
|
||||
}
|
||||
ms = append(ms, clique.Masternode{Address: candidate, Stake: v.Int64()})
|
||||
}
|
||||
|
|
@ -383,14 +383,20 @@ func startNode(ctx *cli.Context, stack *node.Node) {
|
|||
sort.Slice(ms, func(i, j int) bool {
|
||||
return ms[i].Stake > ms[j].Stake
|
||||
})
|
||||
// update masternodes
|
||||
err = ethereum.UpdateMasternodes(ms)
|
||||
if err != nil {
|
||||
utils.Fatalf("Can't update masternodes: %v", err)
|
||||
log.Info("Ordered list of masternode candidates", "candidates", ms)
|
||||
if len(ms) == 0 {
|
||||
log.Info("No masternode candidates found. Keep the current masternodes set for the next epoch")
|
||||
} else {
|
||||
// update masternodes
|
||||
log.Info("Updating new set of masternodes")
|
||||
err = ethereum.UpdateMasternodes(ms)
|
||||
if err != nil {
|
||||
utils.Fatalf("Can't update masternodes: %v", err)
|
||||
}
|
||||
log.Info("Masternodes are ready for the next epoch")
|
||||
}
|
||||
log.Info("Masternodes are ready for the next epoch")
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue