config

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: May 2, 2020 License: LGPL-3.0 Imports: 22 Imported by: 11

Documentation

Overview

Package config contains the normal config for other modules.

Package config contains the normal config for other modules.

Package config contains the normal config for other modules.

Package config contains the normal config for other modules.

Package config contains the normal config for other modules.

Package config contains the normal config for other modules.

Index

Constants

View Source
const (
	DefaultRpcHost = "localhost" // Default host interface for the RPC server
	DefaultRpcPort = 8545        // Default TCP port for the RPC server
	DefaultDataDir = "data"      // Default data dir for the node

)

Variables

View Source
var (
	MainnetChainID     = uint64(1)
	MainnetChainConfig = &ChainConfig{ChainID: MainnetChainID, Greedy: 4, TxExecutorType: "wasm", TxSignerType: "eip155", BlockSigFake: false, MaxNonceBitLength: 1024, CheckPointEnable: false, PackerGroupSize: 1}

	TestnetChainID     = uint64(2)
	TestnetChainConfig = &ChainConfig{ChainID: TestnetChainID, Greedy: 4, TxExecutorType: "wasm", TxSignerType: "eip155", BlockSigFake: false, MaxNonceBitLength: 1024000, CheckPointEnable: false, PackerGroupSize: 1}

	Testnet2ChainID     = uint64(3)
	Testnet2ChainConfig = &ChainConfig{ChainID: Testnet2ChainID, Greedy: 4, TxExecutorType: "wasm", TxSignerType: "eip155", BlockSigFake: false, MaxNonceBitLength: 1024000, CheckPointEnable: false, PackerGroupSize: 1}

	Testnet3ChainID     = uint64(4)
	Testnet3ChainConfig = &ChainConfig{ChainID: Testnet3ChainID, Greedy: 4, TxExecutorType: "wasm", TxSignerType: "eip155", BlockSigFake: false, MaxNonceBitLength: 1024000, CheckPointEnable: false, PackerGroupSize: 1}

	ErrChainConfigConflict = errors.New("Input chain config conflicts with the stored chain config")
	ErrPackerGroupSize     = errors.New("Input chain config param:<PackerGroupSize> can't be 0")
)
View Source
var DefaultConfig = Config{
	FakeMode: false,

	DatabaseCache: 768,

	PkgCacheSize:        1024,
	PackerInfoCacheSize: 16,

	PackerEnable:      false,
	PackerInterval:    1,
	PackerCollectAddr: ":8899",

	MinerEnable:   false,
	TxPoolConfig:  &DefaultPoolConfig,
	PkgPoolConfig: &DefaultPoolConfig,
	SyncConfig:    &DefaultSyncConfig,
	SyncTest:      false,
}

DefaultConfig contains default settings for use on the Fractal private net.

View Source
var DefaultGenesisRound = uint64(time.Date(2020, 5, 2, 2, 0, 0, 0, time.UTC).Unix() * params.RoundsPerSecond)
View Source
var DefaultMainnetConfig = Config{
	FakeMode: false,

	DatabaseCache: 768,

	ChainConfig: MainnetChainConfig,
	Genesis:     DefaultMainnetGenesisBlock(),

	PkgCacheSize:        1024,
	PackerInfoCacheSize: 16,

	PackerEnable:      false,
	PackerInterval:    1,
	PackerCollectAddr: ":8899",

	MinerEnable:   false,
	TxPoolConfig:  &DefaultPoolConfig,
	PkgPoolConfig: &DefaultPoolConfig,
	SyncConfig:    &DefaultSyncConfig,
	SyncTest:      false,
}

DefaultMainnetConfig contains default settings for use on the Fractal main net.

View Source
var DefaultPoolConfig = PoolConfig{
	NoLocals:    true,
	FakeMode:    false,
	Journal:     "elements.rlp",
	Rejournal:   time.Hour,
	PriceLimit:  1,
	PriceBump:   10,
	GlobalQueue: 4096,
	Lifetime:    3 * time.Hour,
}

DefaultPoolConfig contains the default configurations for the transaction pool.

View Source
var DefaultSyncConfig = SyncConfig{
	PeriodSyncCycle:               10,
	MinRegularPeerCount:           1,
	MinFastSyncPeerCount:          1,
	CommonPrefixCount:             3,
	HeightDiff:                    30,
	ShortHashListLength:           30,
	Interval:                      200,
	CheckMainChainPostBlockLength: 20,

	TimeOutOfFixPointPreBlock:     120000000,
	LongTimeOutOfFixPointFinish:   120000000,
	LongTimeOutOfFullfillLongList: 120000000,
	LongTimeOutOfIntevalList:      120000000,
	LongTimeOutOfLongList:         120000000,

	ShortTimeOutOfSyncVeryHigh: 60000000,
	ShortTimeOutOfShortLists:   60000000,
	ShortTimeOutOfPeriodSync:   60000000,
}

DefaultPoolConfig contains the default configurations for the transaction pool.

View Source
var DefaultTestnet2Config = Config{
	FakeMode: false,

	DatabaseCache: 768,

	ChainConfig: Testnet2ChainConfig,
	Genesis:     DefaultTestnet2GenesisBlock(),

	PkgCacheSize:        1024,
	PackerInfoCacheSize: 16,

	PackerEnable:      false,
	PackerInterval:    1,
	PackerCollectAddr: ":9899",

	MinerEnable:   false,
	TxPoolConfig:  &DefaultPoolConfig,
	PkgPoolConfig: &DefaultPoolConfig,
	SyncConfig:    &DefaultSyncConfig,
	SyncTest:      false,
}

DefaultConfig contains default settings for use on the Fractal test net.

View Source
var DefaultTestnet3Config = Config{
	FakeMode: false,

	DatabaseCache: 768,

	ChainConfig: Testnet3ChainConfig,
	Genesis:     DefaultTestnet3GenesisBlock(),

	PkgCacheSize:        1024,
	PackerInfoCacheSize: 16,

	PackerEnable:      false,
	PackerInterval:    2,
	PackerCollectAddr: ":9899",

	MinerEnable:   false,
	TxPoolConfig:  &DefaultPoolConfig,
	PkgPoolConfig: &DefaultPoolConfig,
	SyncConfig:    &DefaultSyncConfig,
	SyncTest:      false,
}

DefaultConfig contains default settings for use on the Fractal test net.

View Source
var DefaultTestnetConfig = Config{
	FakeMode: false,

	DatabaseCache: 768,

	ChainConfig: TestnetChainConfig,
	Genesis:     DefaultTestnetGenesisBlock(),

	PkgCacheSize:        1024,
	PackerInfoCacheSize: 16,

	PackerEnable:      false,
	PackerInterval:    1,
	PackerCollectAddr: ":9899",

	MinerEnable:   false,
	TxPoolConfig:  &DefaultPoolConfig,
	PkgPoolConfig: &DefaultPoolConfig,
	SyncConfig:    &DefaultSyncConfig,
	SyncTest:      false,
}

DefaultConfig contains default settings for use on the Fractal test net.

Functions

func SetupGenesisBlock

func SetupGenesisBlock(db dbwrapper.Database, genesis *Genesis) (common.Hash, error)

SetupChainConfig determine the genesis block of the current chain, and write the genesis block to db.

Types

type ChainConfig

type ChainConfig struct {
	ChainID           uint64 `json:"chainId"` // chainId identifies the current chain and is used for replay protection
	Greedy            uint8  `json:"greedy"`  //
	TxExecutorType    string `json:"txExecutorType"`
	TxSignerType      string `json:"txSignerType"`
	BlockSigFake      bool   `json:"blockSigFake"`
	MaxNonceBitLength uint64 `json:"maxNonceBitLength"`
	CheckPointEnable  bool   `json:"checkPointEnable"`
	PackerGroupSize   uint64 `json:"packerGroupSize"`
}

ChainConfig is the config for the current chain. ChainConfig will be stored in the database while initializing the chain.

func SetupChainConfig

func SetupChainConfig(db dbwrapper.Database, config *ChainConfig) (*ChainConfig, error)

SetupChainConfig determine the current chain config, and write chain config to db.

type CheckPoint

type CheckPoint struct {
	Hash   common.Hash `json:"hash" gencodec:"required"`
	Height uint64      `json:"height" gencodec:"required"`
	Round  uint64      `json:"round" gencodec:"required"`
}

func GetCheckPointBelowBlock

func GetCheckPointBelowBlock(block *types.Block, points *CheckPoints) CheckPoint

func GetLatestCheckPoint

func GetLatestCheckPoint(points *CheckPoints) CheckPoint

type CheckPoints

type CheckPoints map[uint64]CheckPoint

func (*CheckPoints) UnmarshalJSON

func (cps *CheckPoints) UnmarshalJSON(data []byte) error

type Config

type Config struct {
	FakeMode bool

	// Database options
	DatabaseHandles int `toml:"-"`
	DatabaseCache   int `toml:"-"`

	//
	NodeConfig *NodeConfig `toml:",omitempty"`

	// The chain config
	// If nil, the Fractal mainnet config will be used.
	ChainConfig *ChainConfig `toml:",omitempty"`

	// sync config
	// when there is need to do fast sync
	SyncConfig *SyncConfig

	Genesis *Genesis

	KeyPass string

	PkgCacheSize        int
	PackerInfoCacheSize uint8

	PackerEnable      bool
	PackerId          uint32
	PackerInterval    int
	PackerCollectAddr string
	PackerKeyFolder   string

	TxBatchSendToPackInterval int
	TxSaveProcessInterval     int

	MinerEnable    bool
	TxPoolConfig   *PoolConfig `toml:",omitempty"`
	PkgPoolConfig  *PoolConfig `toml:",omitempty"`
	MinerKeyFolder string

	CheckPoints *CheckPoints // checkPoints

	SyncTest bool
}

type Genesis

type Genesis struct {
	Round      uint64         `json:"round"            gencodec:"required"`
	PubKey     []byte         `json:"pubKey"           gencodec:"required"`
	Sig        []byte         `json:"sig"              gencodec:"required"`
	Coinbase   common.Address `json:"miner"            gencodec:"required"`
	Difficulty *big.Int       `json:"difficulty"       gencodec:"required"`
	Alloc      GenesisAlloc   `json:"alloc"            gencodec:"required"`
}

Genesis specifies the header fields of genesis block, and the genesis state of the chain.

func DefaultMainnetGenesisBlock

func DefaultMainnetGenesisBlock() *Genesis

DefaultGenesisBlock returns the main net genesis block.

func DefaultTestnet2GenesisBlock

func DefaultTestnet2GenesisBlock() *Genesis

DefaultTestnet2GenesisBlock returns the test2 network genesis block.

func DefaultTestnet3GenesisBlock

func DefaultTestnet3GenesisBlock() *Genesis

DefaultTestnet3GenesisBlock returns the test3 network genesis block.

func DefaultTestnetGenesisBlock

func DefaultTestnetGenesisBlock() *Genesis

DefaultTestnetGenesisBlock returns the test network genesis block.

func (*Genesis) Commit

func (g *Genesis) Commit(db dbwrapper.Database) (*types.Block, error)

Commit writes the block and state of a genesis specification to the database. The block is committed as the canonical head block.

func (*Genesis) ToBlock

func (g *Genesis) ToBlock(db dbwrapper.Database) *types.Block

ToBlock creates the genesis block and writes state of a genesis specification to the given database (or discards it if nil).

type GenesisAccount

type GenesisAccount state.AccountForStorage

GenesisAccount is an account in the state of the genesis block.

type GenesisAlloc

type GenesisAlloc map[common.Address]GenesisAccount

GenesisAlloc specifies the initial state that is part of the genesis block.

func (*GenesisAlloc) UnmarshalJSON

func (ga *GenesisAlloc) UnmarshalJSON(data []byte) error

type GenesisMismatchError

type GenesisMismatchError struct {
	StoredGenesisHash common.Hash
	NewGenesisHash    common.Hash
}

GenesisMismatchError raised when stored genesis block conflicts with the input genesis config

func (*GenesisMismatchError) Error

func (e *GenesisMismatchError) Error() string

type NodeConfig

type NodeConfig struct {
	// UserIdent, if set, is used as an additional component in the devp2p node identifier.
	UserIdent string `toml:",omitempty"`

	// Version should be set to the version number of the program. It is used
	// in the devp2p node identifier.
	Version string `toml:"-"`

	// DataDir is the file system folder the node should use for any data storage
	// requirements. The configured data directory will not be directly shared with
	// registered services, instead those can use utility methods to create/access
	// databases or flat files. This enables ephemeral nodes which can fully reside
	// in memory.
	DataDir string

	// Configuration of peer-to-peer networking.
	P2P p2p.Config

	// UseLightweightKDF lowers the memory and CPU requirements of the key store
	// scrypt KDF at the expense of security.
	UseLightweightKDF bool `toml:",omitempty"`

	// RpcEndpoint is the interface for the RPC server.
	RpcEndpoint string `toml:",omitempty"`

	//
	RpcApiList []string

	HTTPCors []string

	// Logger is a custom logger to use with the p2p.Server.
	Logger log.Logger `toml:",omitempty"`
}

NodeConfig represents the config set for the running node

func NewNodeConfig

func NewNodeConfig() *NodeConfig

NewNodeConfig creates the default NodeConfig and return it

func (*NodeConfig) NodeDB

func (c *NodeConfig) NodeDB() string

NodeDB returns the path to the discovery node database.

func (*NodeConfig) NodeKey

func (c *NodeConfig) NodeKey() *ecdsa.PrivateKey

NodeKey retrieves the currently configured private key of the node, checking first any manually set key, falling back to the one found in the configured data folder. If no key can be found, a new one is generated.

func (*NodeConfig) NodeName

func (c *NodeConfig) NodeName() string

NodeName returns the devp2p node identifier.

func (*NodeConfig) Progname

func (c *NodeConfig) Progname() string

func (*NodeConfig) ResolvePath

func (c *NodeConfig) ResolvePath(path string) string

ResolvePath resolves path in the instance directory.

func (*NodeConfig) StaticNodes

func (c *NodeConfig) StaticNodes() []*discover.Node

StaticNodes returns a list of node enode URLs configured as static nodes.

func (*NodeConfig) TrustedNodes

func (c *NodeConfig) TrustedNodes() []*discover.Node

TrustedNodes returns a list of node enode URLs configured as trusted nodes.

type PoolConfig

type PoolConfig struct {
	Locals      []common.Address // Addresses that should be treated by default as local
	NoLocals    bool             // Whether local transaction handling should be disabled
	FakeMode    bool
	Journal     string        // Journal of local transactions to survive node restarts
	Rejournal   time.Duration // Time interval to regenerate the local transaction journal
	PriceLimit  uint64        // Minimum gas price to enforce for acceptance into the pool
	PriceBump   uint64        // Minimum price bump percentage to replace an already existing transaction (nonce)
	GlobalQueue uint64        // Maximum number of non-executable transaction slots for all accounts
	Lifetime    time.Duration // Maximum amount of time non-executable transaction are queued

	// fake
	StartCleanTime     int64
	CleanPeriod        int64
	LeftEleNumEachAddr int
}

func (*PoolConfig) Sanitize

func (config *PoolConfig) Sanitize() PoolConfig

Sanitize checks the provided user configurations and changes anything that's unreasonable or unworkable.

type SyncConfig

type SyncConfig struct {
	PeriodSyncCycle               int   // Time interval to force syncs, even if few peers are available
	MinRegularPeerCount           int   // Amount of peers desired to start syncing
	MinFastSyncPeerCount          int   //amount for fast sync
	CommonPrefixCount             int   // honest peer amount should be equal or bigger than CommonPrefixCount
	HeightDiff                    int32 // bigger than heightDiff,it  will start fast sync:(HeightDiff >CheckMainChainPostBlockLength+)
	ShortHashListLength           int   //short hash list length
	Interval                      int   //first time to sync long hashList interval
	CheckMainChainPostBlockLength int   //should be less than shortHashListLength

	TimeOutOfFixPointPreBlock     int
	LongTimeOutOfFixPointFinish   int
	LongTimeOutOfFullfillLongList int
	LongTimeOutOfIntevalList      int
	LongTimeOutOfLongList         int

	ShortTimeOutOfSyncVeryHigh int
	ShortTimeOutOfShortLists   int
	ShortTimeOutOfPeriodSync   int
}

func (*SyncConfig) Sanitize

func (config *SyncConfig) Sanitize() SyncConfig

Sanitize checks the provided user configurations and changes anything that's unreasonable or unworkable.

Jump to

Keyboard shortcuts

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