Skip to content

Commit

Permalink
refactor: calculate namespace before loop (#2113)
Browse files Browse the repository at this point in the history
Closes #2110
  • Loading branch information
rootulp authored Jul 17, 2023
1 parent 83aff91 commit 7faf094
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions x/blob/types/payforblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,10 @@ func CreateCommitment(blob *Blob) ([]byte, error) {
ShareVersion: uint8(blob.ShareVersion),
NamespaceVersion: uint8(blob.NamespaceVersion),
}
namespace, err := appns.New(uint8(blob.NamespaceVersion), blob.NamespaceId)
if err != nil {
return nil, err
}

shares, err := appshares.SplitBlobs(coreblob)
if err != nil {
Expand Down Expand Up @@ -207,10 +211,6 @@ func CreateCommitment(blob *Blob) ([]byte, error) {
// create the nmt todo(evan) use nmt wrapper
tree := nmt.New(sha256.New(), nmt.NamespaceIDSize(appns.NamespaceSize), nmt.IgnoreMaxNamespace(true))
for _, leaf := range set {
namespace, err := appns.New(uint8(blob.NamespaceVersion), blob.NamespaceId)
if err != nil {
return nil, err
}
// the namespace must be added again here even though it is already
// included in the leaf to ensure that the hash will match that of
// the nmt wrapper (pkg/wrapper). Each namespace is added to keep
Expand Down

0 comments on commit 7faf094

Please sign in to comment.