config

package
v0.99.2-pre Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2022 License: MIT Imports: 11 Imported by: 4

Documentation

Overview

Package config contains NeoGo node configuration definition.

Index

Constants

View Source
const (
	// UserAgentWrapper is a string that user agent string should be wrapped into.
	UserAgentWrapper = "/"
	// UserAgentPrefix is a prefix used to generate user agent string.
	UserAgentPrefix = "NEO-GO:"
	// UserAgentFormat is a formatted string used to generate user agent string.
	UserAgentFormat = UserAgentWrapper + UserAgentPrefix + "%s" + UserAgentWrapper
	// DefaultMaxIteratorResultItems is the default upper bound of traversed
	// iterator items per JSON-RPC response.
	DefaultMaxIteratorResultItems = 100
)

Variables

View Source
var Version string

Version is the version of the node, set at the build time.

Functions

func IsHardforkValid added in v0.99.0

func IsHardforkValid(s string) bool

IsHardforkValid denotes whether the provided string represents a valid Hardfork name.

Types

type ApplicationConfiguration

type ApplicationConfiguration struct {
	Address           string                   `yaml:"Address"`
	AnnouncedNodePort uint16                   `yaml:"AnnouncedPort"`
	AttemptConnPeers  int                      `yaml:"AttemptConnPeers"`
	DBConfiguration   dbconfig.DBConfiguration `yaml:"DBConfiguration"`
	DialTimeout       int64                    `yaml:"DialTimeout"`
	LogPath           string                   `yaml:"LogPath"`
	MaxPeers          int                      `yaml:"MaxPeers"`
	MinPeers          int                      `yaml:"MinPeers"`
	NodePort          uint16                   `yaml:"NodePort"`
	PingInterval      int64                    `yaml:"PingInterval"`
	PingTimeout       int64                    `yaml:"PingTimeout"`
	Pprof             BasicService             `yaml:"Pprof"`
	Prometheus        BasicService             `yaml:"Prometheus"`
	ProtoTickInterval int64                    `yaml:"ProtoTickInterval"`
	Relay             bool                     `yaml:"Relay"`
	RPC               RPC                      `yaml:"RPC"`
	UnlockWallet      Wallet                   `yaml:"UnlockWallet"`
	Oracle            OracleConfiguration      `yaml:"Oracle"`
	P2PNotary         P2PNotary                `yaml:"P2PNotary"`
	StateRoot         StateRoot                `yaml:"StateRoot"`
	// ExtensiblePoolSize is the maximum amount of the extensible payloads from a single sender.
	ExtensiblePoolSize int `yaml:"ExtensiblePoolSize"`
}

ApplicationConfiguration config specific to the node.

type BasicService added in v0.99.1

type BasicService struct {
	Enabled bool   `yaml:"Enabled"`
	Address string `yaml:"Address"`
	Port    string `yaml:"Port"`
}

BasicService is used for simple services like Pprof or Prometheus monitoring.

type Config

type Config struct {
	ProtocolConfiguration    ProtocolConfiguration    `yaml:"ProtocolConfiguration"`
	ApplicationConfiguration ApplicationConfiguration `yaml:"ApplicationConfiguration"`
}

Config top level struct representing the config for the node.

func Load

func Load(path string, netMode netmode.Magic) (Config, error)

Load attempts to load the config from the given path for the given netMode.

func LoadFile added in v0.90.0

func LoadFile(configPath string) (Config, error)

LoadFile loads config from the provided path.

func (Config) GenerateUserAgent

func (c Config) GenerateUserAgent() string

GenerateUserAgent creates a user agent string based on the build time environment.

type Hardfork added in v0.99.0

type Hardfork byte

Hardfork represents the application hard-fork identifier.

const (
	// HFAspidochelone represents hard-fork introduced in #2469 (ported from
	// https://github.com/neo-project/neo/pull/2712) and #2519 (ported from
	// https://github.com/neo-project/neo/pull/2749).
	HFAspidochelone Hardfork = 1 << iota // Aspidochelone
)

func (Hardfork) String added in v0.99.0

func (i Hardfork) String() string

type NeoFSConfiguration added in v0.94.0

type NeoFSConfiguration struct {
	Nodes   []string      `yaml:"Nodes"`
	Timeout time.Duration `yaml:"Timeout"`
}

NeoFSConfiguration is a config for the NeoFS service.

type OracleConfiguration added in v0.93.0

type OracleConfiguration struct {
	Enabled               bool               `yaml:"Enabled"`
	AllowPrivateHost      bool               `yaml:"AllowPrivateHost"`
	AllowedContentTypes   []string           `yaml:"AllowedContentTypes"`
	Nodes                 []string           `yaml:"Nodes"`
	NeoFS                 NeoFSConfiguration `yaml:"NeoFS"`
	MaxTaskTimeout        time.Duration      `yaml:"MaxTaskTimeout"`
	RefreshInterval       time.Duration      `yaml:"RefreshInterval"`
	MaxConcurrentRequests int                `yaml:"MaxConcurrentRequests"`
	RequestTimeout        time.Duration      `yaml:"RequestTimeout"`
	ResponseTimeout       time.Duration      `yaml:"ResponseTimeout"`
	UnlockWallet          Wallet             `yaml:"UnlockWallet"`
}

OracleConfiguration is a config for the oracle module.

type P2PNotary added in v0.93.0

type P2PNotary struct {
	Enabled      bool   `yaml:"Enabled"`
	UnlockWallet Wallet `yaml:"UnlockWallet"`
}

P2PNotary stores configuration for Notary node service.

type ProtocolConfiguration

type ProtocolConfiguration struct {
	// CommitteeHistory stores committee size change history (height: size).
	CommitteeHistory map[uint32]int `yaml:"CommitteeHistory"`
	// GarbageCollectionPeriod sets the number of blocks to wait before
	// starting the next MPT garbage collection cycle when RemoveUntraceableBlocks
	// option is used.
	GarbageCollectionPeriod uint32 `yaml:"GarbageCollectionPeriod"`

	Magic       netmode.Magic `yaml:"Magic"`
	MemPoolSize int           `yaml:"MemPoolSize"`

	// Hardforks is a map of hardfork names that enables version-specific application
	// logic dependent on the specified height.
	Hardforks map[string]uint32 `yaml:"Hardforks"`
	// InitialGASSupply is the amount of GAS generated in the genesis block.
	InitialGASSupply fixedn.Fixed8 `yaml:"InitialGASSupply"`
	// P2PNotaryRequestPayloadPoolSize specifies the memory pool size for P2PNotaryRequestPayloads.
	// It is valid only if P2PSigExtensions are enabled.
	P2PNotaryRequestPayloadPoolSize int `yaml:"P2PNotaryRequestPayloadPoolSize"`
	// KeepOnlyLatestState specifies if MPT should only store the latest state.
	// If true, DB size will be smaller, but older roots won't be accessible.
	// This value should remain the same for the same database.
	KeepOnlyLatestState bool `yaml:"KeepOnlyLatestState"`
	// RemoveUntraceableBlocks specifies if old data should be removed.
	RemoveUntraceableBlocks bool `yaml:"RemoveUntraceableBlocks"`
	// MaxBlockSize is the maximum block size in bytes.
	MaxBlockSize uint32 `yaml:"MaxBlockSize"`
	// MaxBlockSystemFee is the maximum overall system fee per block.
	MaxBlockSystemFee int64 `yaml:"MaxBlockSystemFee"`
	// MaxTraceableBlocks is the length of the chain accessible to smart contracts.
	MaxTraceableBlocks uint32 `yaml:"MaxTraceableBlocks"`
	// MaxTransactionsPerBlock is the maximum amount of transactions per block.
	MaxTransactionsPerBlock uint16 `yaml:"MaxTransactionsPerBlock"`
	// MaxValidUntilBlockIncrement is the upper increment size of blockchain height in blocks
	// exceeding that a transaction should fail validation. It is set to estimated daily number
	// of blocks with 15s interval.
	MaxValidUntilBlockIncrement uint32 `yaml:"MaxValidUntilBlockIncrement"`
	// NativeUpdateHistories is a list of histories of native contracts updates.
	NativeUpdateHistories map[string][]uint32 `yaml:"NativeActivations"`
	// P2PSigExtensions enables additional signature-related logic.
	P2PSigExtensions bool `yaml:"P2PSigExtensions"`
	// P2PStateExchangeExtensions enables additional P2P MPT state data exchange logic.
	P2PStateExchangeExtensions bool `yaml:"P2PStateExchangeExtensions"`
	// ReservedAttributes allows to have reserved attributes range for experimental or private purposes.
	ReservedAttributes bool `yaml:"ReservedAttributes"`
	// SaveStorageBatch enables storage batch saving before every persist.
	SaveStorageBatch bool     `yaml:"SaveStorageBatch"`
	SecondsPerBlock  int      `yaml:"SecondsPerBlock"`
	SeedList         []string `yaml:"SeedList"`
	StandbyCommittee []string `yaml:"StandbyCommittee"`
	// StateRooInHeader enables storing state root in block header.
	StateRootInHeader bool `yaml:"StateRootInHeader"`
	// StateSyncInterval is the number of blocks between state heights available for MPT state data synchronization.
	// It is valid only if P2PStateExchangeExtensions are enabled.
	StateSyncInterval int `yaml:"StateSyncInterval"`
	ValidatorsCount   int `yaml:"ValidatorsCount"`
	// Validators stores history of changes to consensus node number (height: number).
	ValidatorsHistory map[uint32]int `yaml:"ValidatorsHistory"`
	// Whether to verify received blocks.
	VerifyBlocks bool `yaml:"VerifyBlocks"`
	// Whether to verify transactions in the received blocks.
	VerifyTransactions bool `yaml:"VerifyTransactions"`
}

ProtocolConfiguration represents the protocol config.

func (*ProtocolConfiguration) GetCommitteeSize added in v0.98.2

func (p *ProtocolConfiguration) GetCommitteeSize(height uint32) int

GetCommitteeSize returns the committee size for the given height. It implies valid configuration file.

func (*ProtocolConfiguration) GetNumOfCNs added in v0.98.2

func (p *ProtocolConfiguration) GetNumOfCNs(height uint32) int

GetNumOfCNs returns the number of validators for the given height. It implies valid configuration file.

func (*ProtocolConfiguration) ShouldUpdateCommitteeAt added in v0.98.2

func (p *ProtocolConfiguration) ShouldUpdateCommitteeAt(height uint32) bool

ShouldUpdateCommitteeAt answers the question of whether the committee should be updated at the given height.

func (*ProtocolConfiguration) Validate added in v0.98.2

func (p *ProtocolConfiguration) Validate() error

Validate checks ProtocolConfiguration for internal consistency and returns an error if anything inappropriate found. Other methods can rely on protocol validity after this.

type RPC added in v0.99.1

type RPC struct {
	Address              string `yaml:"Address"`
	Enabled              bool   `yaml:"Enabled"`
	EnableCORSWorkaround bool   `yaml:"EnableCORSWorkaround"`
	// MaxGasInvoke is the maximum amount of GAS which
	// can be spent during an RPC call.
	MaxGasInvoke           fixedn.Fixed8 `yaml:"MaxGasInvoke"`
	MaxIteratorResultItems int           `yaml:"MaxIteratorResultItems"`
	MaxFindResultItems     int           `yaml:"MaxFindResultItems"`
	MaxNEP11Tokens         int           `yaml:"MaxNEP11Tokens"`
	Port                   uint16        `yaml:"Port"`
	SessionEnabled         bool          `yaml:"SessionEnabled"`
	SessionExpirationTime  int           `yaml:"SessionExpirationTime"`
	SessionBackedByMPT     bool          `yaml:"SessionBackedByMPT"`
	SessionPoolSize        int           `yaml:"SessionPoolSize"`
	StartWhenSynchronized  bool          `yaml:"StartWhenSynchronized"`
	TLSConfig              TLS           `yaml:"TLSConfig"`
}

RPC is an RPC service configuration information.

type StateRoot added in v0.94.0

type StateRoot struct {
	Enabled      bool   `yaml:"Enabled"`
	UnlockWallet Wallet `yaml:"UnlockWallet"`
}

StateRoot contains state root service configuration.

type TLS added in v0.99.1

type TLS struct {
	Address  string `yaml:"Address"`
	CertFile string `yaml:"CertFile"`
	Enabled  bool   `yaml:"Enabled"`
	Port     uint16 `yaml:"Port"`
	KeyFile  string `yaml:"KeyFile"`
}

TLS describes SSL/TLS configuration.

type Wallet added in v0.90.0

type Wallet struct {
	Path     string `yaml:"Path"`
	Password string `yaml:"Password"`
}

Wallet is a wallet info.

Directories

Path Synopsis
Package limits contains a number of system-wide hardcoded constants.
Package limits contains a number of system-wide hardcoded constants.
Package netmode contains well-known network magic numbers.
Package netmode contains well-known network magic numbers.

Jump to

Keyboard shortcuts

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