diff --git a/browser/index.html b/browser/index.html index 8402e1254..50e0cd7bf 100644 --- a/browser/index.html +++ b/browser/index.html @@ -3,18 +3,6 @@ 0x Mesh in the browser - - -
-
diff --git a/db/db.go b/db/db.go index c0ee2ec41..dabee114a 100644 --- a/db/db.go +++ b/db/db.go @@ -36,18 +36,6 @@ type DB struct { colLock sync.Mutex } -// Open creates a new database using the given file path for permanent storage. -// It is not safe to have multiple DBs using the same file path. -func Open(path string) (*DB, error) { - ldb, err := leveldb.OpenFile(path, nil) - if err != nil { - return nil, err - } - return &DB{ - ldb: ldb, - }, nil -} - // Close closes the database. It is not safe to call Close if there are any // other methods that have not yet returned. It is safe to call Close multiple // times. diff --git a/db/open.go b/db/open.go new file mode 100644 index 000000000..c04bd3c42 --- /dev/null +++ b/db/open.go @@ -0,0 +1,17 @@ +// +build !js + +package db + +import "github.com/syndtr/goleveldb/leveldb" + +// Open creates a new database using the given file path for permanent storage. +// It is not safe to have multiple DBs using the same file path. +func Open(path string) (*DB, error) { + ldb, err := leveldb.OpenFile(path, nil) + if err != nil { + return nil, err + } + return &DB{ + ldb: ldb, + }, nil +} diff --git a/db/open_js.go b/db/open_js.go new file mode 100644 index 000000000..7adc85350 --- /dev/null +++ b/db/open_js.go @@ -0,0 +1,20 @@ +// +build js,wasm + +package db + +import ( + "github.com/syndtr/goleveldb/leveldb" + "github.com/syndtr/goleveldb/leveldb/storage" +) + +// Open creates a new database using in-memory storage. The given file path is +// ignored. +func Open(path string) (*DB, error) { + ldb, err := leveldb.Open(storage.NewMemStorage(), nil) + if err != nil { + return nil, err + } + return &DB{ + ldb: ldb, + }, nil +}