storagenode: wallet features

WHAT: updated dashboard type to return wallet features from storagenode api

Change-Id: Ifdbdeae8b9ae239eaebe32d0a093557154f777ad
This commit is contained in:
NickolaiYurchenko 2021-03-17 20:47:23 +02:00 committed by Nikolay Yurchenko
parent 3e37d1e71c
commit 034eb2c214
4 changed files with 20 additions and 12 deletions

View File

@ -32,6 +32,7 @@ import (
"storj.io/storj/storagenode/gracefulexit" "storj.io/storj/storagenode/gracefulexit"
"storj.io/storj/storagenode/monitor" "storj.io/storj/storagenode/monitor"
"storj.io/storj/storagenode/nodestats" "storj.io/storj/storagenode/nodestats"
"storj.io/storj/storagenode/operator"
"storj.io/storj/storagenode/orders" "storj.io/storj/storagenode/orders"
"storj.io/storj/storagenode/pieces" "storj.io/storj/storagenode/pieces"
"storj.io/storj/storagenode/piecestore" "storj.io/storj/storagenode/piecestore"
@ -125,7 +126,7 @@ func (planet *Planet) newStorageNode(ctx context.Context, prefix string, index,
Preflight: preflight.Config{ Preflight: preflight.Config{
LocalTimeCheck: false, LocalTimeCheck: false,
}, },
Operator: storagenode.OperatorConfig{ Operator: operator.Config{
Email: prefix + "@mail.test", Email: prefix + "@mail.test",
Wallet: "0x" + strings.Repeat("00", 20), Wallet: "0x" + strings.Repeat("00", 20),
WalletFeatures: nil, WalletFeatures: nil,

View File

@ -19,6 +19,7 @@ import (
"storj.io/storj/private/version/checker" "storj.io/storj/private/version/checker"
"storj.io/storj/storagenode/bandwidth" "storj.io/storj/storagenode/bandwidth"
"storj.io/storj/storagenode/contact" "storj.io/storj/storagenode/contact"
"storj.io/storj/storagenode/operator"
"storj.io/storj/storagenode/payouts/estimatedpayouts" "storj.io/storj/storagenode/payouts/estimatedpayouts"
"storj.io/storj/storagenode/pieces" "storj.io/storj/storagenode/pieces"
"storj.io/storj/storagenode/pricing" "storj.io/storj/storagenode/pricing"
@ -56,16 +57,17 @@ type Service struct {
allocatedDiskSpace memory.Size allocatedDiskSpace memory.Size
walletAddress string walletAddress string
startedAt time.Time walletFeatures operator.WalletFeatures
versionInfo version.Info startedAt time.Time
versionInfo version.Info
} }
// NewService returns new instance of Service. // NewService returns new instance of Service.
func NewService(log *zap.Logger, bandwidth bandwidth.DB, pieceStore *pieces.Store, version *checker.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, allocatedDiskSpace memory.Size, walletAddress string, versionInfo version.Info, trust *trust.Pool,
reputationDB reputation.DB, storageUsageDB storageusage.DB, pricingDB pricing.DB, satelliteDB satellites.DB, 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 { if log == nil {
return nil, errs.New("log can't be nil") return nil, errs.New("log can't be nil")
} }
@ -116,6 +118,7 @@ func NewService(log *zap.Logger, bandwidth bandwidth.DB, pieceStore *pieces.Stor
walletAddress: walletAddress, walletAddress: walletAddress,
startedAt: time.Now(), startedAt: time.Now(),
versionInfo: versionInfo, versionInfo: versionInfo,
walletFeatures: walletFeatures,
}, nil }, nil
} }
@ -130,8 +133,9 @@ type SatelliteInfo struct {
// Dashboard encapsulates dashboard stale data. // Dashboard encapsulates dashboard stale data.
type Dashboard struct { type Dashboard struct {
NodeID storj.NodeID `json:"nodeID"` NodeID storj.NodeID `json:"nodeID"`
Wallet string `json:"wallet"` Wallet string `json:"wallet"`
WalletFeatures []string `json:"walletFeatures"`
Satellites []SatelliteInfo `json:"satellites"` Satellites []SatelliteInfo `json:"satellites"`
@ -154,6 +158,7 @@ func (s *Service) GetDashboardData(ctx context.Context) (_ *Dashboard, err error
data.NodeID = s.contact.Local().ID data.NodeID = s.contact.Local().ID
data.Wallet = s.walletAddress data.Wallet = s.walletAddress
data.WalletFeatures = s.walletFeatures
data.Version = s.versionInfo.Version data.Version = s.versionInfo.Version
data.StartedAt = s.startedAt data.StartedAt = s.startedAt

View File

@ -1,7 +1,7 @@
// Copyright (C) 2019 Storj Labs, Inc. // Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information. // See LICENSE for copying information.
package storagenode package operator
import ( import (
"fmt" "fmt"
@ -14,15 +14,15 @@ import (
"storj.io/storj/private/nodeoperator" "storj.io/storj/private/nodeoperator"
) )
// OperatorConfig defines properties related to storage node operator metadata. // Config defines properties related to storage node operator metadata.
type OperatorConfig struct { type Config struct {
Email string `user:"true" help:"operator email address" default:""` Email string `user:"true" help:"operator email address" default:""`
Wallet string `user:"true" help:"operator wallet address" default:""` Wallet string `user:"true" help:"operator wallet address" default:""`
WalletFeatures WalletFeatures `user:"true" help:"operator wallet features" default:""` WalletFeatures WalletFeatures `user:"true" help:"operator wallet features" default:""`
} }
// Verify verifies whether operator config is valid. // 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 { if err := isOperatorEmailValid(log, c.Email); err != nil {
return err return err
} }

View File

@ -46,6 +46,7 @@ import (
"storj.io/storj/storagenode/multinode" "storj.io/storj/storagenode/multinode"
"storj.io/storj/storagenode/nodestats" "storj.io/storj/storagenode/nodestats"
"storj.io/storj/storagenode/notifications" "storj.io/storj/storagenode/notifications"
"storj.io/storj/storagenode/operator"
"storj.io/storj/storagenode/orders" "storj.io/storj/storagenode/orders"
"storj.io/storj/storagenode/payouts" "storj.io/storj/storagenode/payouts"
"storj.io/storj/storagenode/payouts/estimatedpayouts" "storj.io/storj/storagenode/payouts/estimatedpayouts"
@ -104,7 +105,7 @@ type Config struct {
Preflight preflight.Config Preflight preflight.Config
Contact contact.Config Contact contact.Config
Operator OperatorConfig Operator operator.Config
// TODO: flatten storage config and only keep the new one // TODO: flatten storage config and only keep the new one
Storage piecestore.OldConfig Storage piecestore.OldConfig
@ -653,6 +654,7 @@ func New(log *zap.Logger, full *identity.FullIdentity, db DB, revocationDB exten
peer.Contact.Service, peer.Contact.Service,
peer.Estimation.Service, peer.Estimation.Service,
peer.Storage2.BlobsCache, peer.Storage2.BlobsCache,
config.Operator.WalletFeatures,
) )
if err != nil { if err != nil {
return nil, errs.Combine(err, peer.Close()) return nil, errs.Combine(err, peer.Close())