mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-17 10:20:44 +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)
|
opts := new(bind.CallOpts)
|
||||||
candidates, err := validator.GetCandidates(opts)
|
candidates, err := validator.GetCandidates(opts)
|
||||||
if err != nil {
|
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
|
var ms []clique.Masternode
|
||||||
for _, candidate := range candidates {
|
for _, candidate := range candidates {
|
||||||
v, err := validator.GetCandidateCap(opts, candidate)
|
v, err := validator.GetCandidateCap(opts, candidate)
|
||||||
if err != nil {
|
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()})
|
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 {
|
sort.Slice(ms, func(i, j int) bool {
|
||||||
return ms[i].Stake > ms[j].Stake
|
return ms[i].Stake > ms[j].Stake
|
||||||
})
|
})
|
||||||
// update masternodes
|
log.Info("Ordered list of masternode candidates", "candidates", ms)
|
||||||
err = ethereum.UpdateMasternodes(ms)
|
if len(ms) == 0 {
|
||||||
if err != nil {
|
log.Info("No masternode candidates found. Keep the current masternodes set for the next epoch")
|
||||||
utils.Fatalf("Can't update masternodes: %v", err)
|
} 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