Skip to content

Commit

Permalink
feat(SPV-1220): rename variables to not shadow internal go funcs (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
wregulski authored Nov 25, 2024
1 parent c99832e commit 6ab8526
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
18 changes: 9 additions & 9 deletions internal/wire/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,10 @@ func ReadVarInt(r io.Reader, _ uint32) (uint64, error) {

// The encoding is not canonical if the value could have been
// encoded using fewer bytes.
min := uint64(0x100000000)
if rv < min {
minValue := uint64(0x100000000)
if rv < minValue {
return 0, messageError("ReadVarInt", fmt.Sprintf(
errNonCanonicalVarInt, rv, discriminant, min))
errNonCanonicalVarInt, rv, discriminant, minValue))
}

case 0xfe:
Expand All @@ -505,10 +505,10 @@ func ReadVarInt(r io.Reader, _ uint32) (uint64, error) {

// The encoding is not canonical if the value could have been
// encoded using fewer bytes.
min := uint64(0x10000)
if rv < min {
minValue := uint64(0x10000)
if rv < minValue {
return 0, messageError("ReadVarInt", fmt.Sprintf(
errNonCanonicalVarInt, rv, discriminant, min))
errNonCanonicalVarInt, rv, discriminant, minValue))
}

case 0xfd:
Expand All @@ -520,10 +520,10 @@ func ReadVarInt(r io.Reader, _ uint32) (uint64, error) {

// The encoding is not canonical if the value could have been
// encoded using fewer bytes.
min := uint64(0xfd)
if rv < min {
minValue := uint64(0xfd)
if rv < minValue {
return 0, messageError("ReadVarInt", fmt.Sprintf(
errNonCanonicalVarInt, rv, discriminant, min))
errNonCanonicalVarInt, rv, discriminant, minValue))
}

default:
Expand Down
12 changes: 6 additions & 6 deletions internal/wire/fixedIO_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ func (w *fixedWriter) Bytes() []byte {
}

// newFixedWriter returns a new io.Writer that will error once more bytes than
// the specified max have been written.
func newFixedWriter(max int) io.Writer {
b := make([]byte, max)
// the specified maxBytes have been written.
func newFixedWriter(maxBytes int) io.Writer {
b := make([]byte, maxBytes)
fw := fixedWriter{b, 0}
return &fw
}
Expand All @@ -64,9 +64,9 @@ func (fr *fixedReader) Read(p []byte) (n int, err error) {
}

// newFixedReader returns a new io.Reader that will error once more bytes than
// the specified max have been read.
func newFixedReader(max int, buf []byte) io.Reader {
b := make([]byte, max)
// the specified maxBytes have been read.
func newFixedReader(maxBytes int, buf []byte) io.Reader {
b := make([]byte, maxBytes)
if buf != nil {
copy(b[:], buf)
}
Expand Down

0 comments on commit 6ab8526

Please sign in to comment.