Skip to content

Commit d4bf217

Browse files
committed
try to make lint happy
1 parent 6046269 commit d4bf217

File tree

4 files changed

+38
-35
lines changed

4 files changed

+38
-35
lines changed

catchup/fetcher_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ func buildTestLedger(t *testing.T, blk bookkeeping.Block) (ledger *data.Ledger,
168168
}
169169

170170
b.StateProofTracking = map[protocol.StateProofType]bookkeeping.StateProofTrackingData{
171-
protocol.StateProofBasic: bookkeeping.StateProofTrackingData{
171+
protocol.StateProofBasic: {
172172
StateProofVotersCommitment: stateProofData.Tree.Root(),
173173
StateProofOnlineTotalWeight: stateProofData.TotalWeight,
174174
StateProofNextRound: basics.Round(proto.StateProofInterval),

catchup/stateproof.go

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -91,33 +91,33 @@ func (s *Service) initStateProofs() error {
9191
rows, err := tx.Query("SELECT proto, msg FROM proofs ORDER BY lastrnd")
9292
if err != nil {
9393
return err
94-
} else {
95-
defer rows.Close()
96-
for rows.Next() {
97-
var proto protocol.ConsensusVersion
98-
var msgbuf []byte
99-
err := rows.Scan(&proto, &msgbuf)
100-
if err != nil {
101-
s.log.Warnf("initStateProofs: cannot scan proof from db: %v", err)
102-
continue
103-
}
104-
105-
var msg stateproofmsg.Message
106-
err = protocol.Decode(msgbuf, &msg)
107-
if err != nil {
108-
s.log.Warnf("initStateProofs: cannot decode proof from db: %v", err)
109-
continue
110-
}
111-
112-
stateproofs[msg.LastAttestedRound] = stateProofInfo{
113-
message: msg,
114-
proto: proto,
115-
}
116-
stateproofmax = msg.LastAttestedRound
117-
if stateproofmin == 0 {
118-
stateproofmin = msg.LastAttestedRound
119-
stateproofproto = proto
120-
}
94+
}
95+
96+
defer rows.Close()
97+
for rows.Next() {
98+
var proto protocol.ConsensusVersion
99+
var msgbuf []byte
100+
err := rows.Scan(&proto, &msgbuf)
101+
if err != nil {
102+
s.log.Warnf("initStateProofs: cannot scan proof from db: %v", err)
103+
continue
104+
}
105+
106+
var msg stateproofmsg.Message
107+
err = protocol.Decode(msgbuf, &msg)
108+
if err != nil {
109+
s.log.Warnf("initStateProofs: cannot decode proof from db: %v", err)
110+
continue
111+
}
112+
113+
stateproofs[msg.LastAttestedRound] = stateProofInfo{
114+
message: msg,
115+
proto: proto,
116+
}
117+
stateproofmax = msg.LastAttestedRound
118+
if stateproofmin == 0 {
119+
stateproofmin = msg.LastAttestedRound
120+
stateproofproto = proto
121121
}
122122
}
123123
return nil
@@ -279,10 +279,13 @@ func (s *Service) nextStateProofVerifier() *StateProofVerificationContext {
279279
}
280280
}
281281

282+
// SetRenaissance sets the "renaissance" parameters for validating state proofs.
282283
func (s *Service) SetRenaissance(r StateProofVerificationContext) {
283284
s.renaissance = &r
284285
}
285286

287+
// SetRenaissanceFromConfig sets the "renaissance" parameters for validating state
288+
// proofs based on the settings in the specified cfg.
286289
func (s *Service) SetRenaissanceFromConfig(cfg config.Local) {
287290
if cfg.RenaissanceCatchupRound == 0 {
288291
return

catchup/universalFetcher.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ func (uf *universalBlockFetcher) fetchBlock(ctx context.Context, round basics.Ro
8787
} else {
8888
return nil, nil, nil, time.Duration(0), fmt.Errorf("fetchBlock: UniversalFetcher only supports HTTPPeer and UnicastPeer")
8989
}
90-
downloadDuration = time.Now().Sub(blockDownloadStartTime)
90+
downloadDuration = time.Since(blockDownloadStartTime)
9191
block, cert, proof, err := processBlockBytes(fetchedBuf, round, address)
9292
if err != nil {
9393
return nil, nil, nil, time.Duration(0), err
@@ -141,7 +141,7 @@ func (uf *universalBlockFetcher) fetchStateProof(ctx context.Context, proofType
141141
} else {
142142
return pf, msg, 0, fmt.Errorf("fetchStateProof: UniversalFetcher only supports HTTPPeer")
143143
}
144-
downloadDuration = time.Now().Sub(downloadStartTime)
144+
downloadDuration = time.Since(downloadStartTime)
145145
pf, msg, err = processStateProofBytes(fetchedBuf, round, address)
146146
if err != nil {
147147
return pf, msg, 0, err
@@ -329,8 +329,8 @@ func (hf *HTTPFetcher) getBlockBytes(ctx context.Context, r basics.Round, proofO
329329
// Remove this 'old' string after next release.
330330
const blockResponseContentTypeOld = "application/algorand-block-v1"
331331
expectedContentTypes := map[string]struct{}{
332-
rpcs.BlockResponseContentType: struct{}{},
333-
blockResponseContentTypeOld: struct{}{},
332+
rpcs.BlockResponseContentType: {},
333+
blockResponseContentTypeOld: {},
334334
}
335335

336336
return hf.getBytes(ctx, blockURL, expectedContentTypes)
@@ -347,7 +347,7 @@ func (hf *HTTPFetcher) getStateProofBytes(ctx context.Context, proofType protoco
347347
proofURL := parsedURL.String()
348348

349349
expectedContentTypes := map[string]struct{}{
350-
rpcs.StateProofResponseContentType: struct{}{},
350+
rpcs.StateProofResponseContentType: {},
351351
}
352352

353353
return hf.getBytes(ctx, proofURL, expectedContentTypes)

rpcs/blockService.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ func (bs *BlockService) ServeStateProofPath(response http.ResponseWriter, reques
224224
return
225225
}
226226
if typeStr != "0" { // StateProofBasic
227-
bs.log.Debugf("http stateproof bad type", typeStr)
227+
bs.log.Debugf("http stateproof bad type %s", typeStr)
228228
response.WriteHeader(http.StatusBadRequest)
229229
return
230230
}
@@ -383,7 +383,7 @@ func (bs *BlockService) ServeBlockPath(response http.ResponseWriter, request *ht
383383
stateProof, hasStateProof := request.Form["stateproof"]
384384
if hasStateProof {
385385
if len(stateProof) != 1 || stateProof[0] != "0" {
386-
bs.log.Debug("http block stateproof version %v unsupported", stateProof)
386+
bs.log.Debugf("http block stateproof version %v unsupported", stateProof)
387387
response.WriteHeader(http.StatusBadRequest)
388388
return
389389
}

0 commit comments

Comments
 (0)