Skip to content

Commit

Permalink
just check not realm path, not a new const for package path
Browse files Browse the repository at this point in the history
  • Loading branch information
deelawn committed Mar 30, 2024
1 parent 77032fc commit 5342c67
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ func (m *Machine) runFiles(memPkg *std.MemPackage, fns ...*FileNode) {
// worry about pointer ownership issues for packages because they (eventually) will only be
// able to import other packages and those packages won't be able to persist any pointers
// to their own state that they receive from other packages.
if memPkg != nil && IsPackagePath(memPkg.Path) {
if memPkg != nil && !IsRealmPath(memPkg.Path) {
// store package values and types
m.savePackageValuesAndTypes()
// store mempackage
Expand Down
9 changes: 1 addition & 8 deletions gnovm/pkg/gnolang/realm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1521,21 +1521,14 @@ func isUnsaved(oo Object) bool {

// realmPathPrefix is the prefix used to identify pkgpaths which are meant to
// be realms and as such to have their state persisted. This is used by [IsRealmPath].
const (
realmPathPrefix = "gno.land/r/"
packagePathPrefix = "gno.land/p"
)
const realmPathPrefix = "gno.land/r/"

// IsRealmPath determines whether the given pkgpath is for a realm, and as such
// should persist the global state.
func IsRealmPath(pkgPath string) bool {
return strings.HasPrefix(pkgPath, realmPathPrefix)
}

func IsPackagePath(pkgPath string) bool {
return strings.HasPrefix(pkgPath, packagePathPrefix)
}

func prettyJSON(jstr []byte) []byte {
var c interface{}
err := json.Unmarshal(jstr, &c)
Expand Down

0 comments on commit 5342c67

Please sign in to comment.