reputation

package
v1.119.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrReputationService is a base error class for reputation service.
	ErrReputationService = errs.Class("reputation")
)

Functions

This section is empty.

Types

type AuditHistory added in v1.20.1

type AuditHistory struct {
	Score   float64              `json:"score"`
	Windows []AuditHistoryWindow `json:"windows"`
}

AuditHistory encapsulates storagenode audit history.

func GetAuditHistoryFromPB added in v1.20.1

func GetAuditHistoryFromPB(auditHistoryPB *pb.AuditHistory) AuditHistory

GetAuditHistoryFromPB creates the AuditHistory json struct from a protobuf.

type AuditHistoryWindow added in v1.20.1

type AuditHistoryWindow struct {
	WindowStart time.Time `json:"windowStart"`
	TotalCount  int32     `json:"totalCount"`
	OnlineCount int32     `json:"onlineCount"`
}

AuditHistoryWindow encapsulates storagenode audit history window.

type Chore added in v1.119.2

type Chore struct {
	Loop *sync2.Cycle
	// contains filtered or unexported fields
}

Chore periodically fetches reputation stats from satellites.

func NewChore added in v1.119.2

func NewChore(log *zap.Logger, service *Service, config Config) *Chore

NewChore creates new reputation chore instance.

func (*Chore) Close added in v1.119.2

func (chore *Chore) Close() error

Close closes the reputation service.

func (*Chore) GetAndCacheStats added in v1.119.2

func (chore *Chore) GetAndCacheStats(ctx context.Context, satellite storj.NodeID) (err error)

GetAndCacheStats retrieves reputation stats from particular satellite and stores it in cache.

func (*Chore) Run added in v1.119.2

func (chore *Chore) Run(ctx context.Context) (err error)

Run runs the reputation service.

func (*Chore) RunOnce added in v1.119.2

func (chore *Chore) RunOnce(ctx context.Context) (err error)

RunOnce runs the reputation service once.

type Client added in v1.119.2

type Client struct {
	pb.DRPCNodeStatsClient
	// contains filtered or unexported fields
}

Client encapsulates NodeStatsClient with underlying connection.

architecture: Client

func (*Client) Close added in v1.119.2

func (c *Client) Close() error

Close closes underlying client connection.

type Config added in v1.119.2

type Config struct {
	MaxSleep time.Duration `help:"maximum duration to wait before requesting data" releaseDefault:"300s" devDefault:"1s"`
	Interval time.Duration `help:"how often to sync reputation" releaseDefault:"4h" devDefault:"1m"`
	Cache    bool          `help:"store reputation stats in cache" releaseDefault:"true" devDefault:"true"`
}

Config defines reputation service configuration.

type DB

type DB interface {
	// Store inserts or updates reputation stats into the DB
	Store(ctx context.Context, stats Stats) error
	// Get retrieves stats for specific satellite
	Get(ctx context.Context, satelliteID storj.NodeID) (*Stats, error)
	// All retrieves all stats from DB
	All(ctx context.Context) ([]Stats, error)
	// Delete removes stats for specific satellite
	Delete(ctx context.Context, satelliteID storj.NodeID) error
}

DB works with reputation database.

architecture: Database

type Metric

type Metric struct {
	TotalCount   int64 `json:"totalCount"`
	SuccessCount int64 `json:"successCount"`

	Alpha        float64 `json:"alpha"`
	Beta         float64 `json:"beta"`
	UnknownAlpha float64 `json:"unknownAlpha"`
	UnknownBeta  float64 `json:"unknownBeta"`
	Score        float64 `json:"score"`
	UnknownScore float64 `json:"unknownScore"`
}

Metric encapsulates storagenode reputation metrics.

type Service added in v1.17.1

type Service struct {
	// contains filtered or unexported fields
}

Service is the reputation service.

architecture: Service

func NewService added in v1.17.1

func NewService(log *zap.Logger, db DB, dialer rpc.Dialer, trust *trust.Pool, nodeID storj.NodeID, notifications *notifications.Service) *Service

NewService creates new instance of service.

func (*Service) GetStats added in v1.119.2

func (s *Service) GetStats(ctx context.Context, satelliteID storj.NodeID) (_ *Stats, err error)

GetStats retrieves reputation stats from particular satellite.

func (*Service) Store added in v1.17.1

func (s *Service) Store(ctx context.Context, stats Stats, satelliteID storj.NodeID) error

Store stores reputation stats into db, and notify's in case of offline suspension.

type Stats

type Stats struct {
	SatelliteID storj.NodeID

	Audit       Metric
	OnlineScore float64

	DisqualifiedAt       *time.Time
	SuspendedAt          *time.Time
	OfflineSuspendedAt   *time.Time
	OfflineUnderReviewAt *time.Time
	VettedAt             *time.Time
	AuditHistory         *pb.AuditHistory

	UpdatedAt time.Time
	JoinedAt  time.Time
}

Stats consist of reputation metrics.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL