storj/cmd/tools/segment-verify/service.go
Egon Elbre 3467fd4b7f cmd/tools/segment-verify: implement batch creation
Implements creating roughly load-balanced set of batched
that can be used to make multiple requests.

Change-Id: I349b276176dcb8ba9163e7e06a94509d73fa5ddc
2022-09-12 18:29:01 +03:00

43 lines
978 B
Go

// Copyright (C) 2022 Storj Labs, Inc.
// See LICENSE for copying information.
package main
import (
"storj.io/common/uuid"
"storj.io/storj/satellite/metabase"
)
// VerifyPieces defines how many pieces we check per segment.
const VerifyPieces = 3
// Service implements segment verification logic.
type Service struct {
PriorityNodes NodeAliasSet
OfflineNodes NodeAliasSet
}
// NewService returns a new service for verifying segments.
func NewService() *Service {
return &Service{
PriorityNodes: NodeAliasSet{},
OfflineNodes: NodeAliasSet{},
}
}
// Segment contains minimal information necessary for verifying a single Segment.
type Segment struct {
StreamID uuid.UUID
Position metabase.SegmentPosition
Pieces []metabase.AliasPiece
}
// Batch is a list of segments to be verified on a single node.
type Batch struct {
Alias metabase.NodeAlias
Items []*Segment
}
// Len returns the length of the batch.
func (b *Batch) Len() int { return len(b.Items) }