Skip to content

Commit

Permalink
try to make lint happy
Browse files Browse the repository at this point in the history
  • Loading branch information
zeldovich committed Aug 31, 2023
1 parent 6046269 commit d4bf217
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 35 deletions.
2 changes: 1 addition & 1 deletion catchup/fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ func buildTestLedger(t *testing.T, blk bookkeeping.Block) (ledger *data.Ledger,
}

b.StateProofTracking = map[protocol.StateProofType]bookkeeping.StateProofTrackingData{
protocol.StateProofBasic: bookkeeping.StateProofTrackingData{
protocol.StateProofBasic: {
StateProofVotersCommitment: stateProofData.Tree.Root(),
StateProofOnlineTotalWeight: stateProofData.TotalWeight,
StateProofNextRound: basics.Round(proto.StateProofInterval),
Expand Down
57 changes: 30 additions & 27 deletions catchup/stateproof.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,33 +91,33 @@ func (s *Service) initStateProofs() error {
rows, err := tx.Query("SELECT proto, msg FROM proofs ORDER BY lastrnd")

Check failure on line 91 in catchup/stateproof.go

View workflow job for this annotation

GitHub Actions / reviewdog-errors

[Lint Errors] reported by reviewdog 🐶 shadow: declaration of "err" shadows declaration at line 80 (govet) Raw Output: catchup/stateproof.go:91:9: shadow: declaration of "err" shadows declaration at line 80 (govet) rows, err := tx.Query("SELECT proto, msg FROM proofs ORDER BY lastrnd") ^
if err != nil {
return err
} else {
defer rows.Close()
for rows.Next() {
var proto protocol.ConsensusVersion
var msgbuf []byte
err := rows.Scan(&proto, &msgbuf)
if err != nil {
s.log.Warnf("initStateProofs: cannot scan proof from db: %v", err)
continue
}

var msg stateproofmsg.Message
err = protocol.Decode(msgbuf, &msg)
if err != nil {
s.log.Warnf("initStateProofs: cannot decode proof from db: %v", err)
continue
}

stateproofs[msg.LastAttestedRound] = stateProofInfo{
message: msg,
proto: proto,
}
stateproofmax = msg.LastAttestedRound
if stateproofmin == 0 {
stateproofmin = msg.LastAttestedRound
stateproofproto = proto
}
}

defer rows.Close()
for rows.Next() {
var proto protocol.ConsensusVersion
var msgbuf []byte
err := rows.Scan(&proto, &msgbuf)
if err != nil {
s.log.Warnf("initStateProofs: cannot scan proof from db: %v", err)
continue
}

var msg stateproofmsg.Message
err = protocol.Decode(msgbuf, &msg)
if err != nil {
s.log.Warnf("initStateProofs: cannot decode proof from db: %v", err)
continue
}

stateproofs[msg.LastAttestedRound] = stateProofInfo{
message: msg,
proto: proto,
}
stateproofmax = msg.LastAttestedRound
if stateproofmin == 0 {
stateproofmin = msg.LastAttestedRound
stateproofproto = proto
}
}
return nil
Expand Down Expand Up @@ -279,10 +279,13 @@ func (s *Service) nextStateProofVerifier() *StateProofVerificationContext {
}
}

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

// SetRenaissanceFromConfig sets the "renaissance" parameters for validating state
// proofs based on the settings in the specified cfg.
func (s *Service) SetRenaissanceFromConfig(cfg config.Local) {
if cfg.RenaissanceCatchupRound == 0 {
return
Expand Down
10 changes: 5 additions & 5 deletions catchup/universalFetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (uf *universalBlockFetcher) fetchBlock(ctx context.Context, round basics.Ro
} else {
return nil, nil, nil, time.Duration(0), fmt.Errorf("fetchBlock: UniversalFetcher only supports HTTPPeer and UnicastPeer")
}
downloadDuration = time.Now().Sub(blockDownloadStartTime)
downloadDuration = time.Since(blockDownloadStartTime)
block, cert, proof, err := processBlockBytes(fetchedBuf, round, address)
if err != nil {
return nil, nil, nil, time.Duration(0), err
Expand Down Expand Up @@ -141,7 +141,7 @@ func (uf *universalBlockFetcher) fetchStateProof(ctx context.Context, proofType
} else {
return pf, msg, 0, fmt.Errorf("fetchStateProof: UniversalFetcher only supports HTTPPeer")
}
downloadDuration = time.Now().Sub(downloadStartTime)
downloadDuration = time.Since(downloadStartTime)
pf, msg, err = processStateProofBytes(fetchedBuf, round, address)
if err != nil {
return pf, msg, 0, err
Expand Down Expand Up @@ -329,8 +329,8 @@ func (hf *HTTPFetcher) getBlockBytes(ctx context.Context, r basics.Round, proofO
// Remove this 'old' string after next release.
const blockResponseContentTypeOld = "application/algorand-block-v1"
expectedContentTypes := map[string]struct{}{
rpcs.BlockResponseContentType: struct{}{},
blockResponseContentTypeOld: struct{}{},
rpcs.BlockResponseContentType: {},
blockResponseContentTypeOld: {},
}

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

expectedContentTypes := map[string]struct{}{
rpcs.StateProofResponseContentType: struct{}{},
rpcs.StateProofResponseContentType: {},
}

return hf.getBytes(ctx, proofURL, expectedContentTypes)
Expand Down
4 changes: 2 additions & 2 deletions rpcs/blockService.go
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ func (bs *BlockService) ServeStateProofPath(response http.ResponseWriter, reques
return
}
if typeStr != "0" { // StateProofBasic
bs.log.Debugf("http stateproof bad type", typeStr)
bs.log.Debugf("http stateproof bad type %s", typeStr)
response.WriteHeader(http.StatusBadRequest)
return
}
Expand Down Expand Up @@ -383,7 +383,7 @@ func (bs *BlockService) ServeBlockPath(response http.ResponseWriter, request *ht
stateProof, hasStateProof := request.Form["stateproof"]
if hasStateProof {
if len(stateProof) != 1 || stateProof[0] != "0" {
bs.log.Debug("http block stateproof version %v unsupported", stateProof)
bs.log.Debugf("http block stateproof version %v unsupported", stateProof)
response.WriteHeader(http.StatusBadRequest)
return
}
Expand Down

0 comments on commit d4bf217

Please sign in to comment.