diff --git a/api/gateway/share.go b/api/gateway/share.go index 372920a21d..c9dec071f3 100644 --- a/api/gateway/share.go +++ b/api/gateway/share.go @@ -137,5 +137,5 @@ func parseGetByNamespaceArgs(r *http.Request) (height uint64, namespace share.Na if err != nil { return 0, nil, err } - return height, namespace, namespace.ValidateDataNamespace() + return height, namespace, namespace.ValidateForData() } diff --git a/blob/blob.go b/blob/blob.go index 890601e1c8..e9ad2b6255 100644 --- a/blob/blob.go +++ b/blob/blob.go @@ -120,7 +120,7 @@ func NewBlob(shareVersion uint8, namespace share.Namespace, data []byte) (*Blob, if len(data) == 0 || len(data) > appconsts.DefaultMaxBytes { return nil, fmt.Errorf("blob data must be > 0 && <= %d, but it was %d bytes", appconsts.DefaultMaxBytes, len(data)) } - if err := namespace.ValidateBlobNamespace(); err != nil { + if err := namespace.ValidateForBlob(); err != nil { return nil, err } diff --git a/share/getters/ipld.go b/share/getters/ipld.go index 5633b03ad3..92d1c55678 100644 --- a/share/getters/ipld.go +++ b/share/getters/ipld.go @@ -98,7 +98,7 @@ func (ig *IPLDGetter) GetSharesByNamespace( utils.SetStatusAndEnd(span, err) }() - if err = namespace.ValidateDataNamespace(); err != nil { + if err = namespace.ValidateForData(); err != nil { return nil, err } diff --git a/share/getters/shrex.go b/share/getters/shrex.go index 479ff4be7f..6a2ac03dcd 100644 --- a/share/getters/shrex.go +++ b/share/getters/shrex.go @@ -190,7 +190,7 @@ func (sg *ShrexGetter) GetSharesByNamespace( root *share.Root, namespace share.Namespace, ) (share.NamespacedShares, error) { - if err := namespace.ValidateDataNamespace(); err != nil { + if err := namespace.ValidateForData(); err != nil { return nil, err } var ( diff --git a/share/getters/store.go b/share/getters/store.go index 47cf3d7cc3..0b88d89155 100644 --- a/share/getters/store.go +++ b/share/getters/store.go @@ -103,7 +103,7 @@ func (sg *StoreGetter) GetSharesByNamespace( utils.SetStatusAndEnd(span, err) }() - if err = namespace.ValidateDataNamespace(); err != nil { + if err = namespace.ValidateForData(); err != nil { return nil, err } diff --git a/share/namespace.go b/share/namespace.go index 111a2536b9..433529a57f 100644 --- a/share/namespace.go +++ b/share/namespace.go @@ -20,6 +20,7 @@ var ( ReservedPaddingNamespace = Namespace(appns.ReservedPaddingNamespace.Bytes()) TxNamespace = Namespace(appns.TxNamespace.Bytes()) PayForBlobNamespace = Namespace(appns.PayForBlobNamespace.Bytes()) + ISRNamespace = Namespace(appns.IntermediateStateRootsNamespace.Bytes()) ) // Namespace represents namespace of a Share. @@ -40,7 +41,7 @@ func NewBlobNamespaceV0(id []byte) (Namespace, error) { // version and zero padding are already set as zero, // so simply copying subNID to the end is enough to comply the V0 spec copy(n[len(n)-len(id):], id) - return n, n.ValidateBlobNamespace() + return n, n.ValidateForBlob() } // NamespaceFromBytes converts bytes into Namespace and validates it. @@ -104,8 +105,8 @@ func (n Namespace) Validate() error { return nil } -// ValidateDataNamespace checks if the Namespace contains real/useful data. -func (n Namespace) ValidateDataNamespace() error { +// ValidateForData checks if the Namespace is of real/useful data. +func (n Namespace) ValidateForData() error { if err := n.Validate(); err != nil { return err } @@ -115,9 +116,9 @@ func (n Namespace) ValidateDataNamespace() error { return nil } -// ValidateBlobNamespace checks if the Namespace is valid blob namespace. -func (n Namespace) ValidateBlobNamespace() error { - if err := n.ValidateDataNamespace(); err != nil { +// ValidateForBlob checks if the Namespace is valid blob namespace. +func (n Namespace) ValidateForBlob() error { + if err := n.ValidateForData(); err != nil { return err } if bytes.Compare(n, MaxReservedNamespace) < 1 { diff --git a/share/p2p/shrexnd/client.go b/share/p2p/shrexnd/client.go index c18b15476e..7f12c21cf2 100644 --- a/share/p2p/shrexnd/client.go +++ b/share/p2p/shrexnd/client.go @@ -53,7 +53,7 @@ func (c *Client) RequestND( namespace share.Namespace, peer peer.ID, ) (share.NamespacedShares, error) { - if err := namespace.ValidateDataNamespace(); err != nil { + if err := namespace.ValidateForData(); err != nil { return nil, err } diff --git a/share/p2p/shrexnd/server.go b/share/p2p/shrexnd/server.go index 112a8016b9..d61e6b2e68 100644 --- a/share/p2p/shrexnd/server.go +++ b/share/p2p/shrexnd/server.go @@ -147,7 +147,7 @@ func (srv *Server) handleNamespacedData(ctx context.Context, stream network.Stre // validateRequest checks correctness of the request func validateRequest(req pb.GetSharesByNamespaceRequest) error { - if err := share.Namespace(req.Namespace).ValidateDataNamespace(); err != nil { + if err := share.Namespace(req.Namespace).ValidateForData(); err != nil { return err } if len(req.RootHash) != sha256.Size { diff --git a/share/sharetest/testing.go b/share/sharetest/testing.go index 76a0287030..50eb0eb003 100644 --- a/share/sharetest/testing.go +++ b/share/sharetest/testing.go @@ -45,7 +45,7 @@ func RandV0Namespace() share.Namespace { rndMu.Unlock() for { namespace, _ := share.NewBlobNamespaceV0(rb) - if err := namespace.ValidateDataNamespace(); err != nil { + if err := namespace.ValidateForData(); err != nil { continue } return namespace diff --git a/state/core_access.go b/state/core_access.go index 97880c5f3a..3fefaa3ed9 100644 --- a/state/core_access.go +++ b/state/core_access.go @@ -168,7 +168,7 @@ func (ca *CoreAccessor) SubmitPayForBlob( appblobs := make([]*apptypes.Blob, len(blobs)) for i, b := range blobs { - if err := b.Namespace().ValidateBlobNamespace(); err != nil { + if err := b.Namespace().ValidateForBlob(); err != nil { return nil, err } appblobs[i] = &b.Blob