Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SPV-1220): rename variables to not shadow internal go funcs #298

Merged
merged 1 commit into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading