storj/storagenode/trust/static_source.go
Andrew Harding cb89496569 storagenode/trust: wire up list into pool
- also updated ping chore to pick up trust changes
- fixed small typo in blueprint
- fixed flags for storj-sim
- wired up changes to testplanet

Change-Id: I02982f3a63a1b4150b82a009ee126b25ed51917d
2019-12-13 20:32:50 +00:00

46 lines
1.2 KiB
Go

// Copyright (C) 2019 Storj Labs, Inc.
// See LICENSE for copying information.
package trust
import (
"context"
"github.com/zeebo/errs"
)
var (
// ErrStaticSource is an error class for static source errors
ErrStaticSource = errs.Class("static source")
)
// StaticURLSource is a trust source that returns an explicitly trusted URL
type StaticURLSource struct {
URL SatelliteURL
}
// NewStaticURLSource takes an explicitly trusted URL and returns a new StaticURLSource.
func NewStaticURLSource(satelliteURL string) (*StaticURLSource, error) {
url, err := ParseSatelliteURL(satelliteURL)
if err != nil {
return nil, ErrStaticSource.Wrap(err)
}
return &StaticURLSource{URL: url}, nil
}
// String implements the Source interface and returns the static trusted URL
func (source *StaticURLSource) String() string {
return source.URL.String()
}
// Static implements the Source interface. It returns true.
func (source *StaticURLSource) Static() bool { return true }
// FetchEntries returns a trust entry for the explicitly trusted Satellite URL.
// The entry is authoritative.
func (source *StaticURLSource) FetchEntries(ctx context.Context) ([]Entry, error) {
return []Entry{
{SatelliteURL: source.URL, Authoritative: true},
}, nil
}