config

package
v0.25.1 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: LGPL-3.0 Imports: 15 Imported by: 9

Documentation

Index

Constants

View Source
const (
	DefaultDataDir          = "datadir"
	DefaultPort             = 40404
	DefaultRpcHost          = "localhost"
	DefaultRpcPort          = 9009
	DefaultIpfsDataDir      = "ipfs"
	DefaultIpfsPort         = 40405
	DefaultGodAddress       = "0x4d60dc6a2cba8c3ef1ba5e1eba5c12c54cee6b61"
	DefaultCeremonyTime     = int64(1567171800)
	DefaultSwarmKey         = "00d6f96bb2b02a7308ad87938d6139a974b555cc029ce416641a60c46db2f531"
	DefaultForceFullSync    = 100
	DefaultStoreCertRange   = 2000
	DefaultMaxInboundPeers  = 12
	DefaultMaxOutboundPeers = 6
	DefaultBurntTxRange     = 180

	LowPowerMaxInboundPeers  = 6
	LowPowerMaxOutboundPeers = 3
)
View Source
const (
	FlipLottery      = 5 * time.Minute
	ShortSession     = 2 * time.Minute
	AfterLongSession = 1 * time.Minute
)
View Source
const (
	LowPowerProfile = "lowpower"
)

Variables

View Source
var (
	DefaultIpfsBootstrapNodes = []string{
		"/ip4/64.227.41.45/tcp/40405/ipfs/QmfJktBd2jf37Jx3eCYyn1fofbW511U5XvYiMp7233mLZM",
		"/ip4/135.181.40.10/tcp/40405/ipfs/QmNYWtiwM1UfeCmHfWSdefrMuQdg6nycY5yS64HYqWCUhD",
		"/ip4/165.227.91.202/tcp/40403/ipfs/QmZ9VnVZsokXEttRYiHbHmCUBSdzSQywjj5wM3Me96XoVD",
		"/ip4/161.35.18.60/tcp/40405/ipfs/QmaBWm6dXsc6Y1MZ1x4ZTqHdjy32PGmyGmNPmHnxGGgrXF",
	}
	CfgFileFlag = cli.StringFlag{
		Name:  "config",
		Usage: "JSON configuration file",
	}
	DataDirFlag = cli.StringFlag{
		Name:  "datadir",
		Usage: "datadir for blockchain",
	}
	TcpPortFlag = cli.IntFlag{
		Name:  "port",
		Usage: "Network listening port",
	}
	RpcHostFlag = cli.StringFlag{
		Name:  "rpcaddr",
		Usage: "RPC listening address",
	}
	RpcPortFlag = cli.IntFlag{
		Name:  "rpcport",
		Usage: "RPC listening port",
	}
	BootNodeFlag = cli.StringFlag{
		Name:  "bootnode",
		Usage: "Bootstrap node url",
	}
	AutomineFlag = cli.BoolFlag{
		Name:  "automine",
		Usage: "Mine blocks alone without peers",
	}
	IpfsBootNodeFlag = cli.StringFlag{
		Name:  "ipfsbootnode",
		Usage: "Ipfs bootstrap node (overrides existing)",
	}
	IpfsPortFlag = cli.IntFlag{
		Name:  "ipfsport",
		Usage: "Ipfs port",
	}
	NoDiscoveryFlag = cli.BoolFlag{
		Name:  "nodiscovery",
		Usage: "NoDiscovery can be used to disable the peer discovery mechanism.",
	}
	VerbosityFlag = cli.IntFlag{
		Name:  "verbosity",
		Usage: "Log verbosity",
		Value: 3,
	}
	GodAddressFlag = cli.StringFlag{
		Name:  "godaddress",
		Usage: "Idena god address",
	}
	CeremonyTimeFlag = cli.Int64Flag{
		Name:  "ceremonytime",
		Usage: "First ceremony time (unix)",
	}
	MaxNetworkDelayFlag = cli.IntFlag{
		Name:  "maxnetdelay",
		Usage: "Max network delay for broadcasting",
	}
	FastSyncFlag = cli.BoolFlag{
		Name:  "fast",
		Usage: "Enable fast sync",
	}
	ForceFullSyncFlag = cli.Uint64Flag{
		Name:  "forcefullsync",
		Usage: "Force full sync on last blocks",
	}
	ProfileFlag = cli.StringFlag{
		Name:  "profile",
		Usage: "Configuration profile",
	}
	IpfsPortStaticFlag = cli.BoolFlag{
		Name:  "ipfsportstatic",
		Usage: "Enable static ipfs port",
	}
	ApiKeyFlag = cli.StringFlag{
		Name:  "apikey",
		Usage: "Set RPC api key",
	}
	LogFileSizeFlag = cli.IntFlag{
		Name:  "logfilesize",
		Usage: "Set log file size in KB",
		Value: 1024 * 100,
	}
	LogColoring = cli.BoolFlag{
		Name:  "logcoloring",
		Usage: "Use log coloring",
	}
)
View Source
var (
	ConsensusVersions map[ConsensusVerson]*ConsensusConf
)

Functions

func ApplyConsensusVersion added in v0.23.0

func ApplyConsensusVersion(ver ConsensusVerson, cfg *ConsensusConf)

Types

type BlockchainConfig

type BlockchainConfig struct {
	// distance between blocks with permanent certificates
	StoreCertRange uint64
	BurnTxRange    uint64
}

type Config

type Config struct {
	DataDir          string
	Network          uint32
	Consensus        *ConsensusConf
	P2P              P2P
	RPC              *rpc.Config
	GenesisConf      *GenesisConf
	IpfsConf         *IpfsConfig
	Validation       *ValidationConfig
	Sync             *SyncConfig
	OfflineDetection *OfflineDetectionConfig
	Blockchain       *BlockchainConfig
	Mempool          *Mempool
}

func MakeConfig

func MakeConfig(ctx *cli.Context, cfgTransform func(cfg *Config)) (*Config, error)

func MakeConfigFromFile

func MakeConfigFromFile(file string) (*Config, error)

func MakeMobileConfig

func MakeMobileConfig(path string, cfg string) (*Config, error)

func (*Config) KeyStoreDataDir

func (c *Config) KeyStoreDataDir() (string, error)

func (*Config) NodeDB

func (c *Config) NodeDB() string

NodeDB returns the path to the discovery node database.

func (*Config) NodeKey

func (c *Config) NodeKey() (*ecdsa.PrivateKey, error)

func (*Config) ProvideNodeKey

func (c *Config) ProvideNodeKey(key string, password string, withBackup bool) error

func (*Config) SetApiKey

func (c *Config) SetApiKey() error

type ConsensusConf

type ConsensusConf struct {
	Version                     ConsensusVerson
	StartActivationDate         int64 // unix timestamp
	EndActivationDate           int64 // unix timestamp
	MigrationTimeout            time.Duration
	GenerateGenesisAfterUpgrade bool

	MaxSteps                          uint8
	AgreementThreshold                float64
	CommitteePercent                  float64
	FinalCommitteePercent             float64
	WaitBlockDelay                    time.Duration
	WaitSortitionProofDelay           time.Duration
	EstimatedBaVariance               time.Duration
	WaitForStepDelay                  time.Duration
	Automine                          bool
	BlockReward                       *big.Int
	StakeRewardRate                   float32
	StakeRewardRateForNewbie          float32
	FinalCommitteeReward              *big.Int
	FeeBurnRate                       float32
	SnapshotRange                     uint64
	OfflinePenaltyBlocksCount         int64
	SuccessfulValidationRewardPercent float32
	FlipRewardPercent                 float32
	ValidInvitationRewardPercent      float32
	FoundationPayoutsPercent          float32
	ZeroWalletPercent                 float32
	FirstInvitationRewardCoef         float32
	SecondInvitationRewardCoef        float32
	ThirdInvitationRewardCoef         float32
	SavedInviteRewardCoef             float32
	SavedInviteWinnerRewardCoef       float32
	FeeSensitivityCoef                float32
	MinBlockDistance                  time.Duration
	MaxCommitteeSize                  int
	StatusSwitchRange                 uint64
	DelegationSwitchRange             uint64
	InvitesPercent                    float32
	MinProposerThreshold              float64
	UpgradeIntervalBeforeValidation   time.Duration
	EnablePools                       bool
	UpdateContracts                   bool
	DisableSavedInviteRewards         bool
}

func GetDefaultConsensusConfig

func GetDefaultConsensusConfig() *ConsensusConf

type ConsensusVerson added in v0.23.0

type ConsensusVerson uint16
const (
	// Enables contracts
	ConsensusV3 ConsensusVerson = 3
	// Enables pools
	ConsensusV4 ConsensusVerson = 4
)

type GenesisAllocation

type GenesisAllocation struct {
	Balance *big.Int
	Stake   *big.Int
	State   uint8
}

type GenesisConf

type GenesisConf struct {
	Alloc             map[common.Address]GenesisAllocation
	GodAddress        common.Address
	FirstCeremonyTime int64
	GodAddressInvites uint16
}

type IpfsConfig

type IpfsConfig struct {
	DataDir            string
	BootNodes          []string
	IpfsPort           int
	StaticPort         bool
	SwarmKey           string
	Routing            string
	LowWater           int
	HighWater          int
	GracePeriod        string
	ReproviderInterval string
	Profile            string
	BlockPinThreshold  float32
	FlipPinThreshold   float32
}

func GetDefaultIpfsConfig added in v0.19.2

func GetDefaultIpfsConfig() *IpfsConfig

type Mempool added in v0.19.2

type Mempool struct {
	TxPoolQueueSlots      int
	TxPoolExecutableSlots int

	TxPoolAddrQueueLimit      int
	TxPoolAddrExecutableLimit int
	TxLifetime                time.Duration
}

func GetDefaultMempoolConfig added in v0.19.2

func GetDefaultMempoolConfig() *Mempool

type OfflineDetectionConfig

type OfflineDetectionConfig struct {
	PersistInterval             int
	MaxSelfOffline              time.Duration
	OfflineProposeInterval      time.Duration
	OfflineVoteInterval         time.Duration
	IntervalBetweenOfflineRetry time.Duration
}

func GetDefaultOfflineDetectionConfig

func GetDefaultOfflineDetectionConfig() *OfflineDetectionConfig

type P2P

type P2P struct {
	MaxInboundPeers  int
	MaxOutboundPeers int
	MaxDelay         int
	DisableMetrics   bool
}

type SyncConfig

type SyncConfig struct {
	FastSync      bool
	ForceFullSync uint64
	LoadAllFlips  bool
}

type ValidationConfig

type ValidationConfig struct {
	// Do not use directly
	ValidationInterval time.Duration
	// Do not use directly
	FlipLotteryDuration time.Duration
	// Do not use directly
	ShortSessionDuration time.Duration
	// Do not use directly
	LongSessionDuration time.Duration
}

func (*ValidationConfig) GetFlipLotteryDuration

func (cfg *ValidationConfig) GetFlipLotteryDuration() time.Duration

func (*ValidationConfig) GetLongSessionDuration

func (cfg *ValidationConfig) GetLongSessionDuration(networkSize int) time.Duration

func (*ValidationConfig) GetNextValidationTime

func (cfg *ValidationConfig) GetNextValidationTime(validationTime time.Time, networkSize int) time.Time

func (*ValidationConfig) GetShortSessionDuration

func (cfg *ValidationConfig) GetShortSessionDuration() time.Duration

Jump to

Keyboard shortcuts

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