From 494bd5db81bc69d78022a8edf37673181dc4b114 Mon Sep 17 00:00:00 2001 From: Stefan Benten Date: Sat, 5 Dec 2020 17:01:42 +0100 Subject: [PATCH] all: golangci-lint v1.33.0 fixes (#3985) --- private/cui/screen.go | 2 +- private/version/checker/service.go | 2 +- satellite/accounting/db.go | 4 +-- satellite/accounting/rollup/rollup.go | 2 +- satellite/accounting/tally/tally.go | 2 +- satellite/admin.go | 2 +- satellite/api.go | 2 +- satellite/attribution/db.go | 2 +- satellite/audit/containment.go | 2 +- satellite/audit/disqualification_test.go | 6 ++-- satellite/audit/pathcollector.go | 2 +- satellite/audit/reporter.go | 2 +- satellite/audit/verifier.go | 2 +- satellite/console/apikeys.go | 2 +- satellite/console/consoleweb/server.go | 2 +- satellite/console/registrationtoken.go | 2 +- satellite/console/resetpasswordtoken.go | 2 +- satellite/console/service.go | 2 +- satellite/console/usercredits.go | 2 +- satellite/core.go | 2 +- satellite/gc.go | 2 +- satellite/gc/piecetracker.go | 2 +- satellite/gc/service.go | 3 +- satellite/gracefulexit/db.go | 2 +- satellite/gracefulexit/pathcollector.go | 2 +- satellite/inspector/inspector.go | 2 +- satellite/mailservice/service.go | 4 +-- satellite/mailservice/simulate/linkclicker.go | 3 +- satellite/marketingweb/server.go | 2 +- satellite/metainfo/db.go | 2 +- satellite/metainfo/expireddeletion/chore.go | 2 +- .../expireddeletion/expireddeleter.go | 2 +- satellite/metainfo/loop_test.go | 2 +- satellite/metainfo/objectdeletion/service.go | 2 +- satellite/metainfo/service.go | 2 +- satellite/nodestats/endpoint.go | 2 +- satellite/orders/endpoint.go | 13 ++++--- satellite/overlay/inspector.go | 2 +- satellite/overlay/nodeselectioncache.go | 2 +- satellite/overlay/peeridentities.go | 2 +- satellite/overlay/service.go | 4 +-- satellite/peer.go | 2 +- satellite/referrals/service.go | 2 +- satellite/repair/checker/checker.go | 4 +-- satellite/repair/irreparable/inspector.go | 2 +- satellite/repair/repair_test.go | 35 +++++++++---------- satellite/repair/repairer/repairer.go | 2 +- satellite/rewards/rewards.go | 2 +- satellite/satellitedb/nodeselection.go | 19 ++++++---- satellite/snopayout/endpoint.go | 2 +- satellite/snopayout/payout.go | 2 +- storagenode/bandwidth/service.go | 2 +- storagenode/contact/chore.go | 2 +- storagenode/contact/endpoint.go | 2 +- storagenode/inspector/inspector.go | 2 +- storagenode/monitor/monitor.go | 2 +- storagenode/nodestats/cache.go | 10 +++--- storagenode/nodestats/service.go | 4 +-- storagenode/payout/payout.go | 2 +- storagenode/payout/service.go | 2 +- storagenode/peer.go | 2 +- storagenode/pieces/cache.go | 5 +-- storagenode/pieces/store.go | 25 ++++++++----- storagenode/pricing/pricing.go | 2 +- storagenode/reputation/reputation.go | 2 +- storagenode/satellites/satellites.go | 2 +- storagenode/storageusage/storageusage.go | 2 +- 67 files changed, 132 insertions(+), 113 deletions(-) diff --git a/private/cui/screen.go b/private/cui/screen.go index ec2417ebf..060e875db 100644 --- a/private/cui/screen.go +++ b/private/cui/screen.go @@ -17,7 +17,7 @@ var initialized = false const padding = 2 -// Point is a 2D coordinate in console +// Point is a 2D coordinate in console. // X is the column // Y is the row type Point struct{ X, Y int } diff --git a/private/version/checker/service.go b/private/version/checker/service.go index d27847f01..f5fb73725 100644 --- a/private/version/checker/service.go +++ b/private/version/checker/service.go @@ -22,7 +22,7 @@ type Config struct { CheckInterval time.Duration `help:"Interval to check the version" default:"0h15m0s"` } -// Service contains the information and variables to ensure the Software is up to date +// Service contains the information and variables to ensure the Software is up to date. // // architecture: Service type Service struct { diff --git a/satellite/accounting/db.go b/satellite/accounting/db.go index dee5134af..83df7597d 100644 --- a/satellite/accounting/db.go +++ b/satellite/accounting/db.go @@ -138,7 +138,7 @@ type BucketUsageRollup struct { Before time.Time } -// StoragenodeAccounting stores information about bandwidth and storage usage for storage nodes +// StoragenodeAccounting stores information about bandwidth and storage usage for storage nodes. // // architecture: Database type StoragenodeAccounting interface { @@ -164,7 +164,7 @@ type StoragenodeAccounting interface { DeleteTalliesBefore(ctx context.Context, latestRollup time.Time) error } -// ProjectAccounting stores information about bandwidth and storage usage for projects +// ProjectAccounting stores information about bandwidth and storage usage for projects. // // architecture: Database type ProjectAccounting interface { diff --git a/satellite/accounting/rollup/rollup.go b/satellite/accounting/rollup/rollup.go index cd129161e..a882e846c 100644 --- a/satellite/accounting/rollup/rollup.go +++ b/satellite/accounting/rollup/rollup.go @@ -21,7 +21,7 @@ type Config struct { DeleteTallies bool `help:"option for deleting tallies after they are rolled up" default:"true"` } -// Service is the rollup service for totalling data on storage nodes on daily intervals +// Service is the rollup service for totalling data on storage nodes on daily intervals. // // architecture: Chore type Service struct { diff --git a/satellite/accounting/tally/tally.go b/satellite/accounting/tally/tally.go index 080285fcc..c9ee70c55 100644 --- a/satellite/accounting/tally/tally.go +++ b/satellite/accounting/tally/tally.go @@ -32,7 +32,7 @@ type Config struct { ReadRollupBatchSize int `help:"how large of batches GetBandwidthSince should process at a time" default:"10000"` } -// Service is the tally service for data stored on each storage node +// Service is the tally service for data stored on each storage node. // // architecture: Chore type Service struct { diff --git a/satellite/admin.go b/satellite/admin.go index f7491700e..5ff18b899 100644 --- a/satellite/admin.go +++ b/satellite/admin.go @@ -24,7 +24,7 @@ import ( "storj.io/storj/satellite/payments/stripecoinpayments" ) -// Admin is the satellite core process that runs chores +// Admin is the satellite core process that runs chores. // // architecture: Peer type Admin struct { diff --git a/satellite/api.go b/satellite/api.go index fda6f162c..f584b74d1 100644 --- a/satellite/api.go +++ b/satellite/api.go @@ -54,7 +54,7 @@ import ( "storj.io/storj/satellite/snopayout" ) -// API is the satellite API process +// API is the satellite API process. // // architecture: Peer type API struct { diff --git a/satellite/attribution/db.go b/satellite/attribution/db.go index de8449eaf..3876ec1e1 100644 --- a/satellite/attribution/db.go +++ b/satellite/attribution/db.go @@ -34,7 +34,7 @@ type CSVRow struct { EgressData int64 } -// DB implements the database for value attribution table +// DB implements the database for value attribution table. // // architecture: Database type DB interface { diff --git a/satellite/audit/containment.go b/satellite/audit/containment.go index 4ccc9b44b..ae18afd27 100644 --- a/satellite/audit/containment.go +++ b/satellite/audit/containment.go @@ -34,7 +34,7 @@ type PendingAudit struct { Path storj.Path } -// Containment holds information about pending audits for contained nodes +// Containment holds information about pending audits for contained nodes. // // architecture: Database type Containment interface { diff --git a/satellite/audit/disqualification_test.go b/satellite/audit/disqualification_test.go index 71500108b..dfb044412 100644 --- a/satellite/audit/disqualification_test.go +++ b/satellite/audit/disqualification_test.go @@ -25,9 +25,9 @@ import ( ) // TestDisqualificationTooManyFailedAudits does the following: -// * Create a failed audit report for a storagenode -// * Record the audit report several times and check that the node isn't -// disqualified until the audit reputation reaches the cut-off value. +// - Create a failed audit report for a storagenode +// - Record the audit report several times and check that the node isn't +// disqualified until the audit reputation reaches the cut-off value. func TestDisqualificationTooManyFailedAudits(t *testing.T) { var ( auditDQCutOff = 0.4 diff --git a/satellite/audit/pathcollector.go b/satellite/audit/pathcollector.go index 66b4e544e..9c511bcb5 100644 --- a/satellite/audit/pathcollector.go +++ b/satellite/audit/pathcollector.go @@ -13,7 +13,7 @@ import ( var _ metainfo.Observer = (*PathCollector)(nil) -// PathCollector uses the metainfo loop to add paths to node reservoirs +// PathCollector uses the metainfo loop to add paths to node reservoirs. // // architecture: Observer type PathCollector struct { diff --git a/satellite/audit/reporter.go b/satellite/audit/reporter.go index 15331a1f9..70c5d839a 100644 --- a/satellite/audit/reporter.go +++ b/satellite/audit/reporter.go @@ -13,7 +13,7 @@ import ( "storj.io/storj/satellite/overlay" ) -// Reporter records audit reports in overlay and implements the reporter interface +// Reporter records audit reports in overlay and implements the reporter interface. // // architecture: Service type Reporter struct { diff --git a/satellite/audit/verifier.go b/satellite/audit/verifier.go index 3b6e41010..f95d2ef1c 100644 --- a/satellite/audit/verifier.go +++ b/satellite/audit/verifier.go @@ -50,7 +50,7 @@ type Share struct { Data []byte } -// Verifier helps verify the correctness of a given stripe +// Verifier helps verify the correctness of a given stripe. // // architecture: Worker type Verifier struct { diff --git a/satellite/console/apikeys.go b/satellite/console/apikeys.go index 7d1d0c6a6..166efa4f4 100644 --- a/satellite/console/apikeys.go +++ b/satellite/console/apikeys.go @@ -10,7 +10,7 @@ import ( "storj.io/common/uuid" ) -// APIKeys is interface for working with api keys store +// APIKeys is interface for working with api keys store. // // architecture: Database type APIKeys interface { diff --git a/satellite/console/consoleweb/server.go b/satellite/console/consoleweb/server.go index c1210b452..321d5f3c6 100644 --- a/satellite/console/consoleweb/server.go +++ b/satellite/console/consoleweb/server.go @@ -87,7 +87,7 @@ type Config struct { console.Config } -// Server represents console web server +// Server represents console web server. // // architecture: Endpoint type Server struct { diff --git a/satellite/console/registrationtoken.go b/satellite/console/registrationtoken.go index 2e149dac0..436e06b26 100644 --- a/satellite/console/registrationtoken.go +++ b/satellite/console/registrationtoken.go @@ -15,7 +15,7 @@ import ( "storj.io/common/uuid" ) -// RegistrationTokens is interface for working with registration tokens +// RegistrationTokens is interface for working with registration tokens. // // architecture: Database type RegistrationTokens interface { diff --git a/satellite/console/resetpasswordtoken.go b/satellite/console/resetpasswordtoken.go index 9f1bc612b..be97da965 100644 --- a/satellite/console/resetpasswordtoken.go +++ b/satellite/console/resetpasswordtoken.go @@ -14,7 +14,7 @@ import ( "storj.io/common/uuid" ) -// ResetPasswordTokens is interface for working with reset password tokens +// ResetPasswordTokens is interface for working with reset password tokens. // // architecture: Database type ResetPasswordTokens interface { diff --git a/satellite/console/service.go b/satellite/console/service.go index cc97ffc61..d30fe7015 100644 --- a/satellite/console/service.go +++ b/satellite/console/service.go @@ -76,7 +76,7 @@ var ( ErrEmailUsed = errs.Class("email used") ) -// Service is handling accounts related logic +// Service is handling accounts related logic. // // architecture: Service type Service struct { diff --git a/satellite/console/usercredits.go b/satellite/console/usercredits.go index da9d3ba56..1d329434f 100644 --- a/satellite/console/usercredits.go +++ b/satellite/console/usercredits.go @@ -17,7 +17,7 @@ import ( // NoCreditForUpdateErr is a error message used when no credits are found for update when new users sign up. var NoCreditForUpdateErr = errs.Class("no credit found to update") -// UserCredits holds information to interact with database +// UserCredits holds information to interact with database. // // architecture: Database type UserCredits interface { diff --git a/satellite/core.go b/satellite/core.go index 342dbb56b..68b743f15 100644 --- a/satellite/core.go +++ b/satellite/core.go @@ -44,7 +44,7 @@ import ( "storj.io/storj/satellite/repair/checker" ) -// Core is the satellite core process that runs chores +// Core is the satellite core process that runs chores. // // architecture: Peer type Core struct { diff --git a/satellite/gc.go b/satellite/gc.go index c8b2e3248..5438a3bcc 100644 --- a/satellite/gc.go +++ b/satellite/gc.go @@ -28,7 +28,7 @@ import ( "storj.io/storj/satellite/overlay" ) -// GarbageCollection is the satellite garbage collection process +// GarbageCollection is the satellite garbage collection process. // // architecture: Peer type GarbageCollection struct { diff --git a/satellite/gc/piecetracker.go b/satellite/gc/piecetracker.go index 29f4f874f..c7b2be5e9 100644 --- a/satellite/gc/piecetracker.go +++ b/satellite/gc/piecetracker.go @@ -17,7 +17,7 @@ import ( var _ metainfo.Observer = (*PieceTracker)(nil) -// PieceTracker implements the metainfo loop observer interface for garbage collection +// PieceTracker implements the metainfo loop observer interface for garbage collection. // // architecture: Observer type PieceTracker struct { diff --git a/satellite/gc/service.go b/satellite/gc/service.go index da4208c64..17c26e474 100644 --- a/satellite/gc/service.go +++ b/satellite/gc/service.go @@ -33,6 +33,7 @@ type Config struct { Enabled bool `help:"set if garbage collection is enabled or not" releaseDefault:"true" devDefault:"true"` SkipFirst bool `help:"if true, skip the first run of GC" releaseDefault:"true" devDefault:"false"` RunInCore bool `help:"if true, run garbage collection as part of the core" releaseDefault:"false" devDefault:"false"` + // value for InitialPieces currently based on average pieces per node InitialPieces int `help:"the initial number of pieces expected for a storage node to have, used for creating a filter" releaseDefault:"400000" devDefault:"10"` FalsePositiveRate float64 `help:"the false positive rate used for creating a garbage collection bloom filter" releaseDefault:"0.1" devDefault:"0.1"` @@ -40,7 +41,7 @@ type Config struct { RetainSendTimeout time.Duration `help:"the amount of time to allow a node to handle a retain request" default:"1m"` } -// Service implements the garbage collection service +// Service implements the garbage collection service. // // architecture: Chore type Service struct { diff --git a/satellite/gracefulexit/db.go b/satellite/gracefulexit/db.go index 351ed33aa..0f65dc83e 100644 --- a/satellite/gracefulexit/db.go +++ b/satellite/gracefulexit/db.go @@ -36,7 +36,7 @@ type TransferQueueItem struct { OrderLimitSendCount int } -// DB implements CRUD operations for graceful exit service +// DB implements CRUD operations for graceful exit service. // // architecture: Database type DB interface { diff --git a/satellite/gracefulexit/pathcollector.go b/satellite/gracefulexit/pathcollector.go index 2a7cd90a1..7fe8c1b92 100644 --- a/satellite/gracefulexit/pathcollector.go +++ b/satellite/gracefulexit/pathcollector.go @@ -17,7 +17,7 @@ import ( var _ metainfo.Observer = (*PathCollector)(nil) -// PathCollector uses the metainfo loop to add paths to node reservoirs +// PathCollector uses the metainfo loop to add paths to node reservoirs. // // architecture: Observer type PathCollector struct { diff --git a/satellite/inspector/inspector.go b/satellite/inspector/inspector.go index 3c819d950..5ebe7c278 100644 --- a/satellite/inspector/inspector.go +++ b/satellite/inspector/inspector.go @@ -27,7 +27,7 @@ var ( const lastSegmentIndex = int64(-1) -// Endpoint for checking object and segment health +// Endpoint for checking object and segment health. // // architecture: Endpoint type Endpoint struct { diff --git a/satellite/mailservice/service.go b/satellite/mailservice/service.go index 577c519b8..5141da44c 100644 --- a/satellite/mailservice/service.go +++ b/satellite/mailservice/service.go @@ -34,7 +34,7 @@ var ( mon = monkit.Package() ) -// Sender sends emails +// Sender sends emails. // // architecture: Service type Sender interface { @@ -48,7 +48,7 @@ type Message interface { Subject() string } -// Service sends template-backed email messages through SMTP +// Service sends template-backed email messages through SMTP. // // architecture: Service type Service struct { diff --git a/satellite/mailservice/simulate/linkclicker.go b/satellite/mailservice/simulate/linkclicker.go index b63ac4967..d69e4c8e1 100644 --- a/satellite/mailservice/simulate/linkclicker.go +++ b/satellite/mailservice/simulate/linkclicker.go @@ -20,8 +20,7 @@ var mon = monkit.Package() var _ mailservice.Sender = (*LinkClicker)(nil) -// LinkClicker is mailservice.Sender that click all links -// from html msg parts +// LinkClicker is mailservice.Sender that click all links from html msg parts. // // architecture: Service type LinkClicker struct{} diff --git a/satellite/marketingweb/server.go b/satellite/marketingweb/server.go index 95cdccc2f..fe52a5dae 100644 --- a/satellite/marketingweb/server.go +++ b/satellite/marketingweb/server.go @@ -31,7 +31,7 @@ type Config struct { StaticDir string `help:"path to static resources" default:""` } -// Server represents marketing offersweb server +// Server represents marketing offersweb server. // // architecture: Endpoint type Server struct { diff --git a/satellite/metainfo/db.go b/satellite/metainfo/db.go index 3891dba09..140db2e01 100644 --- a/satellite/metainfo/db.go +++ b/satellite/metainfo/db.go @@ -12,7 +12,7 @@ import ( "storj.io/storj/satellite/metainfo/metabase" ) -// BucketsDB is the interface for the database to interact with buckets +// BucketsDB is the interface for the database to interact with buckets. // // architecture: Database type BucketsDB interface { diff --git a/satellite/metainfo/expireddeletion/chore.go b/satellite/metainfo/expireddeletion/chore.go index 46df1194c..f9f2a54de 100644 --- a/satellite/metainfo/expireddeletion/chore.go +++ b/satellite/metainfo/expireddeletion/chore.go @@ -27,7 +27,7 @@ type Config struct { Enabled bool `help:"set if expired segment cleanup is enabled or not" releaseDefault:"true" devDefault:"true"` } -// Chore implements the expired segment cleanup chore +// Chore implements the expired segment cleanup chore. // // architecture: Chore type Chore struct { diff --git a/satellite/metainfo/expireddeletion/expireddeleter.go b/satellite/metainfo/expireddeletion/expireddeleter.go index 2d10d2b53..150b59ec2 100644 --- a/satellite/metainfo/expireddeletion/expireddeleter.go +++ b/satellite/metainfo/expireddeletion/expireddeleter.go @@ -17,7 +17,7 @@ import ( var _ metainfo.Observer = (*expiredDeleter)(nil) -// expiredDeleter implements the metainfo loop observer interface for expired segment cleanup +// expiredDeleter implements the metainfo loop observer interface for expired segment cleanup. // // architecture: Observer type expiredDeleter struct { diff --git a/satellite/metainfo/loop_test.go b/satellite/metainfo/loop_test.go index a7c93b45f..2a145ec1d 100644 --- a/satellite/metainfo/loop_test.go +++ b/satellite/metainfo/loop_test.go @@ -33,7 +33,7 @@ import ( // * upload 2 inline files // * connect two observers to the metainfo loop // * run the metainfo loop -// * expect that each observer has seen +// * expect that each observer has seen: // - 5 remote files // - 5 remote segments // - 2 inline files/segments diff --git a/satellite/metainfo/objectdeletion/service.go b/satellite/metainfo/objectdeletion/service.go index b13cb015a..3ac589875 100644 --- a/satellite/metainfo/objectdeletion/service.go +++ b/satellite/metainfo/objectdeletion/service.go @@ -54,7 +54,7 @@ type PointerDB interface { UnsynchronizedGetDel(ctx context.Context, keys []metabase.SegmentKey) (deletedKeys []metabase.SegmentKey, _ []*pb.Pointer, _ error) } -// Service implements the object deletion service +// Service implements the object deletion service. // // architecture: Service type Service struct { diff --git a/satellite/metainfo/service.go b/satellite/metainfo/service.go index 935727bed..f1fdec0e4 100644 --- a/satellite/metainfo/service.go +++ b/satellite/metainfo/service.go @@ -24,7 +24,7 @@ var ( ErrBucketNotEmpty = errs.Class("bucket not empty") ) -// Service structure +// Service provides the metainfo service dependencies. // // architecture: Service type Service struct { diff --git a/satellite/nodestats/endpoint.go b/satellite/nodestats/endpoint.go index 403f74868..7680fd07a 100644 --- a/satellite/nodestats/endpoint.go +++ b/satellite/nodestats/endpoint.go @@ -21,7 +21,7 @@ var ( mon = monkit.Package() ) -// Endpoint for querying node stats for the SNO +// Endpoint for querying node stats for the SNO. // // architecture: Endpoint type Endpoint struct { diff --git a/satellite/orders/endpoint.go b/satellite/orders/endpoint.go index 56c29170a..f8100a044 100644 --- a/satellite/orders/endpoint.go +++ b/satellite/orders/endpoint.go @@ -26,7 +26,7 @@ import ( "storj.io/storj/satellite/nodeapiversion" ) -// DB implements saving order after receiving from storage node +// DB implements saving order after receiving from storage node. // // architecture: Database type DB interface { @@ -200,7 +200,7 @@ type ProcessOrderResponse struct { Status pb.SettlementResponse_Status } -// Endpoint for orders receiving +// Endpoint for orders receiving. // // architecture: Endpoint type Endpoint struct { @@ -218,7 +218,10 @@ type Endpoint struct { // // ordersSemaphoreSize controls the number of concurrent clients allowed to submit orders at once. // A value of zero means unlimited. -func NewEndpoint(log *zap.Logger, satelliteSignee signing.Signee, db DB, nodeAPIVersionDB nodeapiversion.DB, settlementBatchSize int, windowEndpointRolloutPhase WindowEndpointRolloutPhase, ordersSemaphoreSize int, ordersService *Service) *Endpoint { +func NewEndpoint(log *zap.Logger, satelliteSignee signing.Signee, db DB, nodeAPIVersionDB nodeapiversion.DB, + settlementBatchSize int, windowEndpointRolloutPhase WindowEndpointRolloutPhase, + ordersSemaphoreSize int, ordersService *Service) *Endpoint { + var ordersSemaphore chan struct{} if ordersSemaphoreSize > 0 { ordersSemaphore = make(chan struct{}, ordersSemaphoreSize) @@ -737,7 +740,9 @@ func (endpoint *Endpoint) SettlementWithWindowFinal(stream pb.DRPCOrders_Settlem }) } -func (endpoint *Endpoint) isValid(ctx context.Context, log *zap.Logger, order *pb.Order, orderLimit *pb.OrderLimit, peerID storj.NodeID, window int64) bool { +func (endpoint *Endpoint) isValid(ctx context.Context, log *zap.Logger, order *pb.Order, + orderLimit *pb.OrderLimit, peerID storj.NodeID, window int64) bool { + if orderLimit.StorageNodeId != peerID { log.Debug("storage node id mismatch") mon.Event("order_not_valid_storagenodeid") diff --git a/satellite/overlay/inspector.go b/satellite/overlay/inspector.go index ed5c808b2..eb41d3917 100644 --- a/satellite/overlay/inspector.go +++ b/satellite/overlay/inspector.go @@ -11,7 +11,7 @@ import ( "storj.io/storj/satellite/internalpb" ) -// Inspector is a RPC service for inspecting overlay internals +// Inspector is a RPC service for inspecting overlay internals. // // architecture: Endpoint type Inspector struct { diff --git a/satellite/overlay/nodeselectioncache.go b/satellite/overlay/nodeselectioncache.go index 7e7be81fe..30bfaa9a8 100644 --- a/satellite/overlay/nodeselectioncache.go +++ b/satellite/overlay/nodeselectioncache.go @@ -15,7 +15,7 @@ import ( "storj.io/storj/satellite/nodeselection" ) -// CacheDB implements the database for overlay node selection cache +// CacheDB implements the database for overlay node selection cache. // // architecture: Database type CacheDB interface { diff --git a/satellite/overlay/peeridentities.go b/satellite/overlay/peeridentities.go index 1bb6d68f0..0e10ed3db 100644 --- a/satellite/overlay/peeridentities.go +++ b/satellite/overlay/peeridentities.go @@ -10,7 +10,7 @@ import ( "storj.io/common/storj" ) -// PeerIdentities stores storagenode peer identities +// PeerIdentities stores storagenode peer identities. // // architecture: Database type PeerIdentities interface { diff --git a/satellite/overlay/service.go b/satellite/overlay/service.go index 3d95d1b9d..3de10cd15 100644 --- a/satellite/overlay/service.go +++ b/satellite/overlay/service.go @@ -36,7 +36,7 @@ var ErrNodeFinishedGE = errs.Class("node finished graceful exit") // ErrNotEnoughNodes is when selecting nodes failed with the given parameters. var ErrNotEnoughNodes = errs.Class("not enough nodes") -// DB implements the database for overlay.Service +// DB implements the database for overlay.Service. // // architecture: Database type DB interface { @@ -265,7 +265,7 @@ func (node *SelectedNode) Clone() *SelectedNode { } } -// Service is used to store and handle node information +// Service is used to store and handle node information. // // architecture: Service type Service struct { diff --git a/satellite/peer.go b/satellite/peer.go index 478f79ef0..42bba06ca 100644 --- a/satellite/peer.go +++ b/satellite/peer.go @@ -55,7 +55,7 @@ func init() { hw.Register(monkit.Default) } -// DB is the master database for the satellite +// DB is the master database for the satellite. // // architecture: Master Database type DB interface { diff --git a/satellite/referrals/service.go b/satellite/referrals/service.go index a0642d1a9..c17b886a4 100644 --- a/satellite/referrals/service.go +++ b/satellite/referrals/service.go @@ -31,7 +31,7 @@ type Config struct { ReferralManagerURL storj.NodeURL `help:"the URL for referral manager"` } -// Service allows communicating with the Referral Manager +// Service allows communicating with the Referral Manager. // // architecture: Service type Service struct { diff --git a/satellite/repair/checker/checker.go b/satellite/repair/checker/checker.go index 461df572f..993b8f6d3 100644 --- a/satellite/repair/checker/checker.go +++ b/satellite/repair/checker/checker.go @@ -43,7 +43,7 @@ type durabilityStats struct { remoteSegmentsOverThreshold [5]int64 } -// Checker contains the information needed to do checks for missing pieces +// Checker contains the information needed to do checks for missing pieces. // // architecture: Chore type Checker struct { @@ -243,7 +243,7 @@ func (checker *Checker) updateIrreparableSegmentStatus(ctx context.Context, poin var _ metainfo.Observer = (*checkerObserver)(nil) -// checkerObserver implements the metainfo loop Observer interface +// checkerObserver implements the metainfo loop Observer interface. // // architecture: Observer type checkerObserver struct { diff --git a/satellite/repair/irreparable/inspector.go b/satellite/repair/irreparable/inspector.go index 38331e318..de81f7f3b 100644 --- a/satellite/repair/irreparable/inspector.go +++ b/satellite/repair/irreparable/inspector.go @@ -15,7 +15,7 @@ var ( mon = monkit.Package() ) -// Inspector is a RPC service for inspecting irreparable internals +// Inspector is a RPC service for inspecting irreparable internals. // // architecture: Endpoint type Inspector struct { diff --git a/satellite/repair/repair_test.go b/satellite/repair/repair_test.go index bfc94415f..568b80011 100644 --- a/satellite/repair/repair_test.go +++ b/satellite/repair/repair_test.go @@ -33,8 +33,7 @@ import ( // the numbers of nodes determined by the upload repair max threshold // - Shuts down several nodes, but keeping up a number equal to the minim // threshold -// - Downloads the data from those left nodes and check that it's the same than -// the uploaded one +// - Downloads the data from those left nodes and check that it's the same than the uploaded one. func TestDataRepairInMemory(t *testing.T) { testDataRepair(t, true) } @@ -894,10 +893,10 @@ func testRepairMultipleDisqualifiedAndSuspended(t *testing.T, inMemoryRepair boo } // TestDataRepairOverride_HigherLimit does the following: -// - Uploads test data -// - Kills nodes to fall to the Repair Override Value of the checker but stays above the original Repair Threshold -// - Triggers data repair, which attempts to repair the data from the remaining nodes to -// the numbers of nodes determined by the upload repair max threshold +// - Uploads test data +// - Kills nodes to fall to the Repair Override Value of the checker but stays above the original Repair Threshold +// - Triggers data repair, which attempts to repair the data from the remaining nodes to +// the numbers of nodes determined by the upload repair max threshold func TestDataRepairOverride_HigherLimitInMemory(t *testing.T) { testDataRepairOverrideHigherLimit(t, true) } @@ -988,12 +987,12 @@ func testDataRepairOverrideHigherLimit(t *testing.T, inMemoryRepair bool) { } // TestDataRepairOverride_LowerLimit does the following: -// - Uploads test data -// - Kills nodes to fall to the Repair Threshold of the checker that should not trigger repair any longer -// - Starts Checker and Repairer and ensures this is the case. -// - Kills more nodes to fall to the Override Value to trigger repair -// - Triggers data repair, which attempts to repair the data from the remaining nodes to -// the numbers of nodes determined by the upload repair max threshold +// - Uploads test data +// - Kills nodes to fall to the Repair Threshold of the checker that should not trigger repair any longer +// - Starts Checker and Repairer and ensures this is the case. +// - Kills more nodes to fall to the Override Value to trigger repair +// - Triggers data repair, which attempts to repair the data from the remaining nodes to +// the numbers of nodes determined by the upload repair max threshold func TestDataRepairOverride_LowerLimitInMemory(t *testing.T) { testDataRepairOverrideLowerLimit(t, true) } @@ -1112,12 +1111,12 @@ func testDataRepairOverrideLowerLimit(t *testing.T, inMemoryRepair bool) { } // TestDataRepairUploadLimits does the following: -// - Uploads test data to nodes -// - Get one segment of that data to check in which nodes its pieces are stored -// - Kills as many nodes as needed which store such segment pieces -// - Triggers data repair -// - Verify that the number of pieces which repaired has uploaded don't overpass -// the established limit (success threshold + % of excess) +// - Uploads test data to nodes +// - Get one segment of that data to check in which nodes its pieces are stored +// - Kills as many nodes as needed which store such segment pieces +// - Triggers data repair +// - Verify that the number of pieces which repaired has uploaded don't overpass +// the established limit (success threshold + % of excess) func TestDataRepairUploadLimitInMemory(t *testing.T) { testDataRepairUploadLimit(t, true) } diff --git a/satellite/repair/repairer/repairer.go b/satellite/repair/repairer/repairer.go index 356e53bd7..b24637cad 100644 --- a/satellite/repair/repairer/repairer.go +++ b/satellite/repair/repairer/repairer.go @@ -38,7 +38,7 @@ type Config struct { InMemoryRepair bool `help:"whether to download pieces for repair in memory (true) or download to disk (false)" default:"false"` } -// Service contains the information needed to run the repair service +// Service contains the information needed to run the repair service. // // architecture: Worker type Service struct { diff --git a/satellite/rewards/rewards.go b/satellite/rewards/rewards.go index 96cc28d66..09496976d 100644 --- a/satellite/rewards/rewards.go +++ b/satellite/rewards/rewards.go @@ -19,7 +19,7 @@ var ( ErrOfferNotExist = errs.Class("no current offer") ) -// DB holds information about offer +// DB holds information about offers. // // architecture: Database type DB interface { diff --git a/satellite/satellitedb/nodeselection.go b/satellite/satellitedb/nodeselection.go index 7d7a5d0a1..41ac4a71c 100644 --- a/satellite/satellitedb/nodeselection.go +++ b/satellite/satellitedb/nodeselection.go @@ -90,7 +90,10 @@ func (cache *overlaycache) SelectStorageNodes(ctx context.Context, totalNeededNo return nodes, nil } -func (cache *overlaycache) selectStorageNodesOnce(ctx context.Context, reputableNodeCount, newNodeCount int, criteria *overlay.NodeCriteria, excludedIDs []storj.NodeID, excludedNetworks []string) (reputableNodes, newNodes []*overlay.SelectedNode, err error) { +func (cache *overlaycache) selectStorageNodesOnce(ctx context.Context, reputableNodeCount, newNodeCount int, + criteria *overlay.NodeCriteria, excludedIDs []storj.NodeID, + excludedNetworks []string) (reputableNodes, newNodes []*overlay.SelectedNode, err error) { + defer mon.Task()(&ctx)(&err) newNodesCondition, err := nodeSelectionCondition(ctx, criteria, excludedIDs, excludedNetworks, true) @@ -171,7 +174,9 @@ func (cache *overlaycache) selectStorageNodesOnce(ctx context.Context, reputable } // nodeSelectionCondition creates a condition with arguments that corresponds to the arguments. -func nodeSelectionCondition(ctx context.Context, criteria *overlay.NodeCriteria, excludedIDs []storj.NodeID, excludedNetworks []string, isNewNodeQuery bool) (condition, error) { +func nodeSelectionCondition(ctx context.Context, criteria *overlay.NodeCriteria, excludedIDs []storj.NodeID, + excludedNetworks []string, isNewNodeQuery bool) (condition, error) { + var conds conditions conds.add(`disqualified IS NULL`) conds.add(`unknown_audit_suspended IS NULL`) @@ -220,15 +225,15 @@ func nodeSelectionCondition(ctx context.Context, criteria *overlay.NodeCriteria, return conds.combine(), nil } -// partialQuery corresponds to a query +// partialQuery corresponds to a query. // -// distinct=false +// distinct=false // -// $selection WHERE $condition ORDER BY $orderBy, RANDOM() LIMIT $limit +// $selection WHERE $condition ORDER BY $orderBy, RANDOM() LIMIT $limit // -// distinct=true +// distinct=true // -// SELECT * FROM ($selection WHERE $condition ORDER BY $orderBy, RANDOM()) filtered ORDER BY RANDOM() LIMIT $limit +// SELECT * FROM ($selection WHERE $condition ORDER BY $orderBy, RANDOM()) filtered ORDER BY RANDOM() LIMIT $limit // type partialQuery struct { selection string diff --git a/satellite/snopayout/endpoint.go b/satellite/snopayout/endpoint.go index a6829a6bd..10358fec4 100644 --- a/satellite/snopayout/endpoint.go +++ b/satellite/snopayout/endpoint.go @@ -21,7 +21,7 @@ var ( mon = monkit.Package() ) -// Endpoint for querying node stats for the SNO +// Endpoint for querying node stats for the SNO. // // architecture: Endpoint type Endpoint struct { diff --git a/satellite/snopayout/payout.go b/satellite/snopayout/payout.go index 5073cfb11..7f75b4e45 100644 --- a/satellite/snopayout/payout.go +++ b/satellite/snopayout/payout.go @@ -73,7 +73,7 @@ type StoragenodePayment struct { Notes string `json:"notes"` } -// Service is used to store and handle node paystub information +// Service is used to store and handle node paystub information. // // architecture: Service type Service struct { diff --git a/storagenode/bandwidth/service.go b/storagenode/bandwidth/service.go index 4ef958df8..7522ac351 100644 --- a/storagenode/bandwidth/service.go +++ b/storagenode/bandwidth/service.go @@ -21,7 +21,7 @@ type Config struct { Interval time.Duration `help:"how frequently bandwidth usage rollups are calculated" default:"1h0m0s"` } -// Service implements +// Service implements the bandwidth usage rollup service. // // architecture: Chore type Service struct { diff --git a/storagenode/contact/chore.go b/storagenode/contact/chore.go index e42777572..434df7df0 100644 --- a/storagenode/contact/chore.go +++ b/storagenode/contact/chore.go @@ -15,7 +15,7 @@ import ( "storj.io/common/sync2" ) -// Chore is the contact chore for nodes announcing themselves to their trusted satellites +// Chore is the contact chore for nodes announcing themselves to their trusted satellites. // // architecture: Chore type Chore struct { diff --git a/storagenode/contact/endpoint.go b/storagenode/contact/endpoint.go index 28a5c1e64..3701204d6 100644 --- a/storagenode/contact/endpoint.go +++ b/storagenode/contact/endpoint.go @@ -16,7 +16,7 @@ import ( "storj.io/common/rpc/rpcstatus" ) -// Endpoint implements the contact service Endpoints +// Endpoint implements the contact service Endpoints. // // architecture: Endpoint type Endpoint struct { diff --git a/storagenode/inspector/inspector.go b/storagenode/inspector/inspector.go index c3ce61bc8..2eb1d2361 100644 --- a/storagenode/inspector/inspector.go +++ b/storagenode/inspector/inspector.go @@ -27,7 +27,7 @@ var ( Error = errs.Class("piecestore inspector") ) -// Endpoint does inspectory things +// Endpoint implements the inspector endpoints. // // architecture: Endpoint type Endpoint struct { diff --git a/storagenode/monitor/monitor.go b/storagenode/monitor/monitor.go index eb4fbb775..c3efa4d1e 100644 --- a/storagenode/monitor/monitor.go +++ b/storagenode/monitor/monitor.go @@ -37,7 +37,7 @@ type Config struct { NotifyLowDiskCooldown time.Duration `help:"minimum length of time between capacity reports" default:"10m" hidden:"true"` } -// Service which monitors disk usage +// Service which monitors disk usage. // // architecture: Service type Service struct { diff --git a/storagenode/nodestats/cache.go b/storagenode/nodestats/cache.go index 2240e7c87..6a937b927 100644 --- a/storagenode/nodestats/cache.go +++ b/storagenode/nodestats/cache.go @@ -39,8 +39,7 @@ type CacheStorage struct { Satellites satellites.DB } -// Cache runs cache loop and stores reputation stats -// and storage usage into db +// Cache runs cache loop and stores reputation stats and storage usage into db. // // architecture: Chore type Cache struct { @@ -58,7 +57,9 @@ type Cache struct { } // NewCache creates new caching service instance. -func NewCache(log *zap.Logger, config Config, db CacheStorage, service *Service, payoutEndpoint *payout.Endpoint, reputationService *reputation.Service, trust *trust.Pool) *Cache { +func NewCache(log *zap.Logger, config Config, db CacheStorage, service *Service, + payoutEndpoint *payout.Endpoint, reputationService *reputation.Service, trust *trust.Pool) *Cache { + return &Cache{ log: log, db: db, @@ -187,7 +188,8 @@ func (cache *Cache) CacheSpaceUsage(ctx context.Context) (err error) { }) } -// CacheHeldAmount queries held amount stats and payments from all the satellites known to the storagenode and stores info into db. +// CacheHeldAmount queries held amount stats and payments from +// all the satellites known to the storagenode and stores info into db. func (cache *Cache) CacheHeldAmount(ctx context.Context) (err error) { defer mon.Task()(&ctx)(&err) diff --git a/storagenode/nodestats/service.go b/storagenode/nodestats/service.go index b6793f86c..1711d44dd 100644 --- a/storagenode/nodestats/service.go +++ b/storagenode/nodestats/service.go @@ -27,7 +27,7 @@ var ( mon = monkit.Package() ) -// Client encapsulates NodeStatsClient with underlying connection +// Client encapsulates NodeStatsClient with underlying connection. // // architecture: Client type Client struct { @@ -40,7 +40,7 @@ func (c *Client) Close() error { return c.conn.Close() } -// Service retrieves info from satellites using an rpc client +// Service retrieves info from satellites using an rpc client. // // architecture: Service type Service struct { diff --git a/storagenode/payout/payout.go b/storagenode/payout/payout.go index 34922dce4..d64b456d8 100644 --- a/storagenode/payout/payout.go +++ b/storagenode/payout/payout.go @@ -12,7 +12,7 @@ import ( "storj.io/common/storj" ) -// DB works with payout database +// DB works with payout database. // // architecture: Database type DB interface { diff --git a/storagenode/payout/service.go b/storagenode/payout/service.go index e2ca16f33..a8e6fedd8 100644 --- a/storagenode/payout/service.go +++ b/storagenode/payout/service.go @@ -33,7 +33,7 @@ var ( mon = monkit.Package() ) -// Service retrieves info from satellites using an rpc client +// Service retrieves info from satellites using an rpc client. // // architecture: Service type Service struct { diff --git a/storagenode/peer.go b/storagenode/peer.go index 2f2d6be14..7dd6e7bfb 100644 --- a/storagenode/peer.go +++ b/storagenode/peer.go @@ -66,7 +66,7 @@ var ( mon = monkit.Package() ) -// DB is the master database for Storage Node +// DB is the master database for Storage Node. // // architecture: Master Database type DB interface { diff --git a/storagenode/pieces/cache.go b/storagenode/pieces/cache.go index 86decbec4..58a8a11fd 100644 --- a/storagenode/pieces/cache.go +++ b/storagenode/pieces/cache.go @@ -17,7 +17,7 @@ import ( "storj.io/storj/storage" ) -// CacheService updates the space used cache +// CacheService updates the space used cache. // // architecture: Chore type CacheService struct { @@ -146,7 +146,8 @@ func (service *CacheService) Close() (err error) { // - piecesTotal: the total space used by pieces, including headers // - piecesContentSize: the space used by piece content, not including headers // - trashTotal: the total space used in the trash, including headers -// - pieceTotal and pieceContentSize are the corollary for a single file +// +// pieceTotal and pieceContentSize are the corollary for a single file. // // architecture: Database type BlobsUsageCache struct { diff --git a/storagenode/pieces/store.go b/storagenode/pieces/store.go index 96a77414f..2457873ce 100644 --- a/storagenode/pieces/store.go +++ b/storagenode/pieces/store.go @@ -103,7 +103,7 @@ type V0PieceInfoDBForTest interface { Add(context.Context, *Info) error } -// PieceSpaceUsedDB stores the most recent totals from the space used cache +// PieceSpaceUsedDB stores the most recent totals from the space used cache. // // architecture: Database type PieceSpaceUsedDB interface { @@ -182,7 +182,9 @@ type StoreForTest struct { } // NewStore creates a new piece store. -func NewStore(log *zap.Logger, blobs storage.Blobs, v0PieceInfo V0PieceInfoDB, expirationInfo PieceExpirationDB, pieceSpaceUsedDB PieceSpaceUsedDB, config Config) *Store { +func NewStore(log *zap.Logger, blobs storage.Blobs, v0PieceInfo V0PieceInfoDB, + expirationInfo PieceExpirationDB, pieceSpaceUsedDB PieceSpaceUsedDB, config Config) *Store { + return &Store{ log: log, config: config, @@ -222,7 +224,9 @@ func (store *Store) Writer(ctx context.Context, satellite storj.NodeID, pieceID // WriterForFormatVersion allows opening a piece writer with a specified storage format version. // This is meant to be used externally only in test situations (thus the StoreForTest receiver // type). -func (store StoreForTest) WriterForFormatVersion(ctx context.Context, satellite storj.NodeID, pieceID storj.PieceID, formatVersion storage.FormatVersion) (_ *Writer, err error) { +func (store StoreForTest) WriterForFormatVersion(ctx context.Context, satellite storj.NodeID, + pieceID storj.PieceID, formatVersion storage.FormatVersion) (_ *Writer, err error) { + defer mon.Task()(&ctx)(&err) blobRef := storage.BlobRef{ @@ -271,7 +275,9 @@ func (store *Store) Reader(ctx context.Context, satellite storj.NodeID, pieceID // ReaderWithStorageFormat returns a new piece reader for a located piece, which avoids the // potential need to check multiple storage formats to find the right blob. -func (store *Store) ReaderWithStorageFormat(ctx context.Context, satellite storj.NodeID, pieceID storj.PieceID, formatVersion storage.FormatVersion) (_ *Reader, err error) { +func (store *Store) ReaderWithStorageFormat(ctx context.Context, satellite storj.NodeID, + pieceID storj.PieceID, formatVersion storage.FormatVersion) (_ *Reader, err error) { + defer mon.Task()(&ctx)(&err) ref := storage.BlobRef{Namespace: satellite.Bytes(), Key: pieceID.Bytes()} blob, err := store.blobs.OpenWithStorageFormat(ctx, ref, formatVersion) @@ -306,7 +312,8 @@ func (store *Store) Delete(ctx context.Context, satellite storj.NodeID, pieceID err = errs.Combine(err, store.v0PieceInfo.Delete(ctx, satellite, pieceID)) } - store.log.Debug("deleted piece", zap.String("Satellite ID", satellite.String()), zap.String("Piece ID", pieceID.String())) + store.log.Debug("deleted piece", zap.String("Satellite ID", satellite.String()), + zap.String("Piece ID", pieceID.String())) return Error.Wrap(err) } @@ -386,10 +393,10 @@ func (store *Store) RestoreTrash(ctx context.Context, satelliteID storj.NodeID) // MigrateV0ToV1 will migrate a piece stored with storage format v0 to storage // format v1. If the piece is not stored as a v0 piece it will return an error. // The follow failures are possible: -// - Fail to open or read v0 piece. In this case no artifacts remain. -// - Fail to Write or Commit v1 piece. In this case no artifacts remain. -// - Fail to Delete v0 piece. In this case v0 piece may remain, but v1 piece -// will exist and be preferred in future calls. +// - Fail to open or read v0 piece. In this case no artifacts remain. +// - Fail to Write or Commit v1 piece. In this case no artifacts remain. +// - Fail to Delete v0 piece. In this case v0 piece may remain, +// but v1 piece will exist and be preferred in future calls. func (store *Store) MigrateV0ToV1(ctx context.Context, satelliteID storj.NodeID, pieceID storj.PieceID) (err error) { defer mon.Task()(&ctx)(&err) diff --git a/storagenode/pricing/pricing.go b/storagenode/pricing/pricing.go index 6461495c0..c69dbfd65 100644 --- a/storagenode/pricing/pricing.go +++ b/storagenode/pricing/pricing.go @@ -9,7 +9,7 @@ import ( "storj.io/common/storj" ) -// DB works with pricing database +// DB works with pricing database. // // architecture: Database type DB interface { diff --git a/storagenode/reputation/reputation.go b/storagenode/reputation/reputation.go index e7ced0e75..1d90799d3 100644 --- a/storagenode/reputation/reputation.go +++ b/storagenode/reputation/reputation.go @@ -10,7 +10,7 @@ import ( "storj.io/common/storj" ) -// DB works with reputation database +// DB works with reputation database. // // architecture: Database type DB interface { diff --git a/storagenode/satellites/satellites.go b/storagenode/satellites/satellites.go index 0160fa762..c6ce35acf 100644 --- a/storagenode/satellites/satellites.go +++ b/storagenode/satellites/satellites.go @@ -44,7 +44,7 @@ type Satellite struct { Status int32 } -// DB works with satellite database +// DB works with satellite database. // // architecture: Database type DB interface { diff --git a/storagenode/storageusage/storageusage.go b/storagenode/storageusage/storageusage.go index 2b8bb0ef6..a4853d7ac 100644 --- a/storagenode/storageusage/storageusage.go +++ b/storagenode/storageusage/storageusage.go @@ -10,7 +10,7 @@ import ( "storj.io/common/storj" ) -// DB works with storage usage database +// DB works with storage usage database. // // architecture: Database type DB interface {