Skip to content

Commit 4b2ae2a

Browse files
committed
clique/api: fix some minor review concerns
1 parent 177dc82 commit 4b2ae2a

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

consensus/clique/api.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ func (api *API) Discard(address common.Address) {
120120
delete(api.clique.proposals, address)
121121
}
122122

123-
type CliqueStatus struct {
123+
type Status struct {
124124
InturnPercent float64 `json:"inturnPercent"`
125125
SigningStatus map[common.Address]int `json:"sealerActivity""`
126126
NumBlocks uint64 `json:"numBlocks"`
@@ -130,7 +130,7 @@ type CliqueStatus struct {
130130
// - the number of active signers,
131131
// - the number of signers,
132132
// - the percentage of in-turn blocks
133-
func (api *API) Status() (*CliqueStatus, error) {
133+
func (api *API) Status() (*Status, error) {
134134
var (
135135
numBlocks = uint64(64)
136136
header = api.chain.CurrentHeader()
@@ -156,21 +156,20 @@ func (api *API) Status() (*CliqueStatus, error) {
156156
}
157157
for n := start; n < end; n++ {
158158
h := api.chain.GetHeaderByNumber(n)
159-
if h != nil {
160-
if h.Difficulty.Cmp(diffInTurn) == 0 {
161-
optimals += 1
162-
}
163-
diff += h.Difficulty.Uint64()
164-
if sealer, err := api.clique.Author(h); err != nil {
165-
return nil, err
166-
} else {
167-
signStatus[sealer] += 1
168-
}
169-
} else {
159+
if h == nil {
170160
return nil, fmt.Errorf("missing block %d", n)
171161
}
162+
if h.Difficulty.Cmp(diffInTurn) == 0 {
163+
optimals++
164+
}
165+
diff += h.Difficulty.Uint64()
166+
sealer, err := api.clique.Author(h)
167+
if err != nil {
168+
return nil, err
169+
}
170+
signStatus[sealer]++
172171
}
173-
return &CliqueStatus{
172+
return &Status{
174173
InturnPercent: float64((100 * optimals)) / float64(numBlocks),
175174
SigningStatus: signStatus,
176175
NumBlocks: numBlocks,

0 commit comments

Comments
 (0)