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
88b6b9d7
Commit
88b6b9d7
authored
2 years ago
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
cleaner logging
parent
b635941d
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!76
added first implementation for disabling users in DM indexedDb package
This commit is part of merge request
!76
. Comments created here will be created in the context of that merge request.
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
indexedDb/impl/dm/implementation.go
+1
-1
1 addition, 1 deletion
indexedDb/impl/dm/implementation.go
indexedDb/impl/utils.go
+8
-8
8 additions, 8 deletions
indexedDb/impl/utils.go
wasm/dm.go
+4
-4
4 additions, 4 deletions
wasm/dm.go
with
13 additions
and
13 deletions
indexedDb/impl/dm/implementation.go
+
1
−
1
Edit
View file @
88b6b9d7
...
...
@@ -395,7 +395,7 @@ func (w *wasmModel) GetConversation(senderPubKey ed25519.PublicKey) *dm.ModelCon
// getConversation is a helper that returns the Conversation with the given senderPubKey.
func
(
w
*
wasmModel
)
getConversation
(
senderPubKey
ed25519
.
PublicKey
)
(
*
Conversation
,
error
)
{
resultObj
,
err
:=
impl
.
Get
(
w
.
db
,
conversationStoreName
,
utils
.
Copy
Bytes
ToJS
(
senderPubKey
))
resultObj
,
err
:=
impl
.
Get
(
w
.
db
,
conversationStoreName
,
impl
.
Encode
Bytes
(
senderPubKey
))
if
err
!=
nil
{
return
nil
,
err
}
...
...
This diff is collapsed.
Click to expand it.
indexedDb/impl/utils.go
+
8
−
8
Edit
View file @
88b6b9d7
...
...
@@ -48,7 +48,7 @@ func EncodeBytes(input []byte) js.Value {
// Get is a generic helper for getting values from the given [idb.ObjectStore].
// Only usable by primary key.
func
Get
(
db
*
idb
.
Database
,
objectStoreName
string
,
key
js
.
Value
)
(
js
.
Value
,
error
)
{
parentErr
:=
errors
.
Errorf
(
"failed to Get
%s/
%s"
,
objectStoreName
,
key
)
parentErr
:=
errors
.
Errorf
(
"failed to Get %s"
,
objectStoreName
)
// Prepare the Transaction
txn
,
err
:=
db
.
Transaction
(
idb
.
TransactionReadOnly
,
objectStoreName
)
...
...
@@ -82,8 +82,8 @@ func Get(db *idb.Database, objectStoreName string, key js.Value) (js.Value, erro
}
// Process result into string
jww
.
DEBUG
.
Printf
(
"Got from
%s/
%s: %s"
,
objectStoreName
,
key
,
utils
.
JsToJson
(
resultObj
))
jww
.
DEBUG
.
Printf
(
"Got from %s: %s"
,
objectStoreName
,
utils
.
JsToJson
(
resultObj
))
return
resultObj
,
nil
}
...
...
@@ -131,8 +131,8 @@ func GetAll(db *idb.Database, objectStoreName string) ([]js.Value, error) {
// [idb.ObjectStore] using the given [idb.Index].
func
GetIndex
(
db
*
idb
.
Database
,
objectStoreName
,
indexName
string
,
key
js
.
Value
)
(
js
.
Value
,
error
)
{
parentErr
:=
errors
.
Errorf
(
"failed to GetIndex %s/%s
/%s
"
,
objectStoreName
,
indexName
,
key
)
parentErr
:=
errors
.
Errorf
(
"failed to GetIndex %s/%s"
,
objectStoreName
,
indexName
)
// Prepare the Transaction
txn
,
err
:=
db
.
Transaction
(
idb
.
TransactionReadOnly
,
objectStoreName
)
...
...
@@ -171,8 +171,8 @@ func GetIndex(db *idb.Database, objectStoreName,
}
// Process result into string
jww
.
DEBUG
.
Printf
(
"Got from %s/%s
/%s
: %s"
,
objectStoreName
,
indexName
,
key
,
utils
.
JsToJson
(
resultObj
))
jww
.
DEBUG
.
Printf
(
"Got from %s/%s: %s"
,
objectStoreName
,
indexName
,
utils
.
JsToJson
(
resultObj
))
return
resultObj
,
nil
}
...
...
@@ -210,7 +210,7 @@ func Put(db *idb.Database, objectStoreName string, value js.Value) (js.Value, er
// Delete is a generic helper for removing values from the given
// [idb.ObjectStore]. Only usable by primary key.
func
Delete
(
db
*
idb
.
Database
,
objectStoreName
string
,
key
js
.
Value
)
error
{
parentErr
:=
errors
.
Errorf
(
"failed to Delete
%s/
%s"
,
objectStoreName
,
key
)
parentErr
:=
errors
.
Errorf
(
"failed to Delete %s"
,
objectStoreName
)
// Prepare the Transaction
txn
,
err
:=
db
.
Transaction
(
idb
.
TransactionReadWrite
,
objectStoreName
)
...
...
This diff is collapsed.
Click to expand it.
wasm/dm.go
+
4
−
4
Edit
View file @
88b6b9d7
...
...
@@ -113,7 +113,7 @@ func (emb *dmReceiverBuilder) Build(path string) bindings.DMReceiver {
func
NewDMClient
(
_
js
.
Value
,
args
[]
js
.
Value
)
any
{
privateIdentity
:=
utils
.
CopyBytesToGo
(
args
[
1
])
em
:=
&
dmReceiverBuilder
{
args
[
2
]
.
I
sNaN
}
em
:=
&
dmReceiverBuilder
{
args
[
2
]
.
I
nvoke
}
cm
,
err
:=
bindings
.
NewDMClient
(
args
[
0
]
.
Int
(),
privateIdentity
,
em
)
if
err
!=
nil
{
...
...
@@ -473,8 +473,8 @@ func (dmc *DMClient) SetNickname(_ js.Value, args []js.Value) any {
// Returns:
// - The nickname (string).
// - Throws TypeError if the channel has no nickname set.
func
(
c
h
*
DMClient
)
GetNickname
(
_
js
.
Value
,
args
[]
js
.
Value
)
any
{
nickname
,
err
:=
c
h
.
api
.
GetNickname
()
func
(
dm
c
*
DMClient
)
GetNickname
(
_
js
.
Value
,
_
[]
js
.
Value
)
any
{
nickname
,
err
:=
dm
c
.
api
.
GetNickname
()
if
err
!=
nil
{
utils
.
Throw
(
utils
.
TypeError
,
err
)
return
nil
...
...
@@ -490,7 +490,7 @@ func (ch *DMClient) GetNickname(_ js.Value, args []js.Value) any {
//
// Returns:
// - The storage tag (string).
func
(
dmc
*
DMClient
)
GetDatabaseName
(
_
js
.
Value
,
args
[]
js
.
Value
)
any
{
func
(
dmc
*
DMClient
)
GetDatabaseName
(
_
js
.
Value
,
_
[]
js
.
Value
)
any
{
return
base64
.
RawStdEncoding
.
EncodeToString
(
dmc
.
api
.
GetPublicKey
())
+
"_speakeasy_dm"
}
...
...
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