Skip to content
Snippets Groups Projects
Commit 1d3519b1 authored by Richard T. Carback III's avatar Richard T. Carback III
Browse files

Merge branch 'hotfix/remoteStoragePathPrefix' into 'project/HavenBeta'

update the synchronization functions to take a remote storage prefix path.

See merge request !140
parents 6121f2b9 5737cbcb
No related branches found
No related tags found
2 merge requests!140update the synchronization functions to take a remote storage prefix path.,!109Project/haven beta
......@@ -11,7 +11,7 @@ require (
github.com/spf13/cobra v1.7.0
github.com/spf13/jwalterweatherman v1.1.0
github.com/stretchr/testify v1.8.2
gitlab.com/elixxir/client/v4 v4.6.4-0.20230720181158-df0babea16df
gitlab.com/elixxir/client/v4 v4.6.4-0.20230724165849-04fc01e5b706
gitlab.com/elixxir/crypto v0.0.7-0.20230614183801-387e0cb8e76f
gitlab.com/elixxir/primitives v0.0.3-0.20230613193928-8cf8bdd777ef
gitlab.com/elixxir/wasm-utils v0.0.0-20230615222914-185dd3a6fa08
......@@ -31,10 +31,12 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/elliotchance/orderedmap v1.4.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/gobwas/ws v1.1.0 // indirect
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 // indirect
github.com/golang/protobuf v1.5.2 // indirect
github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.1.0 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
......@@ -43,18 +45,27 @@ require (
github.com/klauspost/compress v1.15.9 // indirect
github.com/klauspost/cpuid/v2 v2.1.0 // indirect
github.com/kr/pretty v0.3.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mattn/go-sqlite3 v1.14.15 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20221003100820-41fad3beba17 // indirect
github.com/oasisprotocol/deoxysii v0.0.0-20220228165953-2091330c22b7 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/pkg/profile v1.6.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rs/cors v1.8.2 // indirect
github.com/sethvargo/go-diceware v0.3.0 // indirect
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
github.com/soheilhy/cmux v0.1.5 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.12.0 // indirect
github.com/subosito/gotenv v1.4.0 // indirect
github.com/ttacon/builder v0.0.0-20170518171403-c099f663e1c2 // indirect
github.com/ttacon/libphonenumber v1.2.1 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect
......@@ -75,6 +86,8 @@ require (
google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc // indirect
google.golang.org/grpc v1.49.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gorm.io/driver/sqlite v1.4.4 // indirect
gorm.io/gorm v1.24.3 // indirect
......
This diff is collapsed.
......@@ -123,8 +123,10 @@ func NewCmix(_ js.Value, args []js.Value) any {
// Parameters:
// - args[0] - NDF JSON ([ndf.NetworkDefinition]) (string).
// - args[1] - Storage directory path (string).
// - args[2] - Password used for storage (Uint8Array).
// - args[3] - Javascript [RemoteStore] implementation.
// - args[2] - The remote "directory" or path prefix used by the RemoteStore
// when reading/writing files (string).
// - args[3] - Password used for storage (Uint8Array).
// - args[4] - Javascript [RemoteStore] implementation.
//
// Returns a promise:
// - Resolves on success.
......@@ -132,14 +134,16 @@ func NewCmix(_ js.Value, args []js.Value) any {
func NewSynchronizedCmix(_ js.Value, args []js.Value) any {
ndfJSON := args[0].String()
storageDir := args[1].String()
password := utils.CopyBytesToGo(args[2])
rs := newRemoteStore(args[3])
remoteStoragePrefixPath := args[2].String()
password := utils.CopyBytesToGo(args[3])
rs := newRemoteStore(args[4])
promiseFn := func(resolve, reject func(args ...any) js.Value) {
// Block loading of synchronized Cmix during initialisation
initializing.Store(true)
err := bindings.NewSynchronizedCmix(ndfJSON, storageDir, password, rs)
err := bindings.NewSynchronizedCmix(ndfJSON, storageDir,
remoteStoragePrefixPath, password, rs)
// Unblock loading of synchronized Cmix during initialisation
initializing.Store(false)
......@@ -178,7 +182,8 @@ func LoadCmix(_ js.Value, args []js.Value) any {
cmixParamsJSON := utils.CopyBytesToGo(args[2])
promiseFn := func(resolve, reject func(args ...any) js.Value) {
net, err := bindings.LoadCmix(storageDir, password, cmixParamsJSON)
net, err := bindings.LoadCmix(storageDir, password,
cmixParamsJSON)
if err != nil {
reject(exception.NewTrace(err))
} else {
......@@ -194,25 +199,29 @@ func LoadCmix(_ js.Value, args []js.Value) any {
//
// Parameters:
// - args[0] - Storage directory path (string).
// - args[1] - Password used for storage (Uint8Array).
// - args[2] - Javascript [RemoteStore] implementation.
// - args[3] - JSON of [xxdk.CMIXParams] (Uint8Array).
// - args[1] - The remote "directory" or path prefix used by the RemoteStore
// when reading/writing files (string).
// - args[2] - Password used for storage (Uint8Array).
// - args[3] - Javascript [RemoteStore] implementation.
// - args[4] - JSON of [xxdk.CMIXParams] (Uint8Array).
//
// Returns a promise:
// - Resolves to a Javascript representation of the [Cmix] object.
// - Rejected with an error if loading [Cmix] fails.
func LoadSynchronizedCmix(_ js.Value, args []js.Value) any {
storageDir := args[0].String()
password := utils.CopyBytesToGo(args[1])
rs := newRemoteStore(args[2])
cmixParamsJSON := utils.CopyBytesToGo(args[3])
remoteStoragePrefixPath := args[1].String()
password := utils.CopyBytesToGo(args[2])
rs := newRemoteStore(args[3])
cmixParamsJSON := utils.CopyBytesToGo(args[4])
promiseFn := func(resolve, reject func(args ...any) js.Value) {
if initializing.Load() {
reject(exception.NewTrace(fmt.Errorf(
"cannot Load when New is running")))
}
net, err := bindings.LoadSynchronizedCmix(storageDir, password,
net, err := bindings.LoadSynchronizedCmix(storageDir,
remoteStoragePrefixPath, password,
rs, cmixParamsJSON)
if err != nil {
reject(exception.NewTrace(err))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment