Skip to content

Commit

Permalink
Move ErrNotFound from internal to pkg
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Zhang <[email protected]>
  • Loading branch information
jimthematrix committed Sep 24, 2024
1 parent 544659e commit 2766782
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 7 deletions.
3 changes: 1 addition & 2 deletions go-sdk/internal/sparse-merkle-tree/smt/merkletree.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (

"github.com/hyperledger-labs/zeto/go-sdk/internal/log"
"github.com/hyperledger-labs/zeto/go-sdk/internal/sparse-merkle-tree/node"
"github.com/hyperledger-labs/zeto/go-sdk/internal/sparse-merkle-tree/storage"
"github.com/hyperledger-labs/zeto/go-sdk/internal/sparse-merkle-tree/utils"
"github.com/hyperledger-labs/zeto/go-sdk/pkg/sparse-merkle-tree/core"
)
Expand All @@ -46,7 +45,7 @@ func NewMerkleTree(db core.Storage, maxLevels int) (core.SparseMerkleTree, error
mt := sparseMerkleTree{db: db, maxLevels: maxLevels}

root, err := mt.db.GetRootNodeIndex()
if err == storage.ErrNotFound {
if err == core.ErrNotFound {
mt.rootKey = node.ZERO_INDEX
err = mt.db.UpsertRootNodeIndex(mt.rootKey)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions go-sdk/internal/sparse-merkle-tree/smt/merkletree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"
"testing"

"github.com/hyperledger-labs/zeto/go-sdk/internal/sparse-merkle-tree/storage"
"github.com/hyperledger-labs/zeto/go-sdk/pkg/sparse-merkle-tree/core"
"github.com/stretchr/testify/assert"
)
Expand All @@ -33,7 +32,7 @@ func (ms *mockStorage) GetRootNodeIndex() (core.NodeIndex, error) {
if ms.GetRootNodeIndex_customError {
return nil, fmt.Errorf("nasty error in get root")
}
return nil, storage.ErrNotFound
return nil, core.ErrNotFound
}
func (ms *mockStorage) UpsertRootNodeIndex(core.NodeIndex) error {
return fmt.Errorf("nasty error in upsert root")
Expand Down
4 changes: 2 additions & 2 deletions go-sdk/internal/sparse-merkle-tree/storage/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (s *sqlStorage) GetRootNodeIndex() (core.NodeIndex, error) {
}
err := s.p.DB().Table(core.TreeRootsTable).First(&root).Error
if err == gorm.ErrRecordNotFound {
return nil, ErrNotFound
return nil, core.ErrNotFound
} else if err != nil {
return nil, err
}
Expand Down Expand Up @@ -121,7 +121,7 @@ func getNode(batchOrDb *gorm.DB, nodesTableName string, ref core.NodeIndex) (cor
}
err := batchOrDb.Table(nodesTableName).First(&n).Error
if err == gorm.ErrRecordNotFound {
return nil, ErrNotFound
return nil, core.ErrNotFound
} else if err != nil {
return nil, err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

package storage
package core

import "errors"

Expand Down

0 comments on commit 2766782

Please sign in to comment.