From f6aab0ede90cba7587ff68c3c901416e9cbe2ff7 Mon Sep 17 00:00:00 2001 From: aBear Date: Tue, 1 Oct 2024 10:45:39 +0200 Subject: [PATCH] renaming nits and comments fixes --- mod/primitives/pkg/constraints/basic.go | 4 ++-- mod/primitives/pkg/encoding/hex/bytes.go | 4 ++-- mod/primitives/pkg/encoding/hex/const.go | 18 +++++++++--------- mod/primitives/pkg/encoding/hex/string.go | 2 +- mod/primitives/pkg/encoding/hex/u64.go | 2 +- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/mod/primitives/pkg/constraints/basic.go b/mod/primitives/pkg/constraints/basic.go index b7c1903adc..3c2bccc657 100644 --- a/mod/primitives/pkg/constraints/basic.go +++ b/mod/primitives/pkg/constraints/basic.go @@ -36,7 +36,7 @@ type EngineType[SelfT any] interface { JSONMarshallable } -// EmptyWithForkVersion is a constraint that requires a type to have an Empty +// EmptyWithVersion is a constraint that requires a type to have an Empty // method. type EmptyWithVersion[SelfT any] interface { Empty(uint32) SelfT @@ -47,7 +47,7 @@ type Empty[SelfT any] interface { Empty() SelfT } -// IsNil is a constraint that requires a type to have an IsNil method. +// Nillable is a constraint that requires a type to have an IsNil method. type Nillable interface { IsNil() bool } diff --git a/mod/primitives/pkg/encoding/hex/bytes.go b/mod/primitives/pkg/encoding/hex/bytes.go index 355eb5a6e4..f404af01f8 100644 --- a/mod/primitives/pkg/encoding/hex/bytes.go +++ b/mod/primitives/pkg/encoding/hex/bytes.go @@ -82,7 +82,7 @@ func DecodeFixedText(input, out []byte) error { return nil } -// MustFromHex returns the bytes represented by the given hex string. +// MustToBytes returns the bytes represented by the given hex string. // It panics if the input is not a valid hex string. func MustToBytes(input string) []byte { bz, err := ToBytes(input) @@ -92,7 +92,7 @@ func MustToBytes(input string) []byte { return bz } -// FromHex returns the bytes represented by the given hex string. +// ToBytes returns the bytes represented by the given hex string. // An error is returned if the input is not a valid hex string. func ToBytes(input string) ([]byte, error) { s, err := NewStringStrict(input) diff --git a/mod/primitives/pkg/encoding/hex/const.go b/mod/primitives/pkg/encoding/hex/const.go index c4e65414a5..8a273f146a 100644 --- a/mod/primitives/pkg/encoding/hex/const.go +++ b/mod/primitives/pkg/encoding/hex/const.go @@ -21,15 +21,15 @@ package hex const ( - prefix = "0x" - prefixLen = len(prefix) - badNibble = ^uint64(0) - hexBase = 16 - initialCapacity = 10 - encDecRatio = 2 - bytesPer64Bits = 16 // 64/8 - bytesPer256Bits = 64 // 256/8 - nibbleShift = 4 + prefix = "0x" + prefixLen = len(prefix) + badNibble = ^uint64(0) + hexBase = 16 + initialCapacity = 10 + encDecRatio = 2 + nibblesPer64Bits = 16 // 64/4 + nibblesPer256Bits = 64 // 256/4 + nibbleShift = 4 // hexadecimal conversion constants. hexBaseOffset = '0' diff --git a/mod/primitives/pkg/encoding/hex/string.go b/mod/primitives/pkg/encoding/hex/string.go index 71dc29b480..52c70820ee 100644 --- a/mod/primitives/pkg/encoding/hex/string.go +++ b/mod/primitives/pkg/encoding/hex/string.go @@ -158,7 +158,7 @@ func (s String) ToBigInt() (*big.Int, error) { if err != nil { return nil, err } - if len(raw) > bytesPer256Bits { + if len(raw) > nibblesPer256Bits { return nil, ErrBig256Range } bigWordNibbles, err := getBigWordNibbles() diff --git a/mod/primitives/pkg/encoding/hex/u64.go b/mod/primitives/pkg/encoding/hex/u64.go index d3ac69f6a7..77ec28dc8a 100644 --- a/mod/primitives/pkg/encoding/hex/u64.go +++ b/mod/primitives/pkg/encoding/hex/u64.go @@ -54,7 +54,7 @@ func UnmarshalUint64Text(input []byte) (uint64, error) { if err != nil { return 0, err } - if len(raw) > bytesPer64Bits { + if len(raw) > nibblesPer64Bits { return 0, ErrUint64Range } var dec uint64