Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MainNet commitments
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
archives
MainNet commitments
Commits
ab82fcdb
Commit
ab82fcdb
authored
Mar 9, 2022
by
Jonah Husson
Browse files
Options
Downloads
Patches
Plain Diff
Add list of node IDs to not check wallet on
parent
90f8cec8
No related branches found
No related tags found
1 merge request
!10
Draft: November commitments
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/server.go
+1
-0
1 addition, 0 deletions
cmd/server.go
server/serverImpl.go
+32
-10
32 additions, 10 deletions
server/serverImpl.go
with
33 additions
and
10 deletions
cmd/server.go
+
1
−
0
View file @
ab82fcdb
...
...
@@ -53,6 +53,7 @@ var serverCmd = &cobra.Command{
params
:=
server
.
Params
{
KeyPath
:
keyPath
,
CertPath
:
certPath
,
IDListPath
:
viper
.
GetString
(
"idListPath"
),
Port
:
viper
.
GetString
(
"port"
),
ContractHash
:
viper
.
GetString
(
"contractHash"
),
}
...
...
This diff is collapsed.
Click to expand it.
server/serverImpl.go
+
32
−
10
View file @
ab82fcdb
...
...
@@ -8,10 +8,12 @@
package
server
import
(
"bytes"
"context"
gorsa
"crypto/rsa"
"crypto/x509"
"encoding/base64"
"encoding/csv"
"encoding/json"
"encoding/pem"
"fmt"
...
...
@@ -26,6 +28,7 @@ import (
"gitlab.com/xx_network/crypto/signature/rsa"
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/idf"
utils2
"gitlab.com/xx_network/primitives/utils"
"net/http"
"testing"
"time"
...
...
@@ -37,6 +40,7 @@ type Params struct {
CertPath
string
ContractHash
string
Port
string
IDListPath
string
}
// StartServer creates a server object from params
...
...
@@ -44,6 +48,21 @@ func StartServer(params Params, s *storage.Storage) error {
impl
:=
&
Impl
{
s
:
s
,
contractHash
:
params
.
ContractHash
,
idList
:
map
[
string
]
interface
{}{},
}
if
p
,
err
:=
utils2
.
ExpandPath
(
params
.
IDListPath
);
err
==
nil
{
idList
,
err
:=
utils2
.
ReadFile
(
p
)
if
err
!=
nil
{
return
errors
.
WithMessage
(
err
,
"Failed to read ID list path"
)
}
r
:=
csv
.
NewReader
(
bytes
.
NewReader
(
idList
))
records
,
err
:=
r
.
ReadAll
()
for
_
,
r
:=
range
records
{
impl
.
idList
[
r
[
0
]]
=
true
}
}
else
{
return
errors
.
WithMessage
(
err
,
"Failed to expand ID list path"
)
}
// Build gin server, link to verify code
...
...
@@ -90,6 +109,7 @@ type Impl struct {
comms
*
gin
.
Engine
s
*
storage
.
Storage
contractHash
string
idList
map
[
string
]
interface
{}
}
// Verify func is the main endpoint for the mainnet-commitments server
...
...
@@ -192,6 +212,7 @@ func (i *Impl) Verify(_ context.Context, msg messages.Commitment) error {
}
// Check if wallet is in old commitments
if
_
,
ok
:=
i
.
idList
[
nid
.
String
()];
!
ok
{
ok
,
err
=
i
.
s
.
CheckWallet
(
msg
.
PaymentWallet
)
if
err
!=
nil
{
err
=
errors
.
WithMessage
(
err
,
"Failed to check wallet status in old commitments"
)
...
...
@@ -203,6 +224,7 @@ func (i *Impl) Verify(_ context.Context, msg messages.Commitment) error {
jww
.
ERROR
.
Println
(
err
)
return
err
}
}
// Insert commitment info to the database once verified
err
=
i
.
s
.
InsertCommitment
(
storage
.
Commitment
{
...
...
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