Skip to content

Commit

Permalink
send node public key during registration
Browse files Browse the repository at this point in the history
  • Loading branch information
zaibon committed Mar 18, 2020
1 parent 70990d0 commit 3f8cb75
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions pkg/identity/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ package identity

import (
"bytes"
"encoding/hex"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"

"github.com/jbenet/go-base58"

"github.com/threefoldtech/zos/pkg/gedis/types/directory"

"github.com/threefoldtech/zos/pkg/geoip"
Expand All @@ -33,6 +36,9 @@ func NewHTTPIDStore(url string) IDStore {
// RegisterNode implements the IDStore interface
func (s *httpIDStore) RegisterNode(node pkg.Identifier, farm pkg.FarmID, version string, loc geoip.Location) (string, error) {
buf := bytes.Buffer{}

pk := base58.Decode(node.Identity())

err := json.NewEncoder(&buf).Encode(directory.TfgridNode2{
NodeID: node.Identity(),
FarmID: uint64(farm),
Expand All @@ -44,6 +50,7 @@ func (s *httpIDStore) RegisterNode(node pkg.Identifier, farm pkg.FarmID, version
Latitude: loc.Latitude,
Longitude: loc.Longitute,
},
PublicKeyHex: hex.EncodeToString(pk),
})
if err != nil {
return "", err
Expand Down

0 comments on commit 3f8cb75

Please sign in to comment.