conf

package
v3.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CommonWriteBlockType     = 0
	QuickWriteBlockType      = 1
	DbconfigProviderSql      = "sql"
	DbconfigProviderSqlKV    = "sqlkv" //虽然是用SQL数据库,但是当KV数据库使
	DbconfigProviderLeveldb  = "leveldb"
	DbconfigProviderMemdb    = "memdb" //内存数据库,只用于测试
	DbconfigProviderBadgerdb = "badgerdb"
	DbconfigProviderTikvdb   = "tikvdb"

	SqldbconfigSqldbtypeMysql  = "mysql"
	SqldbconfigSqldbtypeSqlite = "sqlite"
)

nolint

Variables

This section is empty.

Functions

This section is empty.

Types

type BigFilterConfig

type BigFilterConfig struct {
	RedisHosts string  `mapstructure:"redis_hosts_port"`
	Pass       string  `mapstructure:"redis_password"`
	TxCapacity uint    `mapstructure:"tx_capacity"`
	FpRate     float64 `mapstructure:"fp_rate"`
}

BigFilterConfig BigFilter config option

@Description:

type BlockFileConfig

type BlockFileConfig struct {
	OnlineFileSystem  string `mapstructure:"online_file_system"`
	ArchiveFileSystem string `mapstructure:"archive_file_system"`
}

BlockFileConfig Block file config option

@Description:

type CacheConfig

type CacheConfig struct {
	//Cache提供方,包括:bigcache,redis,等
	Provider string `mapstructure:"provider"`
	// Time after which entry can be evicted
	LifeWindow time.Duration `mapstructure:"life_window"`
	// Interval between removing expired entries (clean up).
	// If set to <= 0 then no action is performed.
	//Setting to < 1 second is counterproductive — bigcache has a one second resolution.
	CleanWindow time.Duration `mapstructure:"clean_window"`
	// Max size of entry in bytes. Used only to calculate initial size for cache shards.
	MaxEntrySize int `mapstructure:"max_entry_size"`
	// Max size of cache.
	HardMaxCacheSize int `mapstructure:"hard_max_cache_size"`
}

CacheConfig cache config option

@Description:

type DbConfig

type DbConfig struct {
	//leveldb,badgerdb,tikvdb,sql
	Provider       string                 `mapstructure:"provider"`
	LevelDbConfig  map[string]interface{} `mapstructure:"leveldb_config"`
	BadgerDbConfig map[string]interface{} `mapstructure:"badgerdb_config"`
	TikvDbConfig   map[string]interface{} `mapstructure:"tikvdb_config"`
	SqlDbConfig    map[string]interface{} `mapstructure:"sqldb_config"`
}

DbConfig encapsulate db config

@Description:

func (*DbConfig) GetDbConfig

func (c *DbConfig) GetDbConfig() map[string]interface{}

GetDbConfig get concrete db config according to type

@Description:
@receiver c
@return map[string]interface{}

func (*DbConfig) IsKVDB

func (dbc *DbConfig) IsKVDB() bool

IsKVDB check db satisfy kv standard

@Description:
@receiver dbc
@return bool

func (*DbConfig) IsSqlDB

func (dbc *DbConfig) IsSqlDB() bool

IsSqlDB check db satisfy sql standard

@Description:
@receiver dbc
@return bool

type HistoryDbConfig

type HistoryDbConfig struct {
	DbConfig               `mapstructure:",squash"`
	DisableKeyHistory      bool `mapstructure:"disable_key_history"`
	DisableContractHistory bool `mapstructure:"disable_contract_history"`
	DisableAccountHistory  bool `mapstructure:"disable_account_history"`
}

HistoryDbConfig config history db

@Description:

func NewHistoryDbConfig

func NewHistoryDbConfig(config *DbConfig) *HistoryDbConfig

NewHistoryDbConfig 创建historydb config

@Description:
@param config
@return *HistoryDbConfig

type StorageConfig

type StorageConfig struct {
	//默认的Leveldb配置,如果每个DB有不同的设置,可以在自己的DB中进行设置
	StorePath string `mapstructure:"store_path"`
	//写入区块数据存储方式,0-wal和db双写,1-只写wal,2-只写db
	//BlockDbType          uint8  `mapstructure:"block_db_type"`
	DbPrefix             string `mapstructure:"db_prefix"`
	WriteBufferSize      int    `mapstructure:"write_buffer_size"`
	BloomFilterBits      int    `mapstructure:"bloom_filter_bits"`
	BlockWriteBufferSize int    `mapstructure:"block_write_buffer_size"`
	//数据库模式:light只存区块头,normal存储区块头和交易以及生成的State,full存储了区块头、交易、状态和交易收据(读写集、日志等)
	//Mode string `mapstructure:"mode"`
	DisableBlockFileDb     bool             `mapstructure:"disable_block_file_db"`
	DisableHistoryDB       bool             `mapstructure:"disable_historydb"`
	DisableResultDB        bool             `mapstructure:"disable_resultdb"`
	DisableContractEventDB bool             `mapstructure:"disable_contract_eventdb"`
	DisableStateCache      bool             `mapstructure:"disable_state_cache"`
	EnableBigFilter        bool             `mapstructure:"enable_bigfilter"`
	LogDBSegmentAsync      bool             `mapstructure:"logdb_segment_async"`
	LogDBSegmentSize       int              `mapstructure:"logdb_segment_size"`
	DisableLogDBMmap       bool             `mapstructure:"disable_logdb_mmap"`
	BlockDbConfig          *DbConfig        `mapstructure:"blockdb_config"`
	StateDbConfig          *DbConfig        `mapstructure:"statedb_config"`
	HistoryDbConfig        *HistoryDbConfig `mapstructure:"historydb_config"`
	ResultDbConfig         *DbConfig        `mapstructure:"resultdb_config"`
	ContractEventDbConfig  *DbConfig        `mapstructure:"contract_eventdb_config"`
	TxExistDbConfig        *DbConfig        `mapstructure:"txexistdb_config"`
	UnArchiveBlockHeight   uint64           `mapstructure:"unarchive_block_height"`
	Async                  bool             `mapstructure:"is_async"`
	WriteBatchSize         uint64           `mapstructure:"write_batch_size"`
	Encryptor              string           `mapstructure:"encryptor"` //SM4  AES
	EncryptKey             string           `mapstructure:"encrypt_key"`

	WriteBlockType             int                   `mapstructure:"write_block_type"` //0 普通写, 1 高速写
	StateCache                 *CacheConfig          `mapstructure:"state_cache_config"`
	BigFilter                  *BigFilterConfig      `mapstructure:"bigfilter_config"`
	RollingWindowCacheCapacity uint64                `mapstructure:"rolling_window_cache_capacity"`
	EnableRWC                  bool                  `mapstructure:"enable_rwc"`
	BlockFileConfig            *BlockFileConfig      `mapstructure:"block_file_config"`
	ConfigVersion              *StorageConfigVersion `mapstructure:"storage_config_version"`
}

StorageConfig engine config

@Description:

func NewStorageConfig

func NewStorageConfig(cfg map[string]interface{}) (*StorageConfig, error)

NewStorageConfig new storage config from map structure

@Description:
@param cfg
@return *StorageConfig
@return error

func (*StorageConfig) GetActiveDBCount

func (config *StorageConfig) GetActiveDBCount() int

GetActiveDBCount 根据配置的DisableDB的情况,确定当前配置活跃的数据库数量

@Description:
@receiver config
@return int

func (*StorageConfig) GetBlockDbConfig

func (config *StorageConfig) GetBlockDbConfig() *DbConfig

GetBlockDbConfig 返回blockdb config

@Description:
@receiver config
@return *DbConfig

func (*StorageConfig) GetContractEventDbConfig

func (config *StorageConfig) GetContractEventDbConfig() *DbConfig

GetContractEventDbConfig 返回contractdb config

@Description:
@receiver config
@return *DbConfig

func (*StorageConfig) GetDefaultDBConfig

func (config *StorageConfig) GetDefaultDBConfig() *DbConfig

GetDefaultDBConfig 返回一个默认config

@Description:
@receiver config
@return *DbConfig

func (*StorageConfig) GetHistoryDbConfig

func (config *StorageConfig) GetHistoryDbConfig() *HistoryDbConfig

GetHistoryDbConfig 返回historydb config

@Description:
@receiver config
@return *HistoryDbConfig

func (*StorageConfig) GetResultDbConfig

func (config *StorageConfig) GetResultDbConfig() *DbConfig

GetResultDbConfig 返回resultdb config

@Description:
@receiver config
@return *DbConfig

func (*StorageConfig) GetStateDbConfig

func (config *StorageConfig) GetStateDbConfig() *DbConfig

GetStateDbConfig 返回statedb config

@Description:
@receiver config
@return *DbConfig

func (*StorageConfig) GetTxExistDbConfig

func (config *StorageConfig) GetTxExistDbConfig() *DbConfig

GetTxExistDbConfig 返回txExistdb config

@Description:
@receiver config
@return *DbConfig

type StorageConfigVersion

type StorageConfigVersion struct {
	Major int32 `mapstructure:"major_version"`
	Minor int32 `mapstructure:"minor_version"`
}

StorageConfigVersion storage version config option

@Description:

Jump to

Keyboard shortcuts

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