From 034eb2c2146686e521b34ac88d5eaa5366ee5709 Mon Sep 17 00:00:00 2001 From: NickolaiYurchenko Date: Wed, 17 Mar 2021 20:47:23 +0200 Subject: [PATCH] storagenode: wallet features WHAT: updated dashboard type to return wallet features from storagenode api Change-Id: Ifdbdeae8b9ae239eaebe32d0a093557154f777ad --- private/testplanet/storagenode.go | 3 ++- storagenode/console/service.go | 17 +++++++++++------ storagenode/{ => operator}/operator.go | 8 ++++---- storagenode/peer.go | 4 +++- 4 files changed, 20 insertions(+), 12 deletions(-) rename storagenode/{ => operator}/operator.go (92%) diff --git a/private/testplanet/storagenode.go b/private/testplanet/storagenode.go index 68d691845..0be40c85e 100644 --- a/private/testplanet/storagenode.go +++ b/private/testplanet/storagenode.go @@ -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" @@ -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, diff --git a/storagenode/console/service.go b/storagenode/console/service.go index bf36b1a01..dafdcaab1 100644 --- a/storagenode/console/service.go +++ b/storagenode/console/service.go @@ -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" @@ -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") } @@ -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 } @@ -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"` @@ -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 diff --git a/storagenode/operator.go b/storagenode/operator/operator.go similarity index 92% rename from storagenode/operator.go rename to storagenode/operator/operator.go index 147f6f8a0..17fbbfeb8 100644 --- a/storagenode/operator.go +++ b/storagenode/operator/operator.go @@ -1,7 +1,7 @@ // Copyright (C) 2019 Storj Labs, Inc. // See LICENSE for copying information. -package storagenode +package operator import ( "fmt" @@ -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 } diff --git a/storagenode/peer.go b/storagenode/peer.go index 9bc218080..e0358e811 100644 --- a/storagenode/peer.go +++ b/storagenode/peer.go @@ -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" @@ -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 @@ -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())