Skip to content

Commit

Permalink
storagenode: wallet features
Browse files Browse the repository at this point in the history
WHAT: updated dashboard type to return wallet features from storagenode api

Change-Id: Ifdbdeae8b9ae239eaebe32d0a093557154f777ad
  • Loading branch information
NikolaiYurchenko committed Mar 24, 2021
1 parent 3e37d1e commit 034eb2c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
3 changes: 2 additions & 1 deletion private/testplanet/storagenode.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"storj.io/storj/storagenode/gracefulexit"
"storj.io/storj/storagenode/monitor"
"storj.io/storj/storagenode/nodestats"
"storj.io/storj/storagenode/operator"
"storj.io/storj/storagenode/orders"
"storj.io/storj/storagenode/pieces"
"storj.io/storj/storagenode/piecestore"
Expand Down Expand Up @@ -125,7 +126,7 @@ func (planet *Planet) newStorageNode(ctx context.Context, prefix string, index,
Preflight: preflight.Config{
LocalTimeCheck: false,
},
Operator: storagenode.OperatorConfig{
Operator: operator.Config{
Email: prefix + "@mail.test",
Wallet: "0x" + strings.Repeat("00", 20),
WalletFeatures: nil,
Expand Down
17 changes: 11 additions & 6 deletions storagenode/console/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"storj.io/storj/private/version/checker"
"storj.io/storj/storagenode/bandwidth"
"storj.io/storj/storagenode/contact"
"storj.io/storj/storagenode/operator"
"storj.io/storj/storagenode/payouts/estimatedpayouts"
"storj.io/storj/storagenode/pieces"
"storj.io/storj/storagenode/pricing"
Expand Down Expand Up @@ -56,16 +57,17 @@ type Service struct {

allocatedDiskSpace memory.Size

walletAddress string
startedAt time.Time
versionInfo version.Info
walletAddress string
walletFeatures operator.WalletFeatures
startedAt time.Time
versionInfo version.Info
}

// NewService returns new instance of Service.
func NewService(log *zap.Logger, bandwidth bandwidth.DB, pieceStore *pieces.Store, version *checker.Service,
allocatedDiskSpace memory.Size, walletAddress string, versionInfo version.Info, trust *trust.Pool,
reputationDB reputation.DB, storageUsageDB storageusage.DB, pricingDB pricing.DB, satelliteDB satellites.DB,
pingStats *contact.PingStats, contact *contact.Service, estimation *estimatedpayouts.Service, usageCache *pieces.BlobsUsageCache) (*Service, error) {
pingStats *contact.PingStats, contact *contact.Service, estimation *estimatedpayouts.Service, usageCache *pieces.BlobsUsageCache, walletFeatures operator.WalletFeatures) (*Service, error) {
if log == nil {
return nil, errs.New("log can't be nil")
}
Expand Down Expand Up @@ -116,6 +118,7 @@ func NewService(log *zap.Logger, bandwidth bandwidth.DB, pieceStore *pieces.Stor
walletAddress: walletAddress,
startedAt: time.Now(),
versionInfo: versionInfo,
walletFeatures: walletFeatures,
}, nil
}

Expand All @@ -130,8 +133,9 @@ type SatelliteInfo struct {

// Dashboard encapsulates dashboard stale data.
type Dashboard struct {
NodeID storj.NodeID `json:"nodeID"`
Wallet string `json:"wallet"`
NodeID storj.NodeID `json:"nodeID"`
Wallet string `json:"wallet"`
WalletFeatures []string `json:"walletFeatures"`

Satellites []SatelliteInfo `json:"satellites"`

Expand All @@ -154,6 +158,7 @@ func (s *Service) GetDashboardData(ctx context.Context) (_ *Dashboard, err error

data.NodeID = s.contact.Local().ID
data.Wallet = s.walletAddress
data.WalletFeatures = s.walletFeatures
data.Version = s.versionInfo.Version
data.StartedAt = s.startedAt

Expand Down
8 changes: 4 additions & 4 deletions storagenode/operator.go → storagenode/operator/operator.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.

package storagenode
package operator

import (
"fmt"
Expand All @@ -14,15 +14,15 @@ import (
"storj.io/storj/private/nodeoperator"
)

// OperatorConfig defines properties related to storage node operator metadata.
type OperatorConfig struct {
// Config defines properties related to storage node operator metadata.
type Config struct {
Email string `user:"true" help:"operator email address" default:""`
Wallet string `user:"true" help:"operator wallet address" default:""`
WalletFeatures WalletFeatures `user:"true" help:"operator wallet features" default:""`
}

// Verify verifies whether operator config is valid.
func (c OperatorConfig) Verify(log *zap.Logger) error {
func (c Config) Verify(log *zap.Logger) error {
if err := isOperatorEmailValid(log, c.Email); err != nil {
return err
}
Expand Down
4 changes: 3 additions & 1 deletion storagenode/peer.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import (
"storj.io/storj/storagenode/multinode"
"storj.io/storj/storagenode/nodestats"
"storj.io/storj/storagenode/notifications"
"storj.io/storj/storagenode/operator"
"storj.io/storj/storagenode/orders"
"storj.io/storj/storagenode/payouts"
"storj.io/storj/storagenode/payouts/estimatedpayouts"
Expand Down Expand Up @@ -104,7 +105,7 @@ type Config struct {

Preflight preflight.Config
Contact contact.Config
Operator OperatorConfig
Operator operator.Config

// TODO: flatten storage config and only keep the new one
Storage piecestore.OldConfig
Expand Down Expand Up @@ -653,6 +654,7 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, revocationDB exten
peer.Contact.Service,
peer.Estimation.Service,
peer.Storage2.BlobsCache,
config.Operator.WalletFeatures,
)
if err != nil {
return nil, errs.Combine(err, peer.Close())
Expand Down

0 comments on commit 034eb2c

Please sign in to comment.