func (s *Store) Get(key string, i interface{}) error {
	data, err := s.db.Get([]byte(key), nil)
	if err != nil {
		if errors.Is(err, leveldb.ErrNotFound) {
			return storage.ErrNotFound
		}
		return err
	}
	if unmarshaler, ok := i.(encoding.BinaryUnmarshaler); ok {
		return unmarshaler.UnmarshalBinary(data)
	}
	return json.Unmarshal(data, i)
}
Get retrieves a value of the requested key. If no results are found,
storage.ErrNotFound will be returned.
package leveldb
import (
	"encoding"
	"encoding/json"
	"errors"
	"fmt"
	"github.com/ethersphere/bee/pkg/logging"
	"github.com/ethersphere/bee/pkg/storage"
	"github.com/syndtr/goleveldb/leveldb"
	ldberr "github.com/syndtr/goleveldb/leveldb/errors"
	ldb "github.com/syndtr/goleveldb/leveldb"
	ldbs "github.com/syndtr/goleveldb/leveldb/storage"
	"github.com/syndtr/goleveldb/leveldb/util"
)
var _ storage.StateStorer = (*Store)(nil)
type Store struct {
	db     *leveldb.DB
	logger logging.Logger
}
func NewInMemoryStateStore(l logging.Logger) (*Store, error) {
	ldb, err := ldb.Open(ldbs.NewMemStorage(), nil)
	if err != nil {
		return nil, err
	}
	s := &Store{
		db:     ldb,
		logger: l,
	}
	if err := migrate(s); err != nil {
		return nil, err
	}
	return s, nil
}
func NewStateStore(path string, l logging.Logger) (*Store, error) {
	db, err := leveldb.OpenFile(path, nil)
	if err != nil {
		if !ldberr.IsCorrupted(err) {
			return nil, err
		}
		l.Warningf("statestore open failed: %v. attempting recovery", err)
		db, err = leveldb.RecoverFile(path, nil)
		if err != nil {
			return nil, fmt.Errorf("statestore recovery: %w", err)
		}
		l.Warning("statestore recovery ok! you are kindly request to inform us about the steps that preceded the last Bee shutdown.")
	}
	s := &Store{
		db:     db,
		logger: l,
	}
	if err := migrate(s); err != nil {
		return nil, err
	}
	return s, nil
}
func migrate(s *Store) error {
	sn, err := s.getSchemaName()
	if err != nil {
		if !errors.Is(err, storage.ErrNotFound) {
			_ = s.Close()
			return fmt.Errorf("get schema name: %w", err)
		}
		if err := s.putSchemaName(dbSchemaCurrent); err != nil {
			_ = s.Close()
			return fmt.Errorf("put schema name: %w", err)
		}
		sn = dbSchemaCurrent
	}
	if err = s.migrate(sn); err != nil {
		_ = s.Close()
		return fmt.Errorf("migrate: %w", err)
	}
	return nil
}