Skip to content

Commit

Permalink
refactor: add close body after use and fix lint (#22248)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoank101 authored Oct 14, 2024
1 parent 8c39f41 commit 4274dcf
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 20 deletions.
1 change: 1 addition & 0 deletions collections/quad.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ func (t quadKeyCodec[K1, K2, K3, K4]) Encode(buffer []byte, key Quad[K1, K2, K3,
}
return writtenTotal, nil
}

func (t quadKeyCodec[K1, K2, K3, K4]) Decode(buffer []byte) (int, Quad[K1, K2, K3, K4], error) {
readTotal := 0
read, key1, err := t.keyCodec1.DecodeNonTerminal(buffer)
Expand Down
2 changes: 1 addition & 1 deletion server/v2/cometbft/abci.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func NewConsensus[T transaction.Tx](
indexedEvents: indexedEvents,
initialHeight: 0,
queryHandlersMap: queryHandlersMap,
getProtoRegistry: sync.OnceValues(func() (*protoregistry.Files, error) { return gogoproto.MergedRegistry() }),
getProtoRegistry: sync.OnceValues(gogoproto.MergedRegistry),
}
}

Expand Down
18 changes: 0 additions & 18 deletions tests/integration/tx/aminojson/aminojson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package aminojson

import (
"bytes"
"encoding/json"
"fmt"
stdmath "math"
"testing"
Expand Down Expand Up @@ -454,20 +453,3 @@ func postFixPulsarMessage(msg proto.Message) {
}
}
}

// sortJson sorts the JSON bytes by way of the side effect of unmarshalling and remarshalling the JSON
// using encoding/json. This hacky way of sorting JSON fields was used by the legacy amino JSON encoding in
// x/auth/migrations/legacytx.StdSignBytes. It is used here ensure the x/tx JSON encoding is equivalent to
// the legacy amino JSON encoding.
func sortJson(bz []byte) ([]byte, error) {
var c any
err := json.Unmarshal(bz, &c)
if err != nil {
return nil, err
}
js, err := json.Marshal(c)
if err != nil {
return nil, err
}
return js, nil
}
5 changes: 4 additions & 1 deletion tools/hubl/internal/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,15 @@ func GetChainRegistryEntry(chain string) (*ChainRegistryEntry, error) {
if err != nil {
return nil, err
}

bz, err := io.ReadAll(res.Body)
if err != nil {
return nil, err
}

if err = res.Body.Close(); err != nil {
return nil, err
}

data := &ChainRegistryEntry{}
if err = json.Unmarshal(bz, data); err != nil {
return nil, err
Expand Down

0 comments on commit 4274dcf

Please sign in to comment.