config

package
v0.1.10 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RetrievalPricingDefault configures the node to use the default retrieval pricing policy.
	RetrievalPricingDefaultMode = "default"
	// RetrievalPricingExternal configures the node to use the external retrieval pricing script
	// configured by the user.
	RetrievalPricingExternalMode = "external"
)

Variables

View Source
var Doc = map[string][]DocField{
	"CandidateCfg": {
		{
			Name: "TCPSrvAddr",
			Type: "string",

			Comment: ``,
		},
		{
			Name: "IpfsAPIURL",
			Type: "string",

			Comment: ``,
		},
	},
	"EdgeCfg": {
		{
			Name: "ListenAddress",
			Type: "string",

			Comment: `host address and port the edge node api will listen on`,
		},
		{
			Name: "Timeout",
			Type: "string",

			Comment: `used when 'ListenAddress' is unspecified. must be a valid duration recognized by golang's time.ParseDuration function`,
		},
		{
			Name: "NodeID",
			Type: "string",

			Comment: `deivce id`,
		},
		{
			Name: "Secret",
			Type: "string",

			Comment: `used auth when connect to scheduler`,
		},
		{
			Name: "CarfileStorePath",
			Type: "string",

			Comment: `carfilestore path`,
		},
		{
			Name: "BandwidthUp",
			Type: "int64",

			Comment: `upload file bandwidth, unit is B/s`,
		},
		{
			Name: "BandwidthDown",
			Type: "int64",

			Comment: `download file bandwidth, unit is B/s`,
		},
		{
			Name: "Locator",
			Type: "bool",

			Comment: `if true, get scheduler url from locator`,
		},
		{
			Name: "InsecureSkipVerify",
			Type: "bool",

			Comment: `InsecureSkipVerify skip tls verify`,
		},
		{
			Name: "CertificatePath",
			Type: "string",

			Comment: `used for http3 server
be used if InsecureSkipVerify is true`,
		},
		{
			Name: "PrivateKeyPath",
			Type: "string",

			Comment: `used for http3 server
be used if InsecureSkipVerify is true`,
		},
		{
			Name: "CaCertificatePath",
			Type: "string",

			Comment: `self sign certificate, use for client`,
		},
		{
			Name: "FetchBlockTimeout",
			Type: "int",

			Comment: `FetchTimeout get block timeout`,
		},
		{
			Name: "FetchBlockRetry",
			Type: "int",

			Comment: `FetchBlockFailedRetry retry when get block failed`,
		},
	},
	"LocatorCfg": {
		{
			Name: "ListenAddress",
			Type: "string",

			Comment: `host address and port the edge node api will listen on`,
		},
		{
			Name: "Timeout",
			Type: "string",

			Comment: `used when 'ListenAddress' is unspecified. must be a valid duration recognized by golang's time.ParseDuration function`,
		},
		{
			Name: "GeoDBPath",
			Type: "string",

			Comment: `geodb path`,
		},
		{
			Name: "DatabaseAddress",
			Type: "string",

			Comment: `mysql db address`,
		},
		{
			Name: "UUID",
			Type: "string",

			Comment: `uuid`,
		},
		{
			Name: "InsecureSkipVerify",
			Type: "bool",

			Comment: `InsecureSkipVerify skip tls verify`,
		},
		{
			Name: "CertificatePath",
			Type: "string",

			Comment: `used for http3 server
be used if InsecureSkipVerify is true`,
		},
		{
			Name: "PrivateKeyPath",
			Type: "string",

			Comment: `used for http3 server
be used if InsecureSkipVerify is true`,
		},
		{
			Name: "CaCertificatePath",
			Type: "string",

			Comment: `self sign certificate, use for client`,
		},
	},
	"SchedulerCfg": {
		{
			Name: "ExternalAddress",
			Type: "string",

			Comment: `host external address and port`,
		},
		{
			Name: "ListenAddress",
			Type: "string",

			Comment: `host address and port the edge node api will listen on`,
		},
		{
			Name: "DatabaseAddress",
			Type: "string",

			Comment: `database address`,
		},
		{
			Name: "AreaID",
			Type: "string",

			Comment: `area id`,
		},
		{
			Name: "InsecureSkipVerify",
			Type: "bool",

			Comment: `InsecureSkipVerify skip tls verify`,
		},
		{
			Name: "CertificatePath",
			Type: "string",

			Comment: `used for http3 server
be used if InsecureSkipVerify is true`,
		},
		{
			Name: "PrivateKeyPath",
			Type: "string",

			Comment: `used for http3 server
be used if InsecureSkipVerify is true`,
		},
		{
			Name: "CaCertificatePath",
			Type: "string",

			Comment: `self sign certificate, use for client`,
		},
		{
			Name: "SchedulerServer1",
			Type: "string",

			Comment: `test nat type`,
		},
		{
			Name: "SchedulerServer2",
			Type: "string",

			Comment: `test nat type`,
		},
		{
			Name: "EnableValidate",
			Type: "bool",

			Comment: `config to enabled node validation, default: true`,
		},
		{
			Name: "EtcdAddresses",
			Type: "[]string",

			Comment: `etcd server addresses`,
		},
		{
			Name: "CandidateReplicaCachesCount",
			Type: "int",

			Comment: `Cache to the number of candidate nodes (does not contain 'seedCacheCount')`,
		},
	},
}
View Source
var MaxTraversalLinks uint64 = 32 * (1 << 20)

MaxTraversalLinks configures the maximum number of links to traverse in a DAG while calculating CommP and traversing a DAG with graphsync; invokes a budget on DAG depth and density.

Functions

func FromFile

func FromFile(path string, def interface{}) (interface{}, error)

FromFile loads config from a specified file overriding defaults specified in the def parameter. If file does not exist or is empty defaults are assumed.

func FromReader

func FromReader(reader io.Reader, def interface{}) (interface{}, error)

FromReader loads config from a reader instance.

func GenerateConfigComment

func GenerateConfigComment(t interface{}) ([]byte, error)

GenerateConfigComment generates a commented version of the specified configuration, with comments describing each configuration field.

func GenerateConfigUpdate

func GenerateConfigUpdate(cfgCur, cfgDef interface{}, comment bool) ([]byte, error)

GenerateConfigUpdate generates an updated configuration based on the current configuration and the specified defaults. If 'comment' is true, the updated configuration will contain comments describing each configuration field.

Types

type CandidateCfg

type CandidateCfg struct {
	EdgeCfg
}

CandidateCfg candidate node config

func DefaultCandidateCfg

func DefaultCandidateCfg() *CandidateCfg

DefaultCandidateCfg returns the default candidate config

type DocField

type DocField struct {
	Name    string
	Type    string
	Comment string
}

type Duration

type Duration time.Duration

Duration is a wrapper type for time.Duration for decoding and encoding from/to TOML

func (Duration) MarshalText

func (dur Duration) MarshalText() ([]byte, error)

MarshalText implements interface for TOML encoding

func (*Duration) UnmarshalText

func (dur *Duration) UnmarshalText(text []byte) error

UnmarshalText implements interface for TOML decoding

type EdgeCfg

type EdgeCfg struct {
	// host address and port the edge node api will listen on
	ListenAddress string
	// used when 'ListenAddress' is unspecified. must be a valid duration recognized by golang's time.ParseDuration function
	Timeout string
	// node id
	NodeID string
	// area id
	AreaID string
	// used auth when connect to scheduler
	Secret string
	// metadata path
	MetadataPath string
	// assets path
	AssetsPaths []string
	// upload file bandwidth, unit is B/s
	BandwidthUp int64
	// download file bandwidth, unit is B/s
	BandwidthDown int64
	// if true, get scheduler url from locator
	Locator bool
	// InsecureSkipVerify skip tls verify
	InsecureSkipVerify bool
	// used for http3 server
	// be used if InsecureSkipVerify is true
	CertificatePath string
	// used for http3 server
	// be used if InsecureSkipVerify is true
	PrivateKeyPath string
	// self sign certificate, use for client
	CaCertificatePath string
	// PullBlockTimeout get block timeout
	PullBlockTimeout int
	// PullBlockRetry retry when get block failed
	PullBlockRetry int
	// PullBlockParallel the number of goroutine to pull block
	PullBlockParallel int
	TCPSrvAddr        string
	IPFSAPIURL        string
	// seconds
	ValidateDuration int
}

EdgeCfg edge node config

func DefaultEdgeCfg

func DefaultEdgeCfg() *EdgeCfg

DefaultEdgeCfg returns the default edge config

type LocatorCfg

type LocatorCfg struct {
	// host address and port the edge node api will listen on
	ListenAddress string
	// used when 'ListenAddress' is unspecified. must be a valid duration recognized by golang's time.ParseDuration function
	Timeout string
	// geodb path
	GeoDBPath string
	// InsecureSkipVerify skip tls verify
	InsecureSkipVerify bool
	// used for http3 server
	// be used if InsecureSkipVerify is false
	CertificatePath string
	// used for http3 server
	// be used if InsecureSkipVerify is false
	PrivateKeyPath string
	// self sign certificate, use for client
	CaCertificatePath string
	// etcd server addresses
	EtcdAddresses    []string
	DefaultAreaID    string
	DNSServerAddress string
	UseDefaultAreaID bool
}

LocatorCfg locator config

func DefaultLocatorCfg

func DefaultLocatorCfg() *LocatorCfg

DefaultLocatorCfg returns the default locator config

type SchedulerCfg

type SchedulerCfg struct {
	// host external address and port
	ExternalURL string
	// host address and port the edge node api will listen on
	ListenAddress string
	// database address
	DatabaseAddress string
	// area id
	AreaID string
	// InsecureSkipVerify skip tls verify
	InsecureSkipVerify bool
	// used for http3 server
	// be used if InsecureSkipVerify is true
	CertificatePath string
	// used for http3 server
	// be used if InsecureSkipVerify is true
	PrivateKeyPath string
	// self sign certificate, use for client
	CaCertificatePath string
	// config to enabled node validation, default: true
	EnableValidation bool
	// etcd server addresses
	EtcdAddresses []string
	// Number of candidate node replicas (does not contain 'seed')
	CandidateReplicas int
	// Proportion of validator in candidate nodes (0 ~ 1)
	ValidatorRatio float64
	// The base downstream bandwidth per validator window (unit : MiB)
	ValidatorBaseBwDn int
	// Increased profit after node validation passes
	ValidationProfit float64
	// Increased profit after node workload passes
	WorkloadProfit float64
	// ElectionCycle cycle (Unit:day)
	ElectionCycle int
	// Node score level scale
	// The key of map is the rank name, and the value of map is a int array containing two elements,
	// the first element of which is the minimum value of score,
	// and the second element is the maximum value of score. (scores out of 100)
	NodeScoreLevel map[string][]int
	// Node level weight
	// The key of the map is the name of the level, and the value of the map is an int,
	// indicating how many select weight this level can get (the more select weight, the greater the probability of the node being selected)
	LevelSelectWeight map[string]int

	UserFreeStorageSize int64

	LotusRPCAddress string
	LotusToken      string

	// The ratio of edge nodes returned to the user for download
	EdgeDownloadRatio float64
	// Maximum number of concurrent asset pulls
	AssetPullTaskLimit int

	NatDetectConcurrency int
	AssetDomain          string

	// Default number of backups for user uploaded files
	UploadAssetReplicaCount int
	// Default expiration time for user uploaded files
	UploadAssetExpiration int // (Unit:day)
}

SchedulerCfg scheduler config

func DefaultSchedulerCfg

func DefaultSchedulerCfg() *SchedulerCfg

DefaultSchedulerCfg returns the default scheduler config

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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