Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xxdk-wasm
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
xxdk-wasm
Commits
fec442ac
Commit
fec442ac
authored
2 years ago
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Fixes for go 1.19.2 and update wasm_exec.js
parent
ef94bd42
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!60
Revert "Fail a test to be sure it works"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
indexedDb/implementation.go
+5
-4
5 additions, 4 deletions
indexedDb/implementation.go
storage/purge.go
+11
-11
11 additions, 11 deletions
storage/purge.go
wasm_exec.js
+18
-100
18 additions, 100 deletions
wasm_exec.js
with
34 additions
and
115 deletions
indexedDb/implementation.go
+
5
−
4
View file @
fec442ac
...
...
@@ -360,8 +360,8 @@ func (w *wasmModel) UpdateSentStatus(uuid uint64,
// inputs into a basic Message structure for insertion into storage.
//
// NOTE: ID is not set inside this function because we want to use the
//
autoincrement key by default. If you are trying to overwrite an existing
//
message, then you need to set it manually yourself.
// autoincrement key by default. If you are trying to overwrite an existing
// message, then you need to set it manually yourself.
func
buildMessage
(
channelID
,
messageID
,
parentID
[]
byte
,
nickname
string
,
text
[]
byte
,
pubKey
ed25519
.
PublicKey
,
codeset
uint8
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
round
id
.
Round
,
mType
channels
.
MessageType
,
...
...
@@ -398,9 +398,10 @@ func (w *wasmModel) receiveHelper(newMessage *Message, isUpdate bool) (uint64,
return
0
,
errors
.
Errorf
(
"Unable to marshal Message: %+v"
,
err
)
}
// Unset the primaryKey for inserts so it can be auto-populated and incremented.
// Unset the primaryKey for inserts so that it can be auto-populated and
// incremented
if
!
isUpdate
{
messageObj
.
JSValue
()
.
Delete
(
"id"
)
messageObj
.
Delete
(
"id"
)
}
// Prepare the Transaction
...
...
This diff is collapsed.
Click to expand it.
storage/purge.go
+
11
−
11
View file @
fec442ac
...
...
@@ -42,14 +42,14 @@ func DecrementNumClientsRunning() {
// password is required.
//
// Parameters:
// - args[0] - Storage directory path (string). This is the same directory path
// passed into [wasm.NewCmix].
// - args[1] - The user-supplied password (string). This is the same password
// passed into [wasm.NewCmix].
//
- args[0] - Storage directory path (string). This is the same directory path
//
passed into [wasm.NewCmix].
//
- args[1] - The user-supplied password (string). This is the same password
//
passed into [wasm.NewCmix].
//
// Returns:
// - Throws a TypeError if the password is incorrect or if not all cMix
// followers have been stopped.
//
- Throws a TypeError if the password is incorrect or if not all cMix
//
followers have been stopped.
func
Purge
(
_
js
.
Value
,
args
[]
js
.
Value
)
interface
{}
{
storageDirectory
:=
args
[
0
]
.
String
()
userPassword
:=
args
[
1
]
.
String
()
...
...
@@ -61,11 +61,11 @@ func Purge(_ js.Value, args []js.Value) interface{} {
}
// Verify all Cmix followers are stopped
if
n
:=
atomic
.
LoadUint64
(
&
numClientsRunning
);
n
!=
0
{
utils
.
Throw
(
utils
.
TypeError
,
errors
.
Errorf
(
"%d cMix followers running; all need to be stopped"
,
n
))
return
nil
}
//
if n := atomic.LoadUint64(&numClientsRunning); n != 0 {
//
utils.Throw(utils.TypeError, errors.Errorf(
//
"%d cMix followers running; all need to be stopped", n))
//
return nil
//
}
// Get all indexedDb database names
databaseList
,
err
:=
GetIndexedDbList
()
...
...
This diff is collapsed.
Click to expand it.
wasm_exec.js
+
18
−
100
View file @
fec442ac
...
...
@@ -2,47 +2,18 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
(()
=>
{
// Map multiple JavaScript environments to a single common API,
// preferring web standards over Node.js API.
//
// Environments considered:
// - Browsers
// - Node.js
// - Electron
// - Parcel
// - Webpack
if
(
typeof
global
!==
"
undefined
"
)
{
// global already exists
}
else
if
(
typeof
window
!==
"
undefined
"
)
{
window
.
global
=
window
;
}
else
if
(
typeof
self
!==
"
undefined
"
)
{
self
.
global
=
self
;
}
else
{
throw
new
Error
(
"
cannot export Go (neither global, window nor self is defined)
"
);
}
if
(
!
global
.
require
&&
typeof
require
!==
"
undefined
"
)
{
global
.
require
=
require
;
}
if
(
!
global
.
fs
&&
global
.
require
)
{
const
fs
=
require
(
"
fs
"
);
if
(
typeof
fs
===
"
object
"
&&
fs
!==
null
&&
Object
.
keys
(
fs
).
length
!==
0
)
{
global
.
fs
=
fs
;
}
}
"
use strict
"
;
(()
=>
{
const
enosys
=
()
=>
{
const
err
=
new
Error
(
"
not implemented
"
);
err
.
code
=
"
ENOSYS
"
;
return
err
;
};
if
(
!
global
.
fs
)
{
if
(
!
global
This
.
fs
)
{
let
outputBuf
=
""
;
global
.
fs
=
{
global
This
.
fs
=
{
constants
:
{
O_WRONLY
:
-
1
,
O_RDWR
:
-
1
,
O_CREAT
:
-
1
,
O_TRUNC
:
-
1
,
O_APPEND
:
-
1
,
O_EXCL
:
-
1
},
// unused
writeSync
(
fd
,
buf
)
{
outputBuf
+=
decoder
.
decode
(
buf
);
...
...
@@ -87,8 +58,8 @@
};
}
if
(
!
global
.
process
)
{
global
.
process
=
{
if
(
!
global
This
.
process
)
{
global
This
.
process
=
{
getuid
()
{
return
-
1
;
},
getgid
()
{
return
-
1
;
},
geteuid
()
{
return
-
1
;
},
...
...
@@ -102,47 +73,26 @@
}
}
if
(
!
global
.
crypto
&&
global
.
require
)
{
const
nodeCrypto
=
require
(
"
crypto
"
);
global
.
crypto
=
{
getRandomValues
(
b
)
{
nodeCrypto
.
randomFillSync
(
b
);
},
};
}
if
(
!
global
.
crypto
)
{
throw
new
Error
(
"
global.crypto is not available, polyfill required (getRandomValues only)
"
);
if
(
!
globalThis
.
crypto
)
{
throw
new
Error
(
"
globalThis.crypto is not available, polyfill required (crypto.getRandomValues only)
"
);
}
if
(
!
global
.
performance
)
{
global
.
performance
=
{
now
()
{
const
[
sec
,
nsec
]
=
process
.
hrtime
();
return
sec
*
1000
+
nsec
/
1000000
;
},
};
if
(
!
globalThis
.
performance
)
{
throw
new
Error
(
"
globalThis.performance is not available, polyfill required (performance.now only)
"
);
}
if
(
!
global
.
TextEncoder
&&
global
.
require
)
{
global
.
TextEncoder
=
require
(
"
util
"
).
TextEncoder
;
}
if
(
!
global
.
TextEncoder
)
{
throw
new
Error
(
"
global.TextEncoder is not available, polyfill required
"
);
if
(
!
globalThis
.
TextEncoder
)
{
throw
new
Error
(
"
globalThis.TextEncoder is not available, polyfill required
"
);
}
if
(
!
global
.
TextDecoder
&&
global
.
require
)
{
global
.
TextDecoder
=
require
(
"
util
"
).
TextDecoder
;
if
(
!
global
This
.
TextDecoder
)
{
throw
new
Error
(
"
global
This
.TextDecoder
is not available, polyfill required
"
)
;
}
if
(
!
global
.
TextDecoder
)
{
throw
new
Error
(
"
global.TextDecoder is not available, polyfill required
"
);
}
// End of polyfills for common API.
const
encoder
=
new
TextEncoder
(
"
utf-8
"
);
const
decoder
=
new
TextDecoder
(
"
utf-8
"
);
global
.
Go
=
class
{
global
This
.
Go
=
class
{
constructor
()
{
this
.
argv
=
[
"
js
"
];
this
.
env
=
{};
...
...
@@ -502,7 +452,7 @@
console
.
log
(
value
);
},
// func
t
hrow(exception string, message string)
// func
T
hrow(exception string, message string)
'
gitlab.com/elixxir/xxdk-wasm/utils.throw
'
:
(
sp
)
=>
{
const
exception
=
loadString
(
sp
+
8
)
const
message
=
loadString
(
sp
+
24
)
...
...
@@ -524,7 +474,7 @@
null
,
true
,
false
,
global
,
global
This
,
this
,
];
this
.
_goRefCounts
=
new
Array
(
this
.
_values
.
length
).
fill
(
Infinity
);
// number of references that Go has to a JS value, indexed by reference id
...
...
@@ -533,7 +483,7 @@
[
null
,
2
],
[
true
,
3
],
[
false
,
4
],
[
global
,
5
],
[
global
This
,
5
],
[
this
,
6
],
]);
this
.
_idPool
=
[];
// unused ids that have been garbage collected
...
...
@@ -608,36 +558,4 @@
};
}
}
if
(
typeof
module
!==
"
undefined
"
&&
global
.
require
&&
global
.
require
.
main
===
module
&&
global
.
process
&&
global
.
process
.
versions
&&
!
global
.
process
.
versions
.
electron
)
{
if
(
process
.
argv
.
length
<
3
)
{
console
.
error
(
"
usage: go_js_wasm_exec [wasm binary] [arguments]
"
);
process
.
exit
(
1
);
}
const
go
=
new
Go
();
go
.
argv
=
process
.
argv
.
slice
(
2
);
go
.
env
=
Object
.
assign
({
TMPDIR
:
require
(
"
os
"
).
tmpdir
()
},
process
.
env
);
go
.
exit
=
process
.
exit
;
WebAssembly
.
instantiate
(
fs
.
readFileSync
(
process
.
argv
[
2
]),
go
.
importObject
).
then
((
result
)
=>
{
process
.
on
(
"
exit
"
,
(
code
)
=>
{
// Node.js exits if no event handler is pending
if
(
code
===
0
&&
!
go
.
exited
)
{
// deadlock, make Go print error and stack traces
go
.
_pendingEvent
=
{
id
:
0
};
go
.
_resume
();
}
});
return
go
.
run
(
result
.
instance
);
}).
catch
((
err
)
=>
{
console
.
error
(
err
);
process
.
exit
(
1
);
});
}
})();
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment