config

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: May 20, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlobsPath = "blobs"
	DBPath    = "db"
)
View Source
const (
	IdentityFilename = "identity"
)

Variables

View Source
var DefaultConfig = Config{
	BanLists:       []string{},
	LogLevel:       log.LevelInfo.String(),
	EnableProfiler: false,
	Heartbeat: HeartbeatConfig{
		Moniker: "",
		URL:     "https://www.ddrpscan.com/heartbeat",
	},
	P2P: P2PConfig{
		Host: "0.0.0.0",
		DNSSeeds: []string{
			"seeds.ddrp.network",
		},
		FixedSeeds:          []string{},
		MaxInboundPeers:     117,
		MaxOutboundPeers:    8,
		ConnectionTimeoutMS: 5000,
	},
	RPC: RPCConfig{
		Host: "127.0.0.1",
		Port: 9098,
	},
	HNSResolver: HNSResolverConfig{
		Host:     "http://127.0.0.1",
		Port:     12037,
		BasePath: "",
		APIKey:   "",
	},
	Tuning: TuningConfig{
		Timebank: TimebankConfig{
			PeriodMS:             86400 * 2,
			MinUpdateIntervalMS:  120,
			FullUpdatesPerPeriod: 2,
		},
		UpdateQueue: UpdateQueueConfig{
			MaxLen:         1000,
			ReapIntervalMS: 5000,
		},
		Updater: UpdaterConfig{
			PollIntervalMS: 100,
			Workers:        2,
		},
		Syncer: SyncerConfig{
			TreeBaseResponseTimeoutMS: 10000,
			SectorResponseTimeoutMS:   15000,
		},
		SectorServer: SectorServerConfig{
			CacheExpiryMS: 5000,
		},
		PeerExchanger: PeerExchangerConfig{
			SampleSize:         12,
			RequestIntervalMS:  60 * 60 * 1000,
			MaxSentPeers:       255,
			MaxReceivedPeers:   255,
			MaxConcurrentDials: 2,
		},
		NameImporter: NameImporterConfig{
			ConfirmationDepth:     24,
			CheckIntervalMS:       60000,
			Workers:               5,
			VerificationThreshold: 0.90,
		},
		Heartbeat: HeartbeaterConfig{
			IntervalMS: 30000,
			TimeoutMS:  10000,
		},
		NameSyncer: NameSyncerConfig{
			Workers:                 2,
			SampleSize:              7,
			UpdateResponseTimeoutMS: 5000,
			IntervalMS:              60 * 60 * 1000,
			SyncResponseTimeoutMS:   60000,
		},
	},
}

Functions

func ConvertDuration

func ConvertDuration(base int, unit time.Duration) time.Duration

func EnsureHomeDir

func EnsureHomeDir(path string) error

func ExpandBlobsPath

func ExpandBlobsPath(homePath string) string

func ExpandDBPath

func ExpandDBPath(homePath string) string

func ExpandHomePath

func ExpandHomePath(path string) string

func GenerateDefaultConfigFile

func GenerateDefaultConfigFile() []byte

func HomeDirExists

func HomeDirExists(path string) (bool, error)

func InitBlobsDir

func InitBlobsDir(homePath string) error

func InitDBDir

func InitDBDir(homePath string) error

func InitHomeDir

func InitHomeDir(homePath string) error

func WriteDefaultConfigFile

func WriteDefaultConfigFile(homeDir string) error

func WriteIdentity

func WriteIdentity(homePath string, id *Identity) error

Types

type Config

type Config struct {
	LogLevel       string            `mapstructure:"log_level"`
	EnableProfiler bool              `mapstructure:"enable_profiler"`
	Heartbeat      HeartbeatConfig   `mapstructure:"heartbeat"`
	P2P            P2PConfig         `mapstructure:"p2p"`
	RPC            RPCConfig         `mapstructure:"rpc"`
	HNSResolver    HNSResolverConfig `mapstructure:"hns_resolver"`
	BanLists       []string          `mapstructure:"ban_lists"`
	Tuning         TuningConfig      `mapstructure:"tuning"`
}

func ReadConfig

func ReadConfig(r io.Reader) (*Config, error)

func ReadConfigFile

func ReadConfigFile(homeDir string) (*Config, error)

type HNSResolverConfig

type HNSResolverConfig struct {
	Host     string `mapstructure:"host"`
	Port     int    `mapstructure:"port"`
	BasePath string `mapstructure:"base_path"`
	APIKey   string `mapstructure:"api_key"`
}

type HeartbeatConfig

type HeartbeatConfig struct {
	Moniker string `mapstructure:"moniker"`
	URL     string `mapstructure:"url"`
}

type HeartbeaterConfig

type HeartbeaterConfig struct {
	IntervalMS int `mapstructure:"interval_ms"`
	TimeoutMS  int `mapstructure:"timeout_ms"`
}

type Identity

type Identity struct {
	PrivateKey *btcec.PrivateKey
}

func NewIdentity

func NewIdentity() *Identity

func ReadNodeIdentity

func ReadNodeIdentity(homePath string) (*Identity, error)

func (*Identity) MarshalBinary

func (n *Identity) MarshalBinary() (data []byte, err error)

func (*Identity) UnmarshalBinary

func (n *Identity) UnmarshalBinary(data []byte) error

type NameImporterConfig

type NameImporterConfig struct {
	ConfirmationDepth     int     `mapstructure:"confirmation_depth"`
	CheckIntervalMS       int     `mapstructure:"check_interval_ms"`
	Workers               int     `mapstructure:"workers"`
	VerificationThreshold float64 `mapstructure:"verification_threshold"`
}

type NameSyncerConfig

type NameSyncerConfig struct {
	Workers                 int `mapstructure:"workers"`
	SampleSize              int `mapstructure:"sample_size"`
	UpdateResponseTimeoutMS int `mapstructure:"update_response_timeout_ms"`
	IntervalMS              int `mapstructure:"interval_ms"`
	SyncResponseTimeoutMS   int `mapstructure:"sync_response_timeout_ms"`
}

type P2PConfig

type P2PConfig struct {
	Host                string   `mapstructure:"host"`
	DNSSeeds            []string `mapstructure:"dns_seeds"`
	FixedSeeds          []string `mapstructure:"seed_peers"`
	MaxInboundPeers     int      `mapstructure:"max_inbound_peers"`
	MaxOutboundPeers    int      `mapstructure:"max_outbound_peers"`
	ConnectionTimeoutMS int      `mapstructure:"connection_timeout_ms"`
}

type PeerExchangerConfig

type PeerExchangerConfig struct {
	SampleSize         int `mapstructure:"sample_size"`
	ResponseTimeoutMS  int `mapstructure:"response_timeout_ms"`
	RequestIntervalMS  int `mapstructure:"request_interval_ms"`
	MaxSentPeers       int `mapstructure:"max_sent_peers"`
	MaxReceivedPeers   int `mapstructure:"max_received_peers"`
	MaxConcurrentDials int `mapstructure:"max_concurrent_dials"`
}

type RPCConfig

type RPCConfig struct {
	Host string `mapstructure:"host"`
	Port int    `mapstructure:"port"`
}

type SectorServerConfig

type SectorServerConfig struct {
	CacheExpiryMS int `mapstructure:"cache_expiry_ms"`
}

type SyncerConfig

type SyncerConfig struct {
	TreeBaseResponseTimeoutMS int `mapstructure:"tree_base_response_timeout_ms"`
	SectorResponseTimeoutMS   int `mapstructure:"sector_response_timeout_ms"`
}

type TimebankConfig

type TimebankConfig struct {
	PeriodMS             int `mapstructure:"period_ms"`
	MinUpdateIntervalMS  int `mapstructure:"min_update_interval_ms"`
	FullUpdatesPerPeriod int `mapstructure:"full_updates_per_period"`
}

type TuningConfig

type TuningConfig struct {
	Timebank      TimebankConfig      `mapstructure:"timebank"`
	UpdateQueue   UpdateQueueConfig   `mapstructure:"update_queue"`
	Updater       UpdaterConfig       `mapstructure:"updater"`
	Syncer        SyncerConfig        `mapstructure:"syncer"`
	SectorServer  SectorServerConfig  `mapstructure:"sector_server"`
	PeerExchanger PeerExchangerConfig `mapstructure:"peer_exchanger"`
	NameImporter  NameImporterConfig  `mapstructure:"name_importer"`
	Heartbeat     HeartbeaterConfig   `mapstructure:"heartbeat"`
	NameSyncer    NameSyncerConfig    `mapstructure:"name_syncer"`
}

type UpdateQueueConfig

type UpdateQueueConfig struct {
	MaxLen         int `mapstructure:"max_len"`
	ReapIntervalMS int `mapstructure:"reap_interval_ms"`
}

type UpdaterConfig

type UpdaterConfig struct {
	PollIntervalMS int `mapstructure:"poll_interval_ms"`
	Workers        int `mapstructure:"workers"`
}

Jump to

Keyboard shortcuts

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