Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
client
Commits
bef0fcde
Commit
bef0fcde
authored
2 years ago
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Remove bindings-level Fact object and instead use fact.Fact and fact.FactList
parent
c026d27b
No related branches found
No related tags found
1 merge request
!330
XX-4030 / Bindings Facts
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
bindings/e2eAuth.go
+3
-11
3 additions, 11 deletions
bindings/e2eAuth.go
bindings/identity.go
+14
-40
14 additions, 40 deletions
bindings/identity.go
bindings/identity_test.go
+0
-16
0 additions, 16 deletions
bindings/identity_test.go
bindings/ud.go
+1
-1
1 addition, 1 deletion
bindings/ud.go
with
18 additions
and
68 deletions
bindings/e2eAuth.go
+
3
−
11
View file @
bef0fcde
...
@@ -35,12 +35,12 @@ import (
...
@@ -35,12 +35,12 @@ import (
//
//
// Parameters:
// Parameters:
// - partnerContact - the marshalled bytes of the contact.Contact object.
// - partnerContact - the marshalled bytes of the contact.Contact object.
// -
myF
acts
- stringified list
of fact.FactList.
// -
f
acts
ListJson - the JSON marshalled bytes
of fact.FactList.
//
//
// Returns:
// Returns:
// - int64 - ID of the round (convert to uint64)
// - int64 - ID of the round (convert to uint64)
func
(
e
*
E2e
)
Request
(
partnerContact
,
factsListJson
[]
byte
)
(
int64
,
error
)
{
func
(
e
*
E2e
)
Request
(
partnerContact
,
factsListJson
[]
byte
)
(
int64
,
error
)
{
var
factsList
[]
Fac
t
var
factsList
fact
.
FactLis
t
err
:=
json
.
Unmarshal
(
factsListJson
,
&
factsList
)
err
:=
json
.
Unmarshal
(
factsListJson
,
&
factsList
)
if
err
!=
nil
{
if
err
!=
nil
{
return
0
,
err
return
0
,
err
...
@@ -51,15 +51,7 @@ func (e *E2e) Request(partnerContact, factsListJson []byte) (int64, error) {
...
@@ -51,15 +51,7 @@ func (e *E2e) Request(partnerContact, factsListJson []byte) (int64, error) {
return
0
,
err
return
0
,
err
}
}
myFacts
:=
fact
.
FactList
{}
roundID
,
err
:=
e
.
api
.
GetAuth
()
.
Request
(
partner
,
factsList
)
for
_
,
f
:=
range
factsList
{
myFacts
=
append
(
myFacts
,
fact
.
Fact
{
Fact
:
f
.
Fact
,
T
:
fact
.
FactType
(
f
.
Type
),
})
}
roundID
,
err
:=
e
.
api
.
GetAuth
()
.
Request
(
partner
,
myFacts
)
return
int64
(
roundID
),
err
return
int64
(
roundID
),
err
}
}
...
...
This diff is collapsed.
Click to expand it.
bindings/identity.go
+
14
−
40
View file @
bef0fcde
...
@@ -123,67 +123,41 @@ func GetPubkeyFromContact(marshaled []byte) ([]byte, error) {
...
@@ -123,67 +123,41 @@ func GetPubkeyFromContact(marshaled []byte) ([]byte, error) {
// Fact Functions //
// Fact Functions //
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// Fact is an internal fact type for use in the bindings layer.
//
// JSON example:
// {
// "Fact": "Zezima",
// "Type": 0
// }
type
Fact
struct
{
Fact
string
Type
int
}
// SetFactsOnContact replaces the facts on the contact with the passed in facts
// SetFactsOnContact replaces the facts on the contact with the passed in facts
// pass in empty facts in order to clear the facts.
// pass in empty facts in order to clear the facts.
//
//
// Parameters:
// Parameters:
// - marshaled - JSON marshalled contact.Contact object
// - marshaled -
the
JSON marshalled
by of
contact.Contact object
.
// - fact
s -
JSON marshalled
Fact objec
t.
// - fact
ListJSON - the
JSON marshalled
bytes of fact.FactLis
t.
func
SetFactsOnContact
(
marshaled
[]
byte
,
fact
s
[]
byte
)
([]
byte
,
error
)
{
func
SetFactsOnContact
(
marshaled
[]
byte
,
fact
ListJSON
[]
byte
)
([]
byte
,
error
)
{
cnt
,
err
:=
contact
.
Unmarshal
(
marshaled
)
cnt
,
err
:=
contact
.
Unmarshal
(
marshaled
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
factsList
:=
make
([]
Fact
,
0
)
var
factsList
fact
.
FactList
err
=
json
.
Unmarshal
(
fact
s
,
&
factsList
)
err
=
json
.
Unmarshal
(
fact
ListJSON
,
&
factsList
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
realFactList
:=
make
(
fact
.
FactList
,
0
,
len
(
factsList
))
cnt
.
Facts
=
factsList
for
i
:=
range
factsList
{
realFactList
=
append
(
realFactList
,
fact
.
Fact
{
Fact
:
factsList
[
i
]
.
Fact
,
T
:
fact
.
FactType
(
factsList
[
i
]
.
Type
),
})
}
cnt
.
Facts
=
realFactList
return
cnt
.
Marshal
(),
nil
return
cnt
.
Marshal
(),
nil
}
}
// GetFactsFromContact accepts a marshalled contact.Contact object and returns
// GetFactsFromContact returns the fact list in the contact.Contact object.
// its marshalled list of Fact objects.
//
// Parameters:
// - marshaled - the JSON marshalled by of contact.Contact object.
//
// Returns:
// - []byte - the JSON marshalled bytes of fact.FactList.
func
GetFactsFromContact
(
marshaled
[]
byte
)
([]
byte
,
error
)
{
func
GetFactsFromContact
(
marshaled
[]
byte
)
([]
byte
,
error
)
{
cnt
,
err
:=
contact
.
Unmarshal
(
marshaled
)
cnt
,
err
:=
contact
.
Unmarshal
(
marshaled
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
factsList
:=
make
([]
Fact
,
len
(
cnt
.
Facts
))
return
json
.
Marshal
(
&
cnt
.
Facts
)
for
i
:=
range
cnt
.
Facts
{
factsList
=
append
(
factsList
,
Fact
{
Fact
:
cnt
.
Facts
[
i
]
.
Fact
,
Type
:
int
(
cnt
.
Facts
[
i
]
.
T
),
})
}
factsListMarshaled
,
err
:=
json
.
Marshal
(
&
factsList
)
if
err
!=
nil
{
return
nil
,
err
}
return
factsListMarshaled
,
nil
}
}
This diff is collapsed.
Click to expand it.
bindings/identity_test.go
+
0
−
16
View file @
bef0fcde
...
@@ -41,22 +41,6 @@ func TestIdentity_JSON(t *testing.T) {
...
@@ -41,22 +41,6 @@ func TestIdentity_JSON(t *testing.T) {
t
.
Log
(
string
(
im
))
t
.
Log
(
string
(
im
))
}
}
func
TestFacts_JSON
(
t
*
testing
.
T
)
{
fl
:=
[]
Fact
{
{
Fact
:
"Zezima"
,
Type
:
0
,
},
{
Fact
:
"Zezima@osrs.org"
,
Type
:
2
,
},
}
flm
,
_
:=
json
.
Marshal
(
fl
)
t
.
Log
(
"Marshalled []Fact"
)
t
.
Log
(
string
(
flm
))
}
func
getGroup
()
*
cyclic
.
Group
{
func
getGroup
()
*
cyclic
.
Group
{
return
cyclic
.
NewGroup
(
return
cyclic
.
NewGroup
(
large
.
NewIntFromString
(
"E2EE983D031DC1DB6F1A7A67DF0E9A8E5561DB8E8D4941"
+
large
.
NewIntFromString
(
"E2EE983D031DC1DB6F1A7A67DF0E9A8E5561DB8E8D4941"
+
...
...
This diff is collapsed.
Click to expand it.
bindings/ud.go
+
1
−
1
View file @
bef0fcde
...
@@ -277,7 +277,7 @@ func (ud *UserDiscovery) PermanentDeleteAccount(factJson []byte) error {
...
@@ -277,7 +277,7 @@ func (ud *UserDiscovery) PermanentDeleteAccount(factJson []byte) error {
// passed in is not UD service does not associate this fact with this user.
// passed in is not UD service does not associate this fact with this user.
//
//
// Parameters:
// Parameters:
// - factJson - a JSON marshalled fact.Fact
// - factJson - a JSON marshalled
[
fact.Fact
]
func
(
ud
*
UserDiscovery
)
RemoveFact
(
factJson
[]
byte
)
error
{
func
(
ud
*
UserDiscovery
)
RemoveFact
(
factJson
[]
byte
)
error
{
var
f
fact
.
Fact
var
f
fact
.
Fact
err
:=
json
.
Unmarshal
(
factJson
,
&
f
)
err
:=
json
.
Unmarshal
(
factJson
,
&
f
)
...
...
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