Skip to content

Commit a410da3

Browse files
committed
feature: added client key arg option
1 parent fddb26b commit a410da3

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed

code/go/0chain.net/blobber/flags.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var (
1010
keysFile string
1111
keysFilePublicKey string
1212
keysFilePrivateKey string
13+
keysFileClientKey string
1314
keysFileIsSplit bool
1415
mountPoint string
1516
metadataDB string
@@ -29,6 +30,7 @@ func init() {
2930
flag.StringVar(&keysFile, "keys_file", "", "keys_file")
3031
flag.StringVar(&keysFilePublicKey, "keys_file_public_key", "", "keys_file_public_key")
3132
flag.StringVar(&keysFilePrivateKey, "keys_file_private_key", "", "keys_file_private_key")
33+
flag.StringVar(&keysFileClientKey, "keys_file_client_key", "", "keys_file_client_key")
3234
flag.BoolVar(&keysFileIsSplit, "keys_file_is_split", false, "keys_file_is_split")
3335
flag.StringVar(&mountPoint, "files_dir", "", "Mounted partition where all files will be stored")
3436
flag.StringVar(&metadataDB, "db_dir", "", "db_dir")

code/go/0chain.net/blobber/node.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
"go.uber.org/zap"
1515
)
1616

17-
var publicKey, privateKey string
17+
var clientKey, publicKey, privateKey string
1818

1919
func setupNode() error {
2020
fmt.Println("> setup blobber")
@@ -25,6 +25,10 @@ func setupNode() error {
2525
privateKey = keysFilePrivateKey
2626
publicKey = keysFilePublicKey
2727

28+
if keysFileIsSplit {
29+
clientKey = keysFileClientKey
30+
}
31+
2832
fmt.Println("using blobber keys from local string")
2933
} else {
3034
err = readKeysFromAws()
@@ -39,7 +43,7 @@ func setupNode() error {
3943
}
4044
}
4145

42-
node.Self.SetKeys(publicKey, privateKey, keysFileIsSplit)
46+
node.Self.SetKeys(clientKey, publicKey, privateKey, keysFileIsSplit)
4347

4448
if node.Self.ID == "" {
4549
return errors.New("node definition for self node doesn't exist")

code/go/0chain.net/core/node/self_node.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,22 @@ type SelfNode struct {
2020
}
2121

2222
/*SetKeys - setter */
23-
func (sn *SelfNode) SetKeys(publicKey, privateKey string, isSplit bool) {
24-
publicKeyBytes, err := hex.DecodeString(publicKey)
23+
func (sn *SelfNode) SetKeys(clientKey, publicKey, privateKey string, isSplit bool) {
24+
var (
25+
publicKeyBytes []byte
26+
err error
27+
)
28+
29+
if isSplit {
30+
publicKeyBytes, err = hex.DecodeString(clientKey)
31+
} else {
32+
publicKeyBytes, err = hex.DecodeString(publicKey)
33+
}
34+
2535
if err != nil {
2636
panic(err)
2737
}
38+
2839
sn.wallet = &zcncrypto.Wallet{}
2940
sn.wallet.ClientID = Hash(publicKeyBytes)
3041
sn.wallet.ClientKey = publicKey

code/go/0chain.net/validator/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ func main() {
107107
fmt.Println("using validator keys from aws")
108108
}
109109

110-
node.Self.SetKeys(publicKey, privateKey, false)
110+
node.Self.SetKeys("", publicKey, privateKey, false)
111111

112112
if len(*hostUrl) > 0 {
113113
node.Self.URL = *hostUrl

code/go/0chain.net/validatorcore/storage/models_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,6 @@ func setupModelsTest(t *testing.T) error {
659659
return err
660660
}
661661

662-
node.Self.SetKeys(wallet.Keys[0].PublicKey, wallet.Keys[0].PrivateKey, false)
662+
node.Self.SetKeys("", wallet.Keys[0].PublicKey, wallet.Keys[0].PrivateKey, false)
663663
return nil
664664
}

0 commit comments

Comments
 (0)