Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nodemanager
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Odysseus
nodemanager
Commits
60f2ac1e
Commit
60f2ac1e
authored
Jan 29, 2024
by
vicotor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
ca390b09
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
node.go
server/node.go
+2
-2
workerManager.go
server/workerManager.go
+12
-1
No files found.
server/node.go
View file @
60f2ac1e
...
@@ -3,7 +3,7 @@ package server
...
@@ -3,7 +3,7 @@ package server
import
(
import
(
"context"
"context"
"crypto/ecdsa"
"crypto/ecdsa"
"
crypto/rand
"
"
github.com/ethereum/go-ethereum/crypto
"
"github.com/odysseus/nodemanager/config"
"github.com/odysseus/nodemanager/config"
"github.com/odysseus/nodemanager/nmregistry"
"github.com/odysseus/nodemanager/nmregistry"
"github.com/odysseus/nodemanager/utils"
"github.com/odysseus/nodemanager/utils"
...
@@ -64,7 +64,7 @@ func NewNode() *Node {
...
@@ -64,7 +64,7 @@ func NewNode() *Node {
}
}
func
(
n
*
Node
)
Sign
(
hash
[]
byte
)
([]
byte
,
error
)
{
func
(
n
*
Node
)
Sign
(
hash
[]
byte
)
([]
byte
,
error
)
{
return
n
.
privk
.
Sign
(
rand
.
Reader
,
hash
,
nil
)
return
crypto
.
Sign
(
hash
,
n
.
privk
)
}
}
func
(
n
*
Node
)
Start
()
error
{
func
(
n
*
Node
)
Start
()
error
{
...
...
server/workerManager.go
View file @
60f2ac1e
...
@@ -6,6 +6,7 @@ import (
...
@@ -6,6 +6,7 @@ import (
"encoding/json"
"encoding/json"
"errors"
"errors"
"fmt"
"fmt"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/crypto"
"github.com/golang/protobuf/proto"
"github.com/golang/protobuf/proto"
lru
"github.com/hashicorp/golang-lru"
lru
"github.com/hashicorp/golang-lru"
...
@@ -39,6 +40,7 @@ type Worker struct {
...
@@ -39,6 +40,7 @@ type Worker struct {
uuid
int64
uuid
int64
publicKey
string
publicKey
string
addr
string
addr
string
benefitAddr
string
status
[]
byte
status
[]
byte
usageInfo
[]
*
omanager
.
DeviceUsage
usageInfo
[]
*
omanager
.
DeviceUsage
deviceInfo
[]
*
omanager
.
DeviceInfo
deviceInfo
[]
*
omanager
.
DeviceInfo
...
@@ -47,6 +49,14 @@ type Worker struct {
...
@@ -47,6 +49,14 @@ type Worker struct {
stream
omanager
.
NodeManagerService_RegisterWorkerServer
stream
omanager
.
NodeManagerService_RegisterWorkerServer
}
}
func
(
w
*
Worker
)
ProfitAccount
()
common
.
Address
{
return
common
.
HexToAddress
(
w
.
benefitAddr
)
}
func
(
w
*
Worker
)
WorkerAccount
()
common
.
Address
{
return
common
.
HexToAddress
(
w
.
addr
)
}
type
WorkerManager
struct
{
type
WorkerManager
struct
{
rdb
*
redis
.
Client
rdb
*
redis
.
Client
heartBeat
map
[
int64
]
int64
heartBeat
map
[
int64
]
int64
...
@@ -329,7 +339,7 @@ func (wm *WorkerManager) manageWorker(worker *Worker) error {
...
@@ -329,7 +339,7 @@ func (wm *WorkerManager) manageWorker(worker *Worker) error {
paramHash
:=
crypto
.
Keccak256Hash
(
task
.
TaskParam
)
paramHash
:=
crypto
.
Keccak256Hash
(
task
.
TaskParam
)
resultHash
:=
crypto
.
Keccak256Hash
(
result
.
TaskResult
)
resultHash
:=
crypto
.
Keccak256Hash
(
result
.
TaskResult
)
dataHash
:=
crypto
.
Keccak256Hash
(
utils
.
CombineBytes
([]
byte
(
result
.
TaskUuid
),
paramHash
[
:
],
resultHash
[
:
],
dataHash
:=
crypto
.
Keccak256Hash
(
utils
.
CombineBytes
([]
byte
(
result
.
TaskUuid
),
paramHash
[
:
],
resultHash
[
:
],
result
.
ContainerSignature
,
result
.
MinerSignature
,
big
.
NewInt
(
int64
(
task
.
TaskWorkload
))
.
Bytes
()))
worker
.
ProfitAccount
()
.
Bytes
(),
worker
.
WorkerAccount
()
.
Bytes
(),
result
.
ContainerSignature
,
result
.
MinerSignature
,
big
.
NewInt
(
int64
(
task
.
TaskWorkload
))
.
Bytes
()))
signature
,
err
:=
wm
.
node
.
Sign
(
dataHash
[
:
])
signature
,
err
:=
wm
.
node
.
Sign
(
dataHash
[
:
])
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -421,6 +431,7 @@ func (wm *WorkerManager) handleWorkerMsg(worker *Worker) {
...
@@ -421,6 +431,7 @@ func (wm *WorkerManager) handleWorkerMsg(worker *Worker) {
// receive device info
// receive device info
worker
.
publicKey
=
msg
.
DeviceInfo
.
MinerPubkey
worker
.
publicKey
=
msg
.
DeviceInfo
.
MinerPubkey
worker
.
deviceInfo
=
msg
.
DeviceInfo
.
Devices
worker
.
deviceInfo
=
msg
.
DeviceInfo
.
Devices
worker
.
benefitAddr
=
msg
.
DeviceInfo
.
BenefitAddress
if
pubkey
,
err
:=
utils
.
HexToPubkey
(
worker
.
publicKey
);
err
!=
nil
{
if
pubkey
,
err
:=
utils
.
HexToPubkey
(
worker
.
publicKey
);
err
!=
nil
{
log
.
WithFields
(
log
.
Fields
{
log
.
WithFields
(
log
.
Fields
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment