proposal

package
v0.0.0-...-2dfb075 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2025 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SortTypeUptime    = "uptime"
	SortTypeBandwidth = "bandwidth"
	SortTypeLatency   = "latency"
	SortTypePrice     = "price"
	SortTypeQuality   = "quality"
)

Supported proposals sorting types.

Variables

View Source
var ErrUnsupportedSortType = fmt.Errorf("unsupported proposal sort type")

ErrUnsupportedSortType indicates unsupported proposals sorting type error.

Functions

This section is empty.

Types

type Filter

type Filter struct {
	PresetID                           int
	ProviderID                         string
	ProviderIDs                        []string
	ServiceType                        string
	LocationCountry                    string
	IPType                             string
	AccessPolicy, AccessPolicySource   string
	CompatibilityMin, CompatibilityMax int
	BandwidthMin                       float64
	QualityMin                         float32
	ExcludeUnsupported                 bool
	IncludeMonitoringFailed            bool
	NATCompatibility                   nat.NATType
	// contains filtered or unexported fields
}

Filter defines all flags for proposal filtering in discovery of Mysterium Network

func (*Filter) Build

func (filter *Filter) Build()

Build ensures filter conditions are assembled

func (*Filter) Matches

func (filter *Filter) Matches(proposal market.ServiceProposal) bool

Matches return flag if filter matches given proposal

func (*Filter) ToAPIQuery

func (filter *Filter) ToAPIQuery() mysterium.ProposalsQuery

ToAPIQuery serialises filter to query of Mysterium API

type FilterPreset

type FilterPreset struct {
	ID     int
	Name   string
	IPType IPType
	// contains filtered or unexported fields
}

FilterPreset represent predefined or user stored proposal filter preset

func (*FilterPreset) Filter

func (fps *FilterPreset) Filter(proposals []PricedServiceProposal) []PricedServiceProposal

Filter filters proposals according to preset

type FilterPresetRepository

type FilterPresetRepository interface {
	List() (*FilterPresets, error)
	Get(id int) (*FilterPreset, error)
}

FilterPresetRepository provides proposal filter presets by which they can be filtered.

type FilterPresetStorage

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

FilterPresetStorage filter preset storage

func NewFilterPresetStorage

func NewFilterPresetStorage(storage persistentStorage) *FilterPresetStorage

NewFilterPresetStorage constructor for FilterPresetStorage

func (*FilterPresetStorage) Delete

func (fps *FilterPresetStorage) Delete(id int) error

Delete delete filter preset by id

func (*FilterPresetStorage) Get

func (fps *FilterPresetStorage) Get(id int) (*FilterPreset, error)

Get get single filter preset

func (*FilterPresetStorage) List

func (fps *FilterPresetStorage) List() (*FilterPresets, error)

List list all filter presets system preset are identified by preset.ID < startingID

func (*FilterPresetStorage) Save

func (fps *FilterPresetStorage) Save(preset FilterPreset) error

Save created or updates existing to update existing: preset.ID > startingID

type FilterPresets

type FilterPresets struct {
	Entries []FilterPreset
}

FilterPresets convenience wrapper

type IPType

type IPType string

IPType represents type of node

const (
	// Residential node type value
	Residential IPType = "residential"
	// Hosting node type value
	Hosting IPType = "hosting"
	// Business node type value
	Business IPType = "business"
	// Cellular node type value
	Cellular IPType = "cellular"
	// Dialup node type value
	Dialup IPType = "dialup"
	// College node type value
	College IPType = "college"
)

type PricedServiceProposal

type PricedServiceProposal struct {
	market.ServiceProposal
	Price market.Price `json:"price,omitempty"`
}

PricedServiceProposal enriches proposals with price data.

func Sort

func Sort(proposals []PricedServiceProposal, sortType string) ([]PricedServiceProposal, error)

Sort sorts proposals list based on provided sorting type. It might return error in case of unsupported sorting type provided.

func SortByBandwidth

func SortByBandwidth(proposals []PricedServiceProposal) []PricedServiceProposal

SortByBandwidth sorts proposals list based on provider bandwidth.

func SortByLatency

func SortByLatency(proposals []PricedServiceProposal) []PricedServiceProposal

SortByLatency sorts proposals list based on provider latency.

func SortByPrice

func SortByPrice(proposals []PricedServiceProposal) []PricedServiceProposal

SortByPrice sorts proposals list based on proposal price.

func SortByQuality

func SortByQuality(proposals []PricedServiceProposal) []PricedServiceProposal

SortByQuality sorts proposals list based on provider quality.

func SortByUptime

func SortByUptime(proposals []PricedServiceProposal) []PricedServiceProposal

SortByUptime sorts proposals list based on provider uptime.

type Repository

type Repository interface {
	// Proposal returns a single proposal by its ID.
	Proposal(id market.ProposalID) (*market.ServiceProposal, error)
	// Proposals returns proposals matching the filter.
	Proposals(filter *Filter) ([]market.ServiceProposal, error)
	Countries(filter *Filter) (map[string]int, error)
}

Repository provides proposals.

Jump to

Keyboard shortcuts

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