From ad044a70e7fc583ea26e665b88bdaf13740b8405 Mon Sep 17 00:00:00 2001 From: Hoa Nguyen Date: Mon, 22 Jan 2024 23:57:33 +0700 Subject: [PATCH] chore: enhance clarity in comment for function name (#23) --- blob/blob.go | 3 ++- go.work.sum | 2 +- merkle/proof.go | 2 +- merkle/proof_key_path.go | 2 +- merkle/tree.go | 2 +- namespace/consts.go | 4 ++-- shares/consts.go | 2 +- shares/padding.go | 2 +- shares/powers_of_two.go | 2 +- shares/share_builder.go | 2 +- shares/shares.go | 2 +- 11 files changed, 13 insertions(+), 12 deletions(-) diff --git a/blob/blob.go b/blob/blob.go index 3ef52ed..291b981 100644 --- a/blob/blob.go +++ b/blob/blob.go @@ -22,7 +22,7 @@ const ProtoBlobTxTypeID = "BLOB" // decoding binaries that are not actually IndexWrappers. const ProtoIndexWrapperTypeID = "INDX" -// NewBlob creates a new coretypes.Blob from the provided data after performing +// New creates a new coretypes.Blob from the provided data after performing // basic stateless checks over it. func New(ns namespace.Namespace, blob []byte, shareVersion uint8) *Blob { return &Blob{ @@ -104,6 +104,7 @@ func Sort(blobs []*Blob) { }) } +// UnmarshalIndexWrapper attempts to unmarshal the provided transaction into an // IndexWrapper transaction. It returns true if the provided transaction is an // IndexWrapper transaction. An IndexWrapper transaction is a transaction that contains // a MsgPayForBlob that has been wrapped with a share index. diff --git a/go.work.sum b/go.work.sum index c5b581a..162d177 100644 --- a/go.work.sum +++ b/go.work.sum @@ -1,3 +1,3 @@ github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= golang.org/x/mod v0.14.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c= -golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= +golang.org/x/tools v0.16.0/go.mod h1:kYVVN6I1mBNoB1OX+noeBjbRk4IUEPa7JJ+TJMEooJ0= \ No newline at end of file diff --git a/merkle/proof.go b/merkle/proof.go index 4c070f6..df02493 100644 --- a/merkle/proof.go +++ b/merkle/proof.go @@ -73,7 +73,7 @@ func (sp *Proof) Verify(rootHash []byte, leaf []byte) error { return nil } -// Compute the root hash given a leaf hash. Panics in case of errors. +// ComputeRootHash the root hash given a leaf hash. Panics in case of errors. func (sp *Proof) ComputeRootHash() []byte { computedHash, err := sp.computeRootHash() if err != nil { diff --git a/merkle/proof_key_path.go b/merkle/proof_key_path.go index ca8b5f0..775a1c8 100644 --- a/merkle/proof_key_path.go +++ b/merkle/proof_key_path.go @@ -82,7 +82,7 @@ func (pth KeyPath) String() string { return res } -// Decode a path to a list of keys. Path must begin with `/`. +// KeyPathToKeys Decode a path to a list of keys. Path must begin with `/`. // Each key must use a known encoding. func KeyPathToKeys(path string) (keys [][]byte, err error) { if path == "" || path[0] != '/' { diff --git a/merkle/tree.go b/merkle/tree.go index 089c2f8..1b533dd 100644 --- a/merkle/tree.go +++ b/merkle/tree.go @@ -20,7 +20,7 @@ func HashFromByteSlices(items [][]byte) []byte { } } -// HashFromByteSliceIterative is an iterative alternative to +// HashFromByteSlicesIterative is an iterative alternative to // HashFromByteSlice motivated by potential performance improvements. // (#2611) had suggested that an iterative version of // HashFromByteSlice would be faster, presumably because diff --git a/namespace/consts.go b/namespace/consts.go index 6da6e91..bef6573 100644 --- a/namespace/consts.go +++ b/namespace/consts.go @@ -6,7 +6,7 @@ import ( ) const ( - // NamespaveVersionSize is the size of a namespace version in bytes. + // NamespaceVersionSize is the size of a namespace version in bytes. NamespaceVersionSize = 1 // NamespaceIDSize is the size of a namespace ID in bytes. @@ -21,7 +21,7 @@ const ( // NamespaceVersionMax is the max namespace version. NamespaceVersionMax = math.MaxUint8 - // NamespaceZeroPrefixSize is the number of `0` bytes that are prefixed to + // NamespaceVersionZeroPrefixSize is the number of `0` bytes that are prefixed to // namespace IDs for version 0. NamespaceVersionZeroPrefixSize = 18 diff --git a/shares/consts.go b/shares/consts.go index 6ed2814..72ad9aa 100644 --- a/shares/consts.go +++ b/shares/consts.go @@ -46,7 +46,7 @@ const ( // MinSquareSize is the smallest original square width. MinSquareSize = 1 - // MinshareCount is the minimum number of shares allowed in the original + // MinShareCount is the minimum number of shares allowed in the original // data square. MinShareCount = MinSquareSize * MinSquareSize diff --git a/shares/padding.go b/shares/padding.go index 020dafc..e0d905c 100644 --- a/shares/padding.go +++ b/shares/padding.go @@ -59,7 +59,7 @@ func ReservedPaddingShare() Share { return share } -// ReservedPaddingShare returns n reserved padding shares. +// ReservedPaddingShares returns n reserved padding shares. func ReservedPaddingShares(n int) []Share { shares, err := NamespacePaddingShares(namespace.PrimaryReservedPaddingNamespace, ShareVersionZero, n) if err != nil { diff --git a/shares/powers_of_two.go b/shares/powers_of_two.go index d9c7bc1..03e966b 100644 --- a/shares/powers_of_two.go +++ b/shares/powers_of_two.go @@ -27,7 +27,7 @@ func RoundDownPowerOfTwo[I constraints.Integer](input I) (I, error) { return roundedUp / 2, nil } -// RoundUpPowerOfTwo returns the next power of two that is strictly greater than input. +// RoundUpPowerOfTwoStrict returns the next power of two that is strictly greater than input. func RoundUpPowerOfTwoStrict[I constraints.Integer](input I) I { result := RoundUpPowerOfTwo(input) diff --git a/shares/share_builder.go b/shares/share_builder.go index eaaa4e9..8c215d8 100644 --- a/shares/share_builder.go +++ b/shares/share_builder.go @@ -150,7 +150,7 @@ func (b *Builder) MaybeWriteReservedBytes() error { return nil } -// writeSequenceLen writes the sequence length to the first share. +// WriteSequenceLen writes the sequence length to the first share. func (b *Builder) WriteSequenceLen(sequenceLen uint32) error { if b == nil { return errors.New("the builder object is not initialized (is nil)") diff --git a/shares/shares.go b/shares/shares.go index 3e31fc2..08025e5 100644 --- a/shares/shares.go +++ b/shares/shares.go @@ -190,7 +190,7 @@ func (s *Share) rawDataStartIndex() int { return index } -// RawDataWithReserved returns the raw share data while taking reserved bytes into account. +// RawDataUsingReserved returns the raw share data while taking reserved bytes into account. func (s *Share) RawDataUsingReserved() (rawData []byte, err error) { rawDataStartIndexUsingReserved, err := s.rawDataStartIndexUsingReserved() if err != nil {